From 20d77d5a501bcb51eb98d31cb63ce7139a3263b6 Mon Sep 17 00:00:00 2001 From: Deuce <shurd@sasktel.net> Date: Fri, 2 Jun 2023 22:53:46 -0400 Subject: [PATCH] Implement the _NET_WM_PING protcol Implied by _NET_WM_PID being set, so may as well do it. --- src/conio/x_events.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/conio/x_events.c b/src/conio/x_events.c index 114db206c1..64b817421b 100644 --- a/src/conio/x_events.c +++ b/src/conio/x_events.c @@ -65,7 +65,8 @@ bool x_internal_scaling = true; /* Sets the atom to be used for copy/paste operations */ #define CONSOLE_CLIPBOARD XA_PRIMARY -static Atom WM_DELETE_WINDOW=0; +static Atom WM_DELETE_WINDOW = None; +static Atom _NET_WM_PING = None; static Display *dpy=NULL; static Window win; @@ -611,6 +612,7 @@ static int init_window() x11.XFree(classhints); WM_DELETE_WINDOW = x11.XInternAtom(dpy, "WM_DELETE_WINDOW", False); + _NET_WM_PING = x11.XInternAtom(dpy, "_NET_WM_PING", False); gcv.function = GXcopy; gcv.foreground = black | 0xff000000; @@ -623,7 +625,14 @@ static int init_window() | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask); x11.XStoreName(dpy, win, "SyncConsole"); - x11.XSetWMProtocols(dpy, win, &WM_DELETE_WINDOW, 1); + Atom protos[2]; + int i = 0; + if (WM_DELETE_WINDOW != None) + protos[i++] = WM_DELETE_WINDOW; + if (_NET_WM_PING != None) + protos[i++] = _NET_WM_PING; + if (i) + x11.XSetWMProtocols(dpy, win, protos, i); return(0); } @@ -1040,10 +1049,14 @@ static int x11_event(XEvent *ev) return 0; switch (ev->type) { case ClientMessage: - if (ev->xclient.format == 32 && ev->xclient.data.l[0] == WM_DELETE_WINDOW) { + if (ev->xclient.format == 32 && ev->xclient.data.l[0] == WM_DELETE_WINDOW && WM_DELETE_WINDOW != None) { uint16_t key=CIO_KEY_QUIT; write(key_pipe[1], &key, 2); } + else if(ev->xclient.format == 32 && ev->xclient.data.l[0] == _NET_WM_PING && _NET_WM_PING != None) { + ev->xclient.window = DefaultRootWindow(dpy); + x11.XSendEvent(dpy, ev->xclient.window, False, SubstructureNotifyMask | SubstructureRedirectMask, ev); + } break; /* Graphics related events */ case ConfigureNotify: { -- GitLab