keybindings: Have meta_change_keygrab take a MetaKeyDevirtCombo

This commit is contained in:
Jasper St. Pierre 2015-01-06 19:02:17 -08:00
parent 13acf9e35d
commit d12390002a

View File

@ -1156,10 +1156,9 @@ meta_display_shutdown_keys (MetaDisplay *display)
/* Grab/ungrab, ignoring all annoying modifiers like NumLock etc. */ /* Grab/ungrab, ignoring all annoying modifiers like NumLock etc. */
static void static void
meta_change_keygrab (MetaKeyBindingManager *keys, meta_change_keygrab (MetaKeyBindingManager *keys,
Window xwindow, Window xwindow,
gboolean grab, gboolean grab,
unsigned int keycode, MetaKeyDevirtCombo *devirt_combo)
int modmask)
{ {
unsigned int ignored_mask; unsigned int ignored_mask;
@ -1180,7 +1179,7 @@ meta_change_keygrab (MetaKeyBindingManager *keys,
meta_topic (META_DEBUG_KEYBINDINGS, meta_topic (META_DEBUG_KEYBINDINGS,
"%s keybinding keycode %d mask 0x%x on 0x%lx\n", "%s keybinding keycode %d mask 0x%x on 0x%lx\n",
grab ? "Grabbing" : "Ungrabbing", grab ? "Grabbing" : "Ungrabbing",
keycode, modmask, xwindow); devirt_combo->keycode, devirt_combo->mask, xwindow);
ignored_mask = 0; ignored_mask = 0;
while (ignored_mask <= keys->ignored_modifier_mask) while (ignored_mask <= keys->ignored_modifier_mask)
@ -1196,18 +1195,18 @@ meta_change_keygrab (MetaKeyBindingManager *keys,
continue; continue;
} }
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 }; mods = (XIGrabModifiers) { devirt_combo->mask | ignored_mask, 0 };
if (grab) if (grab)
XIGrabKeycode (xdisplay, XIGrabKeycode (xdisplay,
META_VIRTUAL_CORE_KEYBOARD_ID, META_VIRTUAL_CORE_KEYBOARD_ID,
keycode, xwindow, devirt_combo->keycode, xwindow,
XIGrabModeSync, XIGrabModeAsync, XIGrabModeSync, XIGrabModeAsync,
False, &mask, 1, &mods); False, &mask, 1, &mods);
else else
XIUngrabKeycode (xdisplay, XIUngrabKeycode (xdisplay,
META_VIRTUAL_CORE_KEYBOARD_ID, META_VIRTUAL_CORE_KEYBOARD_ID,
keycode, xwindow, 1, &mods); devirt_combo->keycode, xwindow, 1, &mods);
++ignored_mask; ++ignored_mask;
} }
@ -1236,9 +1235,7 @@ change_keygrab_foreach (gpointer key,
if (binding->devirt_combo.keycode == 0) if (binding->devirt_combo.keycode == 0)
return; return;
meta_change_keygrab (data->keys, data->xwindow, data->grab, meta_change_keygrab (data->keys, data->xwindow, data->grab, &binding->devirt_combo);
binding->devirt_combo.keycode,
binding->devirt_combo.mask);
} }
static void static void
@ -1265,9 +1262,7 @@ meta_screen_change_keygrabs (MetaScreen *screen,
MetaKeyBindingManager *keys = &display->key_binding_manager; MetaKeyBindingManager *keys = &display->key_binding_manager;
if (keys->overlay_key_devirt_combo.keycode != 0) if (keys->overlay_key_devirt_combo.keycode != 0)
meta_change_keygrab (keys, screen->xroot, grab, meta_change_keygrab (keys, screen->xroot, grab, &keys->overlay_key_devirt_combo);
keys->overlay_key_devirt_combo.keycode,
keys->overlay_key_devirt_combo.mask);
if (keys->iso_next_group_combos) if (keys->iso_next_group_combos)
{ {
@ -1275,11 +1270,8 @@ meta_screen_change_keygrabs (MetaScreen *screen,
while (i < keys->n_iso_next_group_combos) while (i < keys->n_iso_next_group_combos)
{ {
if (keys->iso_next_group_combos[i].keycode != 0) if (keys->iso_next_group_combos[i].keycode != 0)
{ meta_change_keygrab (keys, screen->xroot, grab, &keys->iso_next_group_combos[i]);
meta_change_keygrab (keys, screen->xroot, grab,
keys->iso_next_group_combos[i].keycode,
keys->iso_next_group_combos[i].mask);
}
++i; ++i;
} }
} }
@ -1425,7 +1417,7 @@ meta_display_grab_accelerator (MetaDisplay *display,
return META_KEYBINDING_ACTION_NONE; return META_KEYBINDING_ACTION_NONE;
if (META_IS_BACKEND_X11 (backend)) if (META_IS_BACKEND_X11 (backend))
meta_change_keygrab (keys, display->screen->xroot, TRUE, devirt_combo.keycode, devirt_combo.mask); meta_change_keygrab (keys, display->screen->xroot, TRUE, &devirt_combo);
grab = g_new0 (MetaKeyGrab, 1); grab = g_new0 (MetaKeyGrab, 1);
grab->action = next_dynamic_keybinding_action (); grab->action = next_dynamic_keybinding_action ();
@ -1474,9 +1466,7 @@ meta_display_ungrab_accelerator (MetaDisplay *display,
guint32 index_key; guint32 index_key;
if (META_IS_BACKEND_X11 (backend)) if (META_IS_BACKEND_X11 (backend))
meta_change_keygrab (keys, display->screen->xroot, FALSE, meta_change_keygrab (keys, display->screen->xroot, FALSE, &binding->devirt_combo);
binding->devirt_combo.keycode,
binding->devirt_combo.mask);
index_key = key_binding_key (binding->devirt_combo.keycode, binding->devirt_combo.mask); index_key = key_binding_key (binding->devirt_combo.keycode, binding->devirt_combo.mask);
g_hash_table_remove (keys->key_bindings_index, GINT_TO_POINTER (index_key)); g_hash_table_remove (keys->key_bindings_index, GINT_TO_POINTER (index_key));