keybindings: Move grab/freeze functions per backend
By making those functions virtual functions of MetaBackend and have the BackendNative implementation no op Helps https://gitlab.gnome.org/GNOME/mutter/-/issues/2272 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3583>
This commit is contained in:

committed by
Marge Bot

parent
868fbe622b
commit
bd1ca76168
@ -81,6 +81,15 @@ struct _MetaBackendClass
|
||||
int device_id,
|
||||
uint32_t timestamp);
|
||||
|
||||
void (* freeze_keyboard) (MetaBackend *backend,
|
||||
uint32_t timestamp);
|
||||
|
||||
void (* unfreeze_keyboard) (MetaBackend *backend,
|
||||
uint32_t timestamp);
|
||||
|
||||
void (* ungrab_keyboard) (MetaBackend *backend,
|
||||
uint32_t timestamp);
|
||||
|
||||
void (* finish_touch_sequence) (MetaBackend *backend,
|
||||
ClutterEventSequence *sequence,
|
||||
MetaSequenceState state);
|
||||
|
@ -647,6 +647,36 @@ meta_backend_real_is_headless (MetaBackend *backend)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_freeze_keyboard (MetaBackend *backend,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
g_return_if_fail (META_IS_BACKEND (backend));
|
||||
|
||||
if (META_BACKEND_GET_CLASS (backend)->freeze_keyboard)
|
||||
META_BACKEND_GET_CLASS (backend)->freeze_keyboard (backend, timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_unfreeze_keyboard (MetaBackend *backend,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
g_return_if_fail (META_IS_BACKEND (backend));
|
||||
|
||||
if (META_BACKEND_GET_CLASS (backend)->unfreeze_keyboard)
|
||||
META_BACKEND_GET_CLASS (backend)->unfreeze_keyboard (backend, timestamp);
|
||||
}
|
||||
|
||||
void
|
||||
meta_backend_ungrab_keyboard (MetaBackend *backend,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
g_return_if_fail (META_IS_BACKEND (backend));
|
||||
|
||||
if (META_BACKEND_GET_CLASS (backend)->ungrab_keyboard)
|
||||
META_BACKEND_GET_CLASS (backend)->ungrab_keyboard (backend, timestamp);
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_backend_is_lid_closed (MetaBackend *backend)
|
||||
{
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "meta/meta-cursor-tracker.h"
|
||||
#include "meta/util.h"
|
||||
#include "mtk/mtk-x11.h"
|
||||
#include "x11/window-x11.h"
|
||||
|
||||
struct _MetaBackendX11Private
|
||||
{
|
||||
@ -703,6 +704,71 @@ meta_backend_x11_ungrab_device (MetaBackend *backend,
|
||||
return (ret == Success);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_freeze_keyboard (MetaBackend *backend,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
MetaBackendX11 *backend_x11;
|
||||
Window xwindow;
|
||||
Display *xdisplay;
|
||||
|
||||
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);
|
||||
|
||||
/* Grab the keyboard, so we get key releases and all key
|
||||
* presses
|
||||
*/
|
||||
|
||||
backend_x11 = META_BACKEND_X11 (backend);
|
||||
xwindow = meta_backend_x11_get_xwindow (backend_x11);
|
||||
xdisplay = meta_backend_x11_get_xdisplay (backend_x11);
|
||||
|
||||
/* Strictly, we only need to set grab_mode on the keyboard device
|
||||
* while the pointer should always be XIGrabModeAsync. Unfortunately
|
||||
* there is a bug in the X server, only fixed (link below) in 1.15,
|
||||
* which swaps these arguments for keyboard devices. As such, we set
|
||||
* both the device and the paired device mode which works around
|
||||
* that bug and also works on fixed X servers.
|
||||
*
|
||||
* http://cgit.freedesktop.org/xorg/xserver/commit/?id=9003399708936481083424b4ff8f18a16b88b7b3
|
||||
*/
|
||||
XIGrabDevice (xdisplay,
|
||||
META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||
xwindow,
|
||||
timestamp,
|
||||
None,
|
||||
XIGrabModeSync, XIGrabModeSync,
|
||||
False, /* owner_events */
|
||||
&mask);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_unfreeze_keyboard (MetaBackend *backend,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
|
||||
|
||||
XIAllowEvents (xdisplay, META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||
XIAsyncDevice, timestamp);
|
||||
/* We shouldn't need to unfreeze the pointer device here, however we
|
||||
* have to, due to the workaround we do in grab_keyboard().
|
||||
*/
|
||||
XIAllowEvents (xdisplay, META_VIRTUAL_CORE_POINTER_ID,
|
||||
XIAsyncDevice, timestamp);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_ungrab_keyboard (MetaBackend *backend,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
Display *xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
|
||||
|
||||
XIUngrabDevice (xdisplay, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_x11_finish_touch_sequence (MetaBackend *backend,
|
||||
ClutterEventSequence *sequence,
|
||||
@ -993,6 +1059,9 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
|
||||
backend_class->post_init = meta_backend_x11_post_init;
|
||||
backend_class->grab_device = meta_backend_x11_grab_device;
|
||||
backend_class->ungrab_device = meta_backend_x11_ungrab_device;
|
||||
backend_class->freeze_keyboard = meta_backend_x11_freeze_keyboard;
|
||||
backend_class->unfreeze_keyboard = meta_backend_x11_unfreeze_keyboard;
|
||||
backend_class->ungrab_keyboard = meta_backend_x11_ungrab_keyboard;
|
||||
backend_class->finish_touch_sequence = meta_backend_x11_finish_touch_sequence;
|
||||
backend_class->get_current_logical_monitor = meta_backend_x11_get_current_logical_monitor;
|
||||
backend_class->get_keymap = meta_backend_x11_get_keymap;
|
||||
|
Reference in New Issue
Block a user