forked from AuroraMiddleware/gtk
wayland: Implement gdk_keymap_get_modifier_state
This commit is contained in:
parent
e47689d9ea
commit
6629e839d0
@ -903,22 +903,6 @@ keyboard_handle_leave (void *data,
|
||||
static gboolean
|
||||
keyboard_repeat (gpointer data);
|
||||
|
||||
static GdkModifierType
|
||||
get_modifier (struct xkb_state *state)
|
||||
{
|
||||
GdkModifierType modifiers = 0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, XKB_MOD_NAME_SHIFT, XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_SHIFT_MASK:0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, XKB_MOD_NAME_CAPS, XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_LOCK_MASK:0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, XKB_MOD_NAME_CTRL, XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_CONTROL_MASK:0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, XKB_MOD_NAME_ALT, XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_MOD1_MASK:0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, "Mod2", XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_MOD2_MASK:0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, "Mod3", XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_MOD3_MASK:0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, XKB_MOD_NAME_LOGO, XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_MOD4_MASK:0;
|
||||
modifiers |= (xkb_state_mod_name_is_active (state, "Mod5", XKB_STATE_MODS_EFFECTIVE) > 0)?GDK_MOD5_MASK:0;
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
static void
|
||||
translate_keyboard_string (GdkEventKey *event)
|
||||
{
|
||||
@ -1024,7 +1008,7 @@ deliver_key_event(GdkWaylandDeviceData *device,
|
||||
sym = xkb_state_key_get_one_sym (xkb_state, key);
|
||||
|
||||
device->time = time;
|
||||
device->modifiers = get_modifier (xkb_state);
|
||||
device->modifiers = gdk_keymap_get_modifier_state (keymap);
|
||||
|
||||
event = gdk_event_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
|
||||
event->key.window = device->keyboard_focus?g_object_ref (device->keyboard_focus):NULL;
|
||||
|
@ -333,6 +333,18 @@ gdk_wayland_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static guint
|
||||
gdk_wayland_keymap_get_modifier_state (GdkKeymap *keymap)
|
||||
{
|
||||
struct xkb_keymap *xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
|
||||
struct xkb_state *xkb_state = GDK_WAYLAND_KEYMAP (keymap)->xkb_state;
|
||||
xkb_mod_mask_t mods;
|
||||
|
||||
mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
|
||||
|
||||
return get_gdk_modifiers (xkb_keymap, mods);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *state)
|
||||
@ -363,6 +375,7 @@ _gdk_wayland_keymap_class_init (GdkWaylandKeymapClass *klass)
|
||||
keymap_class->get_entries_for_keycode = gdk_wayland_keymap_get_entries_for_keycode;
|
||||
keymap_class->lookup_key = gdk_wayland_keymap_lookup_key;
|
||||
keymap_class->translate_keyboard_state = gdk_wayland_keymap_translate_keyboard_state;
|
||||
keymap_class->get_modifier_state = gdk_wayland_keymap_get_modifier_state;
|
||||
keymap_class->add_virtual_modifiers = gdk_wayland_keymap_add_virtual_modifiers;
|
||||
keymap_class->map_virtual_modifiers = gdk_wayland_keymap_map_virtual_modifiers;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user