From adbab8deae333f735a7fde44f464833dd437c914 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 16 Mar 2018 21:22:23 +0100 Subject: [PATCH] x11display: reenable confined mode on window reconfigure Fixes #280 --- panda/src/x11display/x11GraphicsWindow.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index c57a580aa7..0a1539bd42 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -446,6 +446,21 @@ process_events() { XConfigureWindow(_display, _xwindow, value_mask, &changes); } } + + // If the window was reconfigured, we may need to re-confine the mouse + // pointer. See GitHub bug #280. + if (_properties.get_mouse_mode() == WindowProperties::M_confined) { + X11_Cursor cursor = None; + if (_properties.get_cursor_hidden()) { + x11GraphicsPipe *x11_pipe; + DCAST_INTO_V(x11_pipe, _pipe); + cursor = x11_pipe->get_hidden_cursor(); + } + + XGrabPointer(_display, _xwindow, True, 0, GrabModeAsync, GrabModeAsync, + _xwindow, cursor, CurrentTime); + } + changed_properties = true; }