keybindings: Keep virtual modifier masks around

Besides the resolved real modifier masks, having the virtual masks
around will be useful too.

https://bugzilla.gnome.org/show_bug.cgi?id=748526
This commit is contained in:
Rui Matos 2015-11-03 17:52:10 +01:00
parent 5d6af70bc9
commit 82a247ccf5
2 changed files with 15 additions and 5 deletions

View File

@ -94,8 +94,11 @@ typedef struct
GHashTable *key_bindings_index; GHashTable *key_bindings_index;
xkb_mod_mask_t ignored_modifier_mask; xkb_mod_mask_t ignored_modifier_mask;
xkb_mod_mask_t hyper_mask; xkb_mod_mask_t hyper_mask;
xkb_mod_mask_t virtual_hyper_mask;
xkb_mod_mask_t super_mask; xkb_mod_mask_t super_mask;
xkb_mod_mask_t virtual_super_mask;
xkb_mod_mask_t meta_mask; xkb_mod_mask_t meta_mask;
xkb_mod_mask_t virtual_meta_mask;
MetaKeyCombo overlay_key_combo; MetaKeyCombo overlay_key_combo;
MetaResolvedKeyCombo overlay_resolved_key_combo; MetaResolvedKeyCombo overlay_resolved_key_combo;
gboolean overlay_key_only_pressed; gboolean overlay_key_only_pressed;

View File

@ -185,16 +185,18 @@ reload_modmap (MetaKeyBindingManager *keys)
struct xkb_keymap *keymap = meta_backend_get_keymap (backend); struct xkb_keymap *keymap = meta_backend_get_keymap (backend);
struct xkb_state *scratch_state; struct xkb_state *scratch_state;
xkb_mod_mask_t scroll_lock_mask; xkb_mod_mask_t scroll_lock_mask;
xkb_mod_mask_t dummy_mask;
/* Modifiers to find. */ /* Modifiers to find. */
struct { struct {
const char *name; const char *name;
xkb_mod_mask_t *mask_p; xkb_mod_mask_t *mask_p;
xkb_mod_mask_t *virtual_mask_p;
} mods[] = { } mods[] = {
{ "ScrollLock", &scroll_lock_mask }, { "ScrollLock", &scroll_lock_mask, &dummy_mask },
{ "Meta", &keys->meta_mask }, { "Meta", &keys->meta_mask, &keys->virtual_meta_mask },
{ "Hyper", &keys->hyper_mask }, { "Hyper", &keys->hyper_mask, &keys->virtual_hyper_mask },
{ "Super", &keys->super_mask }, { "Super", &keys->super_mask, &keys->virtual_super_mask },
}; };
scratch_state = xkb_state_new (keymap); scratch_state = xkb_state_new (keymap);
@ -203,6 +205,7 @@ reload_modmap (MetaKeyBindingManager *keys)
for (i = 0; i < G_N_ELEMENTS (mods); i++) for (i = 0; i < G_N_ELEMENTS (mods); i++)
{ {
xkb_mod_mask_t *mask_p = mods[i].mask_p; xkb_mod_mask_t *mask_p = mods[i].mask_p;
xkb_mod_mask_t *virtual_mask_p = mods[i].virtual_mask_p;
xkb_mod_index_t idx = xkb_keymap_mod_get_index (keymap, mods[i].name); xkb_mod_index_t idx = xkb_keymap_mod_get_index (keymap, mods[i].name);
if (idx != XKB_MOD_INVALID) if (idx != XKB_MOD_INVALID)
@ -210,9 +213,13 @@ reload_modmap (MetaKeyBindingManager *keys)
xkb_mod_mask_t vmodmask = (1 << idx); xkb_mod_mask_t vmodmask = (1 << idx);
xkb_state_update_mask (scratch_state, vmodmask, 0, 0, 0, 0, 0); xkb_state_update_mask (scratch_state, vmodmask, 0, 0, 0, 0, 0);
*mask_p = xkb_state_serialize_mods (scratch_state, XKB_STATE_MODS_DEPRESSED) & ~vmodmask; *mask_p = xkb_state_serialize_mods (scratch_state, XKB_STATE_MODS_DEPRESSED) & ~vmodmask;
*virtual_mask_p = vmodmask;
} }
else else
*mask_p = 0; {
*mask_p = 0;
*virtual_mask_p = 0;
}
} }
xkb_state_unref (scratch_state); xkb_state_unref (scratch_state);