From e6167bc9300d497b1f2edf3a307164081e24f2bd Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 6 Sep 2022 20:26:10 +0200 Subject: Set NET_WM_PID --- include/mgl/mgl.h | 1 + src/mgl.c | 1 + src/window/window.c | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/include/mgl/mgl.h b/include/mgl/mgl.h index 7b02ceb..4cbc8d5 100644 --- a/include/mgl/mgl.h +++ b/include/mgl/mgl.h @@ -13,6 +13,7 @@ struct mgl_context { _XVisualInfo *visual_info; unsigned long wm_delete_window_atom; unsigned long net_wm_ping_atom; + unsigned long net_wm_pid_atom; }; /* diff --git a/src/mgl.c b/src/mgl.c index f93704e..dd5cccd 100644 --- a/src/mgl.c +++ b/src/mgl.c @@ -77,6 +77,7 @@ int mgl_init(void) { } context.net_wm_ping_atom = XInternAtom(context.connection, "_NET_WM_PING", True); + context.net_wm_pid_atom = XInternAtom(context.connection, "_NET_WM_PID", True); if(mgl_gl_load(&context.gl) != 0) { mgl_deinit(); diff --git a/src/window/window.c b/src/window/window.c index 08c4585..c03d681 100644 --- a/src/window/window.c +++ b/src/window/window.c @@ -331,6 +331,13 @@ static int mgl_window_init(mgl_window *self, const char *title, const mgl_window context->net_wm_ping_atom }; XSetWMProtocols(context->connection, self->window, wm_protocol_atoms, 2); + + if(context->net_wm_pid_atom) { + const long pid = getpid(); + XChangeProperty(context->connection, self->window, context->net_wm_pid_atom, XA_CARDINAL, + 32, PropModeReplace, (const unsigned char*)&pid, 1); + } + XFlush(context->connection); /* TODO: Check for failure? */ -- cgit v1.2.3