display: Make sure to ungrab the pointer before starting a grab op

Now that we grab devices on the X11 connection, we can run into
cross-connection issues. Since GTK+ frames are on the UI connection,
they'll get the passive grab when we click on them. Forcibly ungrab
on GTK+'s connection before attempting to take a grab on the backend
connection ourselves.
This commit is contained in:
Jasper St. Pierre 2014-04-24 10:42:18 -04:00
parent 1ef06207a4
commit 5b83bfb1db

View File

@ -1762,7 +1762,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
"Doing grab op %u on window %s button %d pointer already grabbed: %d pointer pos %d,%d\n",
op, window ? window->desc : "none", button, pointer_already_grabbed,
root_x, root_y);
if (display->grab_op != META_GRAB_OP_NONE)
{
if (window)
@ -1800,6 +1800,15 @@ meta_display_begin_grab_op (MetaDisplay *display,
if (pointer_already_grabbed)
display->grab_have_pointer = TRUE;
/* Since grab operations often happen as a result of implicit
* pointer operations on the display X11 connection, we need
* to ungrab here to ensure that the backend's X11 can take
* the device grab. */
XIUngrabDevice (display->xdisplay,
META_VIRTUAL_CORE_POINTER_ID,
timestamp);
XSync (display->xdisplay, False);
meta_display_set_grab_op_cursor (display, op, timestamp);
if (!display->grab_have_pointer && !meta_grab_op_is_keyboard (op))