mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[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:
parent
5aa7a391ac
commit
d74307223f
@ -138,18 +138,6 @@ static bool x11Init(const LG_DSInitParams params)
|
|||||||
}
|
}
|
||||||
#endif
|
#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.window = XCreateWindow(
|
||||||
x11.display,
|
x11.display,
|
||||||
XDefaultRootWindow(x11.display),
|
XDefaultRootWindow(x11.display),
|
||||||
@ -179,6 +167,15 @@ static bool x11Init(const LG_DSInitParams params)
|
|||||||
free(hint.res_name);
|
free(hint.res_name);
|
||||||
free(hint.res_class);
|
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();
|
X11AtomsInit();
|
||||||
XSetWMProtocols(x11.display, x11.window, &x11atoms.WM_DELETE_WINDOW, 1);
|
XSetWMProtocols(x11.display, x11.window, &x11atoms.WM_DELETE_WINDOW, 1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user