handle WM_DELETE_WINDOW better

This commit is contained in:
NishiOwO
2025-12-31 00:48:44 +09:00
parent 3f9125d1ae
commit 823c865791
2 changed files with 5 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ struct _MwLLX11 {
GC gc;
Colormap colormap;
Atom wm_delete;
Atom wm_protocols;
XIM xim;
XIC xic;

View File

@@ -211,6 +211,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
r->x11.colormap = DefaultColormap(r->x11.display, XDefaultScreen(r->x11.display));
r->x11.wm_delete = XInternAtom(r->x11.display, "WM_DELETE_WINDOW", False);
r->x11.wm_protocols = XInternAtom(r->x11.display, "WM_PROTOCOLS", False);
XSetWMProtocols(r->x11.display, r->x11.window, &r->x11.wm_delete, 1);
r->x11.gc = XCreateGC(r->x11.display, r->x11.window, 0, NULL);
@@ -471,7 +472,7 @@ static void MwLLNextEventImpl(MwLL handle) {
handle->x11.width = ev.xconfigure.width;
handle->x11.height = ev.xconfigure.height;
} else if(ev.type == ClientMessage) {
if(ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
if(ev.xclient.message_type == handle->x11.wm_protocols && ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
MwLLDispatch(handle, close, NULL);
}
} else if(ev.type == FocusIn) {