Skip to content

Commit 45eb631

Browse files
committed
x11: Resize fixed-size windows after mapping on xmonad
XMonad ignores size hints and shrinks the client area to overlay borders on fixed-size windows, even if no borders were requested, resulting in the window client area being smaller than requested. Calling XResizeWindow after mapping seems to fix it, even though resizing fixed-size windows in this manner doesn't work on any other window manager.
1 parent 7dd5e76 commit 45eb631

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/video/x11/SDL_x11window.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ static Bool X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*p
8686
}
8787
*/
8888

89+
static bool X11_CheckCurrentDesktop(const char *name)
90+
{
91+
SDL_Environment *env = SDL_GetEnvironment();
92+
const char *desktopVar = SDL_GetEnvironmentVariable(env, "DESKTOP_SESSION");
93+
if (desktopVar && SDL_strcasecmp(desktopVar, name) == 0) {
94+
return true;
95+
}
96+
97+
desktopVar = SDL_GetEnvironmentVariable(env, "XDG_CURRENT_DESKTOP");
98+
99+
if (desktopVar && SDL_strcasestr(desktopVar, name)) {
100+
return true;
101+
}
102+
103+
return false;
104+
}
105+
89106
static bool X11_IsWindowMapped(SDL_VideoDevice *_this, SDL_Window *window)
90107
{
91108
SDL_WindowData *data = window->internal;
@@ -1576,6 +1593,15 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
15761593
X11_XMoveWindow(display, data->xwindow, x, y);
15771594
}
15781595

1596+
/* XMonad ignores size hints and shrinks the client area to overlay borders on fixed-size windows,
1597+
* even if no borders were requested, resulting in the window client area being smaller than
1598+
* requested. Calling XResizeWindow after mapping seems to fix it, even though resizing fixed-size
1599+
* windows in this manner doesn't work on any other window manager.
1600+
*/
1601+
if (!(window->flags & SDL_WINDOW_RESIZABLE) && X11_CheckCurrentDesktop("xmonad")) {
1602+
X11_XResizeWindow(display, data->xwindow, window->w, window->h);
1603+
}
1604+
15791605
/* Some window managers can send garbage coordinates while mapping the window, so don't emit size and position
15801606
* events during the initial configure events.
15811607
*/

0 commit comments

Comments
 (0)