[client] x11: properly handle window destruction and fullscreen support

This commit is contained in:
Geoffrey McRae 2021-01-28 00:31:21 +11:00
parent 973806dd9c
commit 06af101bf9

View File

@ -74,6 +74,8 @@ struct X11DSState
Atom aNetFrameExtents; Atom aNetFrameExtents;
Atom aNetWMState; Atom aNetWMState;
Atom aNetWMStateFullscreen; Atom aNetWMStateFullscreen;
Atom aNetWMWindowType;
Atom aNetWMWindowTypeNormal;
// clipboard members // clipboard members
Atom aSelection; Atom aSelection;
@ -201,9 +203,35 @@ static bool x11Init(const LG_DSInitParams params)
XInternAtom(x11.display, "_NET_WM_STATE", True); XInternAtom(x11.display, "_NET_WM_STATE", True);
x11.aNetWMStateFullscreen = x11.aNetWMStateFullscreen =
XInternAtom(x11.display, "_NET_WM_STATE_FULLSCREEN", True); XInternAtom(x11.display, "_NET_WM_STATE_FULLSCREEN", True);
x11.aNetWMWindowType =
XInternAtom(x11.display, "_NET_WM_WINDOW_TYPE", True);
x11.aNetWMWindowTypeNormal =
XInternAtom(x11.display, "_NET_WM_WINDOW_TYPE_NORMAL", True);
XChangeProperty(
x11.display,
x11.window,
x11.aNetWMWindowType,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&x11.aNetWMWindowTypeNormal,
1
);
if (params.fullscreen) if (params.fullscreen)
x11SetFullscreen(true); {
XChangeProperty(
x11.display,
x11.window,
x11.aNetWMState,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&x11.aNetWMStateFullscreen,
1
);
}
if (x11.aNetReqFrameExtents) if (x11.aNetReqFrameExtents)
{ {
@ -395,7 +423,9 @@ static void x11Free(void)
{ {
lgJoinThread(x11.eventThread, NULL); lgJoinThread(x11.eventThread, NULL);
if (x11.window)
XDestroyWindow(x11.display, x11.window); XDestroyWindow(x11.display, x11.window);
XFreeCursor(x11.display, x11.squareCursor); XFreeCursor(x11.display, x11.squareCursor);
XFreeCursor(x11.display, x11.blankCursor); XFreeCursor(x11.display, x11.blankCursor);
XCloseDisplay(x11.display); XCloseDisplay(x11.display);
@ -478,6 +508,15 @@ static int x11EventThread(void * unused)
switch(xe.type) switch(xe.type)
{ {
case DestroyNotify:
if (xe.xdestroywindow.display == x11.display &&
xe.xdestroywindow.window == x11.window)
{
x11.window = 0;
app_handleCloseEvent();
}
break;
case ConfigureNotify: case ConfigureNotify:
{ {
int x, y; int x, y;