From 06af101bf9ca8a8dfdc04e0c79a0620e04f08f71 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 28 Jan 2021 00:31:21 +1100 Subject: [PATCH] [client] x11: properly handle window destruction and fullscreen support --- client/displayservers/X11/x11.c | 43 +++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 323db306..3844d4e4 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -74,6 +74,8 @@ struct X11DSState Atom aNetFrameExtents; Atom aNetWMState; Atom aNetWMStateFullscreen; + Atom aNetWMWindowType; + Atom aNetWMWindowTypeNormal; // clipboard members Atom aSelection; @@ -201,9 +203,35 @@ static bool x11Init(const LG_DSInitParams params) XInternAtom(x11.display, "_NET_WM_STATE", True); x11.aNetWMStateFullscreen = 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) - x11SetFullscreen(true); + { + XChangeProperty( + x11.display, + x11.window, + x11.aNetWMState, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&x11.aNetWMStateFullscreen, + 1 + ); + } if (x11.aNetReqFrameExtents) { @@ -395,7 +423,9 @@ static void x11Free(void) { lgJoinThread(x11.eventThread, NULL); - XDestroyWindow(x11.display, x11.window); + if (x11.window) + XDestroyWindow(x11.display, x11.window); + XFreeCursor(x11.display, x11.squareCursor); XFreeCursor(x11.display, x11.blankCursor); XCloseDisplay(x11.display); @@ -478,6 +508,15 @@ static int x11EventThread(void * unused) switch(xe.type) { + case DestroyNotify: + if (xe.xdestroywindow.display == x11.display && + xe.xdestroywindow.window == x11.window) + { + x11.window = 0; + app_handleCloseEvent(); + } + break; + case ConfigureNotify: { int x, y;