Browse Source

x11: Support _NET_WM_PING

rdb 3 years ago
parent
commit
f593026061

+ 1 - 0
panda/src/x11display/x11GraphicsPipe.cxx

@@ -377,6 +377,7 @@ x11GraphicsPipe(const std::string &display) :
   // Get some X atom numbers.
   _wm_delete_window = XInternAtom(_display, "WM_DELETE_WINDOW", false);
   _net_wm_pid = XInternAtom(_display, "_NET_WM_PID", false);
+  _net_wm_ping = XInternAtom(_display, "_NET_WM_PING", false);
   _net_wm_window_type = XInternAtom(_display, "_NET_WM_WINDOW_TYPE", false);
   _net_wm_window_type_splash = XInternAtom(_display, "_NET_WM_WINDOW_TYPE_SPLASH", false);
   _net_wm_window_type_fullscreen = XInternAtom(_display, "_NET_WM_WINDOW_TYPE_FULLSCREEN", false);

+ 1 - 0
panda/src/x11display/x11GraphicsPipe.h

@@ -167,6 +167,7 @@ public:
   // Atom specifications.
   Atom _wm_delete_window;
   Atom _net_wm_pid;
+  Atom _net_wm_ping;
   Atom _net_wm_window_type;
   Atom _net_wm_window_type_splash;
   Atom _net_wm_window_type_fullscreen;

+ 8 - 3
panda/src/x11display/x11GraphicsWindow.cxx

@@ -120,6 +120,7 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
   _raw_mouse_enabled = false;
   _override_redirect = False;
   _wm_delete_window = x11_pipe->_wm_delete_window;
+  _net_wm_ping = x11_pipe->_net_wm_ping;
 
   PT(GraphicsWindowInputDevice) device = GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
   add_input_device(device);
@@ -513,6 +514,12 @@ process_events() {
           system_changed_properties(properties);
         }
       }
+      else if ((Atom)(event.xclient.data.l[0]) == _net_wm_ping &&
+               event.xclient.window == _xwindow) {
+        DCAST_INTO_V(x11_pipe, _pipe);
+        event.xclient.window = x11_pipe->get_root();
+        XSendEvent(_display, x11_pipe->get_root(), False, SubstructureRedirectMask | SubstructureNotifyMask, &event);
+      }
       break;
 
     case DestroyNotify:
@@ -1480,9 +1487,6 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) {
     // mapped.  To do this, we need to send a client message to the root
     // window for each change.
 
-    x11GraphicsPipe *x11_pipe;
-    DCAST_INTO_V(x11_pipe, _pipe);
-
     for (int i = 0; i < next_set_data; ++i) {
       XClientMessageEvent event;
       memset(&event, 0, sizeof(event));
@@ -1519,6 +1523,7 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) {
   // X server if the user requests a window close.
   Atom protocols[] = {
     _wm_delete_window,
+    _net_wm_ping,
   };
 
   XSetWMProtocols(_display, _xwindow, protocols,

+ 1 - 0
panda/src/x11display/x11GraphicsWindow.h

@@ -108,6 +108,7 @@ protected:
   bool _raw_mouse_enabled;
   Bool _override_redirect;
   Atom _wm_delete_window;
+  Atom _net_wm_ping;
 
   x11GraphicsPipe::pfn_XRRGetScreenInfo _XRRGetScreenInfo;
   x11GraphicsPipe::pfn_XRRSetScreenConfig _XRRSetScreenConfig;