mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
compositor: Use XInput2 to grab the pointer/keyboard
https://bugzilla.gnome.org/show_bug.cgi?id=688779
This commit is contained in:
parent
946a42f13e
commit
55251aa986
@ -358,14 +358,23 @@ meta_begin_modal_for_plugin (MetaScreen *screen,
|
||||
|
||||
if ((options & META_MODAL_POINTER_ALREADY_GRABBED) == 0)
|
||||
{
|
||||
result = XGrabPointer (xdpy, grab_window,
|
||||
False, /* owner_events */
|
||||
(ButtonPressMask | ButtonReleaseMask |
|
||||
EnterWindowMask | LeaveWindowMask | PointerMotionMask),
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
None, /* confine to */
|
||||
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
||||
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
|
||||
|
||||
XISetMask (mask.mask, XI_ButtonPress);
|
||||
XISetMask (mask.mask, XI_ButtonRelease);
|
||||
XISetMask (mask.mask, XI_Enter);
|
||||
XISetMask (mask.mask, XI_Leave);
|
||||
XISetMask (mask.mask, XI_Motion);
|
||||
|
||||
result = XIGrabDevice (xdpy,
|
||||
META_VIRTUAL_CORE_POINTER_ID,
|
||||
grab_window,
|
||||
timestamp,
|
||||
cursor,
|
||||
timestamp);
|
||||
XIGrabModeAsync, XIGrabModeAsync,
|
||||
False, /* owner_events */
|
||||
&mask);
|
||||
if (result != Success)
|
||||
goto fail;
|
||||
|
||||
@ -374,10 +383,20 @@ meta_begin_modal_for_plugin (MetaScreen *screen,
|
||||
|
||||
if ((options & META_MODAL_KEYBOARD_ALREADY_GRABBED) == 0)
|
||||
{
|
||||
result = XGrabKeyboard (xdpy, grab_window,
|
||||
False, /* owner_events */
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
timestamp);
|
||||
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
||||
XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
|
||||
|
||||
XISetMask (mask.mask, XI_KeyPress);
|
||||
XISetMask (mask.mask, XI_KeyRelease);
|
||||
|
||||
result = XIGrabDevice (xdpy,
|
||||
META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||
grab_window,
|
||||
timestamp,
|
||||
None,
|
||||
XIGrabModeAsync, XIGrabModeAsync,
|
||||
False, /* owner_events */
|
||||
&mask);
|
||||
|
||||
if (result != Success)
|
||||
goto fail;
|
||||
@ -397,9 +416,9 @@ meta_begin_modal_for_plugin (MetaScreen *screen,
|
||||
|
||||
fail:
|
||||
if (pointer_grabbed)
|
||||
XUngrabPointer (xdpy, timestamp);
|
||||
XIUngrabDevice (xdpy, META_VIRTUAL_CORE_POINTER_ID, timestamp);
|
||||
if (keyboard_grabbed)
|
||||
XUngrabKeyboard (xdpy, timestamp);
|
||||
XIUngrabDevice (xdpy, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -415,8 +434,8 @@ meta_end_modal_for_plugin (MetaScreen *screen,
|
||||
|
||||
g_return_if_fail (compositor->modal_plugin == plugin);
|
||||
|
||||
XUngrabPointer (xdpy, timestamp);
|
||||
XUngrabKeyboard (xdpy, timestamp);
|
||||
XIUngrabDevice (xdpy, META_VIRTUAL_CORE_POINTER_ID, timestamp);
|
||||
XIUngrabDevice (xdpy, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
|
||||
|
||||
display->grab_op = META_GRAB_OP_NONE;
|
||||
display->grab_window = NULL;
|
||||
|
@ -74,10 +74,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* This is set in stone and also hard-coded in GDK. */
|
||||
#define VIRTUAL_CORE_POINTER_ID 2
|
||||
#define VIRTUAL_CORE_KEYBOARD_ID 3
|
||||
|
||||
#define GRAB_OP_IS_WINDOW_SWITCH(g) \
|
||||
(g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL || \
|
||||
g == META_GRAB_OP_KEYBOARD_TABBING_DOCK || \
|
||||
@ -1816,19 +1812,19 @@ get_input_event (MetaDisplay *display,
|
||||
case XI_Motion:
|
||||
case XI_ButtonPress:
|
||||
case XI_ButtonRelease:
|
||||
if (((XIDeviceEvent *) input_event)->deviceid == VIRTUAL_CORE_POINTER_ID)
|
||||
if (((XIDeviceEvent *) input_event)->deviceid == META_VIRTUAL_CORE_POINTER_ID)
|
||||
return input_event;
|
||||
case XI_KeyPress:
|
||||
case XI_KeyRelease:
|
||||
if (((XIDeviceEvent *) input_event)->deviceid == VIRTUAL_CORE_KEYBOARD_ID)
|
||||
if (((XIDeviceEvent *) input_event)->deviceid == META_VIRTUAL_CORE_KEYBOARD_ID)
|
||||
return input_event;
|
||||
case XI_FocusIn:
|
||||
case XI_FocusOut:
|
||||
if (((XIEnterEvent *) input_event)->deviceid == VIRTUAL_CORE_KEYBOARD_ID)
|
||||
if (((XIEnterEvent *) input_event)->deviceid == META_VIRTUAL_CORE_KEYBOARD_ID)
|
||||
return input_event;
|
||||
case XI_Enter:
|
||||
case XI_Leave:
|
||||
if (((XIEnterEvent *) input_event)->deviceid == VIRTUAL_CORE_POINTER_ID)
|
||||
if (((XIEnterEvent *) input_event)->deviceid == META_VIRTUAL_CORE_POINTER_ID)
|
||||
return input_event;
|
||||
default:
|
||||
break;
|
||||
@ -2877,7 +2873,7 @@ event_callback (XEvent *event,
|
||||
break;
|
||||
case XkbNewKeyboardNotify:
|
||||
case XkbMapNotify:
|
||||
if (xkb_ev->device == VIRTUAL_CORE_KEYBOARD_ID)
|
||||
if (xkb_ev->device == META_VIRTUAL_CORE_KEYBOARD_ID)
|
||||
meta_display_process_mapping_event (display, event);
|
||||
break;
|
||||
}
|
||||
|
@ -35,6 +35,10 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/* This is set in stone and also hard-coded in GDK. */
|
||||
#define META_VIRTUAL_CORE_POINTER_ID 2
|
||||
#define META_VIRTUAL_CORE_KEYBOARD_ID 3
|
||||
|
||||
typedef struct _MetaResizePopup MetaResizePopup;
|
||||
|
||||
typedef enum
|
||||
|
Loading…
Reference in New Issue
Block a user