mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
keybindings: Do not grab the locate-pointer key if unnecessary
On X11, mutter needs to keep a grab on the locate-pointer key to be able to trigger the functionality time the corresponding key combo is pressed. However, doing so may have side effects on other X11 clients that would want to have a grab on the same key. Make sure we only actually grab the key combo for "locate-pointer" only when the feature is actually enabled, so that having the locate pointer feature turned off (the default) would not cause side effects on other X11 clients that might want to use the same key for their own use. Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/647
This commit is contained in:
parent
9c8ff5dbe8
commit
ac5d9ec558
@ -154,6 +154,7 @@ GList *meta_prefs_get_keybindings (void);
|
||||
void meta_prefs_get_overlay_binding (MetaKeyCombo *combo);
|
||||
void meta_prefs_get_locate_pointer_binding (MetaKeyCombo *combo);
|
||||
const char *meta_prefs_get_iso_next_group_option (void);
|
||||
gboolean meta_prefs_is_locate_pointer_enabled (void);
|
||||
|
||||
void meta_x11_display_grab_keys (MetaX11Display *x11_display);
|
||||
void meta_x11_display_ungrab_keys (MetaX11Display *x11_display);
|
||||
|
@ -182,6 +182,9 @@ static gboolean process_keyboard_resize_grab (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
ClutterKeyEvent *event);
|
||||
|
||||
static void maybe_update_locate_pointer_keygrab (MetaDisplay *display,
|
||||
gboolean grab);
|
||||
|
||||
static GHashTable *key_handlers;
|
||||
static GHashTable *external_grabs;
|
||||
|
||||
@ -1342,6 +1345,10 @@ prefs_changed_callback (MetaPreference pref,
|
||||
|
||||
switch (pref)
|
||||
{
|
||||
case META_PREF_LOCATE_POINTER:
|
||||
maybe_update_locate_pointer_keygrab (display,
|
||||
meta_prefs_is_locate_pointer_enabled());
|
||||
break;
|
||||
case META_PREF_KEYBINDINGS:
|
||||
ungrab_key_bindings (display);
|
||||
rebuild_key_binding_table (keys);
|
||||
@ -1491,6 +1498,21 @@ change_binding_keygrabs (MetaKeyBindingManager *keys,
|
||||
g_hash_table_foreach (keys->key_bindings, change_keygrab_foreach, &data);
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_update_locate_pointer_keygrab (MetaDisplay *display,
|
||||
gboolean grab)
|
||||
{
|
||||
MetaKeyBindingManager *keys = &display->key_binding_manager;
|
||||
|
||||
if (!display->x11_display)
|
||||
return;
|
||||
|
||||
if (keys->locate_pointer_resolved_key_combo.len != 0)
|
||||
meta_change_keygrab (keys, display->x11_display->xroot,
|
||||
(!!grab & !!meta_prefs_is_locate_pointer_enabled()),
|
||||
&keys->locate_pointer_resolved_key_combo);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_x11_display_change_keygrabs (MetaX11Display *x11_display,
|
||||
gboolean grab)
|
||||
@ -1502,9 +1524,7 @@ meta_x11_display_change_keygrabs (MetaX11Display *x11_display,
|
||||
meta_change_keygrab (keys, x11_display->xroot,
|
||||
grab, &keys->overlay_resolved_key_combo);
|
||||
|
||||
if (keys->locate_pointer_resolved_key_combo.len != 0)
|
||||
meta_change_keygrab (keys, x11_display->xroot,
|
||||
grab, &keys->locate_pointer_resolved_key_combo);
|
||||
maybe_update_locate_pointer_keygrab (x11_display->display, grab);
|
||||
|
||||
for (i = 0; i < keys->n_iso_next_group_combos; i++)
|
||||
meta_change_keygrab (keys, x11_display->xroot,
|
||||
|
@ -60,6 +60,7 @@
|
||||
|
||||
#define KEY_OVERLAY_KEY "overlay-key"
|
||||
#define KEY_WORKSPACES_ONLY_ON_PRIMARY "workspaces-only-on-primary"
|
||||
#define KEY_LOCATE_POINTER "locate-pointer"
|
||||
|
||||
/* These are the different schemas we are keeping
|
||||
* a GSettings instance for */
|
||||
@ -100,6 +101,7 @@ static gboolean bell_is_visible = FALSE;
|
||||
static gboolean bell_is_audible = TRUE;
|
||||
static gboolean gnome_accessibility = FALSE;
|
||||
static gboolean gnome_animations = TRUE;
|
||||
static gboolean locate_pointer_is_enabled = FALSE;
|
||||
static char *cursor_theme = NULL;
|
||||
/* cursor_size will, when running as an X11 compositing window manager, be the
|
||||
* actual cursor size, multiplied with the global window scaling factor. On
|
||||
@ -147,6 +149,7 @@ static gboolean mouse_button_mods_handler (GVariant*, gpointer*, gpointer);
|
||||
static gboolean button_layout_handler (GVariant*, gpointer*, gpointer);
|
||||
static gboolean overlay_key_handler (GVariant*, gpointer*, gpointer);
|
||||
static gboolean locate_pointer_key_handler (GVariant*, gpointer*, gpointer);
|
||||
|
||||
static gboolean iso_next_group_handler (GVariant*, gpointer*, gpointer);
|
||||
|
||||
static void init_bindings (void);
|
||||
@ -384,6 +387,13 @@ static MetaBoolPreference preferences_bool[] =
|
||||
},
|
||||
&auto_maximize,
|
||||
},
|
||||
{
|
||||
{ KEY_LOCATE_POINTER,
|
||||
SCHEMA_INTERFACE,
|
||||
META_PREF_LOCATE_POINTER,
|
||||
},
|
||||
&locate_pointer_is_enabled,
|
||||
},
|
||||
{ { NULL, 0, 0 }, NULL },
|
||||
};
|
||||
|
||||
@ -960,6 +970,8 @@ meta_prefs_init (void)
|
||||
G_CALLBACK (settings_changed), NULL);
|
||||
g_signal_connect (settings, "changed::" KEY_GNOME_CURSOR_SIZE,
|
||||
G_CALLBACK (settings_changed), NULL);
|
||||
g_signal_connect (settings, "changed::" KEY_LOCATE_POINTER,
|
||||
G_CALLBACK (settings_changed), NULL);
|
||||
g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_INTERFACE), settings);
|
||||
|
||||
settings = g_settings_new (SCHEMA_INPUT_SOURCES);
|
||||
@ -1680,6 +1692,9 @@ meta_preference_to_string (MetaPreference pref)
|
||||
|
||||
case META_PREF_AUTO_MAXIMIZE:
|
||||
return "AUTO_MAXIMIZE";
|
||||
|
||||
case META_PREF_LOCATE_POINTER:
|
||||
return "LOCATE_POINTER";
|
||||
}
|
||||
|
||||
return "(unknown)";
|
||||
@ -2020,6 +2035,12 @@ meta_prefs_get_locate_pointer_binding (MetaKeyCombo *combo)
|
||||
*combo = locate_pointer_key_combo;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_prefs_is_locate_pointer_enabled (void)
|
||||
{
|
||||
return locate_pointer_is_enabled;
|
||||
}
|
||||
|
||||
const char *
|
||||
meta_prefs_get_iso_next_group_option (void)
|
||||
{
|
||||
|
@ -65,6 +65,7 @@
|
||||
* @META_PREF_AUTO_MAXIMIZE: auto-maximize
|
||||
* @META_PREF_CENTER_NEW_WINDOWS: center new windows
|
||||
* @META_PREF_DRAG_THRESHOLD: drag threshold
|
||||
* @META_PREF_LOCATE_POINTER: show pointer location
|
||||
*/
|
||||
|
||||
/* Keep in sync with GSettings schemas! */
|
||||
@ -103,6 +104,7 @@ typedef enum
|
||||
META_PREF_AUTO_MAXIMIZE,
|
||||
META_PREF_CENTER_NEW_WINDOWS,
|
||||
META_PREF_DRAG_THRESHOLD,
|
||||
META_PREF_LOCATE_POINTER,
|
||||
} MetaPreference;
|
||||
|
||||
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
|
||||
|
Loading…
Reference in New Issue
Block a user