Skip to content
Snippets Groups Projects
Commit 20d77d5a authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Implement the _NET_WM_PING protcol

Implied by _NET_WM_PID being set, so may as well do it.
parent 76641ca7
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4389 passed
...@@ -65,7 +65,8 @@ bool x_internal_scaling = true; ...@@ -65,7 +65,8 @@ bool x_internal_scaling = true;
/* Sets the atom to be used for copy/paste operations */ /* Sets the atom to be used for copy/paste operations */
#define CONSOLE_CLIPBOARD XA_PRIMARY #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 Display *dpy=NULL;
static Window win; static Window win;
...@@ -611,6 +612,7 @@ static int init_window() ...@@ -611,6 +612,7 @@ static int init_window()
x11.XFree(classhints); x11.XFree(classhints);
WM_DELETE_WINDOW = x11.XInternAtom(dpy, "WM_DELETE_WINDOW", False); WM_DELETE_WINDOW = x11.XInternAtom(dpy, "WM_DELETE_WINDOW", False);
_NET_WM_PING = x11.XInternAtom(dpy, "_NET_WM_PING", False);
gcv.function = GXcopy; gcv.function = GXcopy;
gcv.foreground = black | 0xff000000; gcv.foreground = black | 0xff000000;
...@@ -623,7 +625,14 @@ static int init_window() ...@@ -623,7 +625,14 @@ static int init_window()
| ButtonReleaseMask | PointerMotionMask | StructureNotifyMask); | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask);
x11.XStoreName(dpy, win, "SyncConsole"); 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); return(0);
} }
...@@ -1040,10 +1049,14 @@ static int x11_event(XEvent *ev) ...@@ -1040,10 +1049,14 @@ static int x11_event(XEvent *ev)
return 0; return 0;
switch (ev->type) { switch (ev->type) {
case ClientMessage: 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; uint16_t key=CIO_KEY_QUIT;
write(key_pipe[1], &key, 2); 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; break;
/* Graphics related events */ /* Graphics related events */
case ConfigureNotify: { case ConfigureNotify: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment