Browse Source

x11display: Release M_relative mouse when window loses focus

Fixes #480
Mitchell Stokes 7 years ago
parent
commit
8dcb735f2b
1 changed files with 14 additions and 4 deletions
  1. 14 4
      panda/src/x11display/x11GraphicsWindow.cxx

+ 14 - 4
panda/src/x11display/x11GraphicsWindow.cxx

@@ -508,23 +508,33 @@ process_events() {
     changed_properties = true;
     changed_properties = true;
   }
   }
 
 
-  if (properties.has_foreground() && _properties.get_mouse_mode() == WindowProperties::M_confined) {
+  if (properties.has_foreground() && (
+        _properties.get_mouse_mode() == WindowProperties::M_confined ||
+        _dga_mouse_enabled)) {
+       x11GraphicsPipe *x11_pipe;
+       DCAST_INTO_V(x11_pipe, _pipe);
+
       // Focus has changed, let's let go of the pointer if we've grabbed or re-grab it if needed
       // Focus has changed, let's let go of the pointer if we've grabbed or re-grab it if needed
       if (properties.get_foreground()) {
       if (properties.get_foreground()) {
         // Window is going to the foreground, re-grab the pointer
         // Window is going to the foreground, re-grab the pointer
         X11_Cursor cursor = None;
         X11_Cursor cursor = None;
         if (_properties.get_cursor_hidden()) {
         if (_properties.get_cursor_hidden()) {
-            x11GraphicsPipe *x11_pipe;
-            DCAST_INTO_V(x11_pipe, _pipe);
             cursor = x11_pipe->get_hidden_cursor();
             cursor = x11_pipe->get_hidden_cursor();
         }
         }
 
 
         XGrabPointer(_display, _xwindow, True, 0, GrabModeAsync, GrabModeAsync,
         XGrabPointer(_display, _xwindow, True, 0, GrabModeAsync, GrabModeAsync,
                     _xwindow, cursor, CurrentTime);
                     _xwindow, cursor, CurrentTime);
+        if (_dga_mouse_enabled) {
+          x11_pipe->enable_relative_mouse();
+        }
       }
       }
       else {
       else {
         // window is leaving the foreground, ungrab the pointer
         // window is leaving the foreground, ungrab the pointer
-        XUngrabPointer(_display, CurrentTime);
+        if (_dga_mouse_enabled) {
+          x11_pipe->disable_relative_mouse();
+        } else if (_properties.get_mouse_mode() == WindowProperties::M_confined) {
+          XUngrabPointer(_display, CurrentTime);
+        }
       }
       }
   }
   }