[client] x11: handle window deletion properly

This commit is contained in:
Geoffrey McRae 2021-01-31 21:43:54 +11:00
parent 5ac53362a3
commit 17d423db06

View File

@ -76,6 +76,7 @@ struct X11DSState
Atom aNetWMStateFullscreen; Atom aNetWMStateFullscreen;
Atom aNetWMWindowType; Atom aNetWMWindowType;
Atom aNetWMWindowTypeNormal; Atom aNetWMWindowTypeNormal;
Atom aWMDeleteWindow;
// clipboard members // clipboard members
Atom aSelection; Atom aSelection;
@ -209,17 +210,21 @@ static bool x11Init(const LG_DSInitParams params)
XInternAtom(x11.display, "_NET_WM_WINDOW_TYPE", True); XInternAtom(x11.display, "_NET_WM_WINDOW_TYPE", True);
x11.aNetWMWindowTypeNormal = x11.aNetWMWindowTypeNormal =
XInternAtom(x11.display, "_NET_WM_WINDOW_TYPE_NORMAL", True); XInternAtom(x11.display, "_NET_WM_WINDOW_TYPE_NORMAL", True);
x11.aWMDeleteWindow =
XInternAtom(x11.display, "WM_DELETE_WINDOW", True);
XChangeProperty( XSetWMProtocols(x11.display, x11.window, &x11.aWMDeleteWindow, 1);
x11.display,
x11.window, XChangeProperty(
x11.aNetWMWindowType, x11.display,
XA_CARDINAL, x11.window,
32, x11.aNetWMWindowType,
PropModeReplace, XA_CARDINAL,
(unsigned char *)&x11.aNetWMWindowTypeNormal, 32,
1 PropModeReplace,
); (unsigned char *)&x11.aNetWMWindowTypeNormal,
1
);
if (params.fullscreen) if (params.fullscreen)
{ {
@ -510,13 +515,9 @@ static int x11EventThread(void * unused)
switch(xe.type) switch(xe.type)
{ {
case DestroyNotify: case ClientMessage:
if (xe.xdestroywindow.display == x11.display && if (xe.xclient.data.l[0] == x11.aWMDeleteWindow)
xe.xdestroywindow.window == x11.window)
{
x11.window = 0;
app_handleCloseEvent(); app_handleCloseEvent();
}
break; break;
case ConfigureNotify: case ConfigureNotify: