[client] x11: set the window center via WM_SIZE_HINTS

Due to the confusing nature of the x11 protocol, bit_gravity and
win_gravity are not what they appear to be. These do not describe the
window position but rather the pixels/subwindows when the window is
resized. Instead set the gravity via the WM_SIZE_HINTS property which
all modern window managers should respect.
This commit is contained in:
Geoffrey McRae 2021-03-27 21:05:27 +11:00
parent 5aa7a391ac
commit d74307223f

View File

@ -138,18 +138,6 @@ static bool x11Init(const LG_DSInitParams params)
}
#endif
swaMask |= CWBitGravity | CWWinGravity;
if (params.center)
{
swa.bit_gravity = CenterGravity;
swa.win_gravity = CenterGravity;
}
else
{
swa.bit_gravity = NorthWestGravity;
swa.win_gravity = NorthWestGravity;
}
x11.window = XCreateWindow(
x11.display,
XDefaultRootWindow(x11.display),
@ -179,6 +167,15 @@ static bool x11Init(const LG_DSInitParams params)
free(hint.res_name);
free(hint.res_class);
if (params.center)
{
XSizeHints *xsh = XAllocSizeHints();
xsh->flags = PWinGravity;
xsh->win_gravity = 5; //Center
XSetWMNormalHints(x11.display, x11.window, xsh);
XFree(xsh);
}
X11AtomsInit();
XSetWMProtocols(x11.display, x11.window, &x11atoms.WM_DELETE_WINDOW, 1);