diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 8ef5d402aa..defd136f4b 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -668,6 +668,7 @@ gdk_keymap_get_direction gdk_keymap_have_bidi_layouts gdk_keymap_get_caps_lock_state gdk_keymap_get_num_lock_state +gdk_keymap_get_scroll_lock_state gdk_keymap_get_modifier_state gdk_keymap_add_virtual_modifiers gdk_keymap_map_virtual_modifiers diff --git a/gdk/broadway/gdkkeys-broadway.c b/gdk/broadway/gdkkeys-broadway.c index c52d1bbb59..47a16a54d1 100644 --- a/gdk/broadway/gdkkeys-broadway.c +++ b/gdk/broadway/gdkkeys-broadway.c @@ -115,6 +115,12 @@ gdk_broadway_keymap_get_num_lock_state (GdkKeymap *keymap) return FALSE; } +static gboolean +gdk_broadway_keymap_get_scroll_lock_state (GdkKeymap *keymap) +{ + return FALSE; +} + static gboolean gdk_broadway_keymap_get_entries_for_keyval (GdkKeymap *keymap, guint keyval, @@ -206,6 +212,7 @@ gdk_broadway_keymap_class_init (GdkBroadwayKeymapClass *klass) keymap_class->have_bidi_layouts = gdk_broadway_keymap_have_bidi_layouts; keymap_class->get_caps_lock_state = gdk_broadway_keymap_get_caps_lock_state; keymap_class->get_num_lock_state = gdk_broadway_keymap_get_num_lock_state; + keymap_class->get_scroll_lock_state = gdk_broadway_keymap_get_scroll_lock_state; keymap_class->get_entries_for_keyval = gdk_broadway_keymap_get_entries_for_keyval; keymap_class->get_entries_for_keycode = gdk_broadway_keymap_get_entries_for_keycode; keymap_class->lookup_key = gdk_broadway_keymap_lookup_key; diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c index 63303dce84..c651205f7a 100644 --- a/gdk/gdkkeys.c +++ b/gdk/gdkkeys.c @@ -357,6 +357,24 @@ gdk_keymap_get_num_lock_state (GdkKeymap *keymap) return GDK_KEYMAP_GET_CLASS (keymap)->get_num_lock_state (keymap); } +/** + * gdk_keymap_get_scroll_lock_state: + * @keymap: a #GdkKeymap + * + * Returns whether the Scroll Lock modifer is locked. + * + * Returns: %TRUE if Scroll Lock is on + * + * Since: 3.18 + */ +gboolean +gdk_keymap_get_scroll_lock_state (GdkKeymap *keymap) +{ + g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE); + + return GDK_KEYMAP_GET_CLASS (keymap)->get_scroll_lock_state (keymap); +} + /** * gdk_keymap_get_modifier_state: * @keymap: a #GdkKeymap diff --git a/gdk/gdkkeys.h b/gdk/gdkkeys.h index 9749467a90..329ce1e882 100644 --- a/gdk/gdkkeys.h +++ b/gdk/gdkkeys.h @@ -117,6 +117,8 @@ GDK_AVAILABLE_IN_ALL gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap); GDK_AVAILABLE_IN_ALL gboolean gdk_keymap_get_num_lock_state (GdkKeymap *keymap); +GDK_AVAILABLE_IN_3_18 +gboolean gdk_keymap_get_scroll_lock_state (GdkKeymap *keymap); GDK_AVAILABLE_IN_3_4 guint gdk_keymap_get_modifier_state (GdkKeymap *keymap); GDK_AVAILABLE_IN_ALL diff --git a/gdk/gdkkeysprivate.h b/gdk/gdkkeysprivate.h index f1c8c1627a..96f67b1519 100644 --- a/gdk/gdkkeysprivate.h +++ b/gdk/gdkkeysprivate.h @@ -36,6 +36,7 @@ struct _GdkKeymapClass gboolean (* have_bidi_layouts) (GdkKeymap *keymap); gboolean (* get_caps_lock_state) (GdkKeymap *keymap); gboolean (* get_num_lock_state) (GdkKeymap *keymap); + gboolean (* get_scroll_lock_state) (GdkKeymap *keymap); gboolean (* get_entries_for_keyval) (GdkKeymap *keymap, guint keyval, GdkKeymapKey **keys, diff --git a/gdk/mir/gdkmirkeymap.c b/gdk/mir/gdkmirkeymap.c index 82f0d2cf79..88901240e2 100644 --- a/gdk/mir/gdkmirkeymap.c +++ b/gdk/mir/gdkmirkeymap.c @@ -98,6 +98,13 @@ gdk_mir_keymap_get_num_lock_state (GdkKeymap *keymap) return xkb_state_led_name_is_active (GDK_MIR_KEYMAP (keymap)->xkb_state, XKB_LED_NAME_NUM); } +static gboolean +gdk_mir_keymap_get_scroll_lock_state (GdkKeymap *keymap) +{ + //g_printerr ("gdk_mir_keymap_get_scroll_lock_state\n"); + return xkb_state_led_name_is_active (GDK_MIR_KEYMAP (keymap)->xkb_state, XKB_LED_NAME_SCROLL); +} + static gboolean gdk_mir_keymap_get_entries_for_keyval (GdkKeymap *keymap, guint keyval, @@ -470,6 +477,7 @@ gdk_mir_keymap_class_init (GdkMirKeymapClass *klass) keymap_class->have_bidi_layouts = gdk_mir_keymap_have_bidi_layouts; keymap_class->get_caps_lock_state = gdk_mir_keymap_get_caps_lock_state; keymap_class->get_num_lock_state = gdk_mir_keymap_get_num_lock_state; + keymap_class->get_scroll_lock_state = gdk_mir_keymap_get_scroll_lock_state; keymap_class->get_entries_for_keyval = gdk_mir_keymap_get_entries_for_keyval; keymap_class->get_entries_for_keycode = gdk_mir_keymap_get_entries_for_keycode; keymap_class->lookup_key = gdk_mir_keymap_lookup_key; diff --git a/gdk/quartz/gdkkeys-quartz.c b/gdk/quartz/gdkkeys-quartz.c index d2b51105a1..b2a52ed9f0 100644 --- a/gdk/quartz/gdkkeys-quartz.c +++ b/gdk/quartz/gdkkeys-quartz.c @@ -523,6 +523,13 @@ gdk_quartz_keymap_get_num_lock_state (GdkKeymap *keymap) return FALSE; } +static gboolean +gdk_quartz_keymap_get_scroll_lock_state (GdkKeymap *keymap) +{ + /* FIXME: Implement this. */ + return FALSE; +} + static gboolean gdk_quartz_keymap_get_entries_for_keyval (GdkKeymap *keymap, guint keyval, @@ -864,6 +871,7 @@ gdk_quartz_keymap_class_init (GdkQuartzKeymapClass *klass) keymap_class->have_bidi_layouts = gdk_quartz_keymap_have_bidi_layouts; keymap_class->get_caps_lock_state = gdk_quartz_keymap_get_caps_lock_state; keymap_class->get_num_lock_state = gdk_quartz_keymap_get_num_lock_state; + keymap_class->get_scroll_lock_state = gdk_quartz_keymap_get_scroll_lock_state; keymap_class->get_entries_for_keyval = gdk_quartz_keymap_get_entries_for_keyval; keymap_class->get_entries_for_keycode = gdk_quartz_keymap_get_entries_for_keycode; keymap_class->lookup_key = gdk_quartz_keymap_lookup_key; diff --git a/gdk/wayland/gdkkeys-wayland.c b/gdk/wayland/gdkkeys-wayland.c index 814ef34276..a0cc1f6144 100644 --- a/gdk/wayland/gdkkeys-wayland.c +++ b/gdk/wayland/gdkkeys-wayland.c @@ -117,6 +117,13 @@ gdk_wayland_keymap_get_num_lock_state (GdkKeymap *keymap) XKB_LED_NAME_NUM); } +static gboolean +gdk_wayland_keymap_get_scroll_lock_state (GdkKeymap *keymap) +{ + return xkb_state_led_name_is_active (GDK_WAYLAND_KEYMAP (keymap)->xkb_state, + XKB_LED_NAME_SCROLL); +} + static gboolean gdk_wayland_keymap_get_entries_for_keyval (GdkKeymap *keymap, guint keyval, @@ -373,6 +380,7 @@ _gdk_wayland_keymap_class_init (GdkWaylandKeymapClass *klass) keymap_class->have_bidi_layouts = gdk_wayland_keymap_have_bidi_layouts; keymap_class->get_caps_lock_state = gdk_wayland_keymap_get_caps_lock_state; keymap_class->get_num_lock_state = gdk_wayland_keymap_get_num_lock_state; + keymap_class->get_scroll_lock_state = gdk_wayland_keymap_get_scroll_lock_state; keymap_class->get_entries_for_keyval = gdk_wayland_keymap_get_entries_for_keyval; keymap_class->get_entries_for_keycode = gdk_wayland_keymap_get_entries_for_keycode; keymap_class->lookup_key = gdk_wayland_keymap_lookup_key; diff --git a/gdk/win32/gdkkeys-win32.c b/gdk/win32/gdkkeys-win32.c index fe9c05c409..46c472e034 100644 --- a/gdk/win32/gdkkeys-win32.c +++ b/gdk/win32/gdkkeys-win32.c @@ -563,6 +563,12 @@ gdk_win32_keymap_get_num_lock_state (GdkKeymap *keymap) return ((GetKeyState (VK_NUMLOCK) & 1) != 0); } +static gboolean +gdk_win32_keymap_get_scroll_lock_state (GdkKeymap *keymap) +{ + return ((GetKeyState (VK_SCROLL) & 1) != 0); +} + static gboolean gdk_win32_keymap_get_entries_for_keyval (GdkKeymap *keymap, guint keyval, @@ -930,6 +936,7 @@ gdk_win32_keymap_class_init (GdkWin32KeymapClass *klass) keymap_class->have_bidi_layouts = gdk_win32_keymap_have_bidi_layouts; keymap_class->get_caps_lock_state = gdk_win32_keymap_get_caps_lock_state; keymap_class->get_num_lock_state = gdk_win32_keymap_get_num_lock_state; + keymap_class->get_scroll_lock_state = gdk_win32_keymap_get_scroll_lock_state; keymap_class->get_entries_for_keyval = gdk_win32_keymap_get_entries_for_keyval; keymap_class->get_entries_for_keycode = gdk_win32_keymap_get_entries_for_keycode; keymap_class->lookup_key = gdk_win32_keymap_lookup_key; diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c index 25df963f62..90284bd907 100644 --- a/gdk/x11/gdkkeys-x11.c +++ b/gdk/x11/gdkkeys-x11.c @@ -69,12 +69,14 @@ struct _GdkX11Keymap guint lock_keysym; GdkModifierType group_switch_mask; GdkModifierType num_lock_mask; + GdkModifierType scroll_lock_mask; GdkModifierType modmap[8]; PangoDirection current_direction; - guint have_direction : 1; - guint have_lock_state : 1; - guint caps_lock_state : 1; - guint num_lock_state : 1; + guint have_direction : 1; + guint have_lock_state : 1; + guint caps_lock_state : 1; + guint num_lock_state : 1; + guint scroll_lock_state : 1; guint modifier_state; guint current_serial; @@ -113,6 +115,7 @@ gdk_x11_keymap_init (GdkX11Keymap *keymap) keymap->mod_keymap = NULL; keymap->num_lock_mask = 0; + keymap->scroll_lock_mask = 0; keymap->group_switch_mask = 0; keymap->lock_keysym = GDK_KEY_Caps_Lock; keymap->have_direction = FALSE; @@ -231,6 +234,10 @@ get_xkb (GdkX11Keymap *keymap_x11) if (keymap_x11->num_lock_mask == 0) keymap_x11->num_lock_mask = XkbKeysymToModifiers (KEYMAP_XDISPLAY (GDK_KEYMAP (keymap_x11)), GDK_KEY_Num_Lock); + if (keymap_x11->scroll_lock_mask == 0) + keymap_x11->scroll_lock_mask = XkbKeysymToModifiers (KEYMAP_XDISPLAY (GDK_KEYMAP (keymap_x11)), GDK_KEY_Scroll_Lock); + + return keymap_x11->xkb_desc; } #endif /* HAVE_XKB */ @@ -353,6 +360,7 @@ update_keymaps (GdkX11Keymap *keymap_x11) keymap_x11->lock_keysym = GDK_KEY_VoidSymbol; keymap_x11->group_switch_mask = 0; keymap_x11->num_lock_mask = 0; + keymap_x11->scroll_lock_mask = 0; for (i = 0; i < 8; i++) keymap_x11->modmap[i] = 1 << i; @@ -426,7 +434,7 @@ update_keymaps (GdkX11Keymap *keymap_x11) break; default: - /* Find the Mode_Switch and Num_Lock modifiers. */ + /* Find the Mode_Switch, Num_Lock and Scroll_Lock modifiers. */ for (j = 0; j < keymap_x11->keysyms_per_keycode; j++) { if (syms[j] == GDK_KEY_Mode_switch) @@ -439,6 +447,11 @@ update_keymaps (GdkX11Keymap *keymap_x11) /* This modifier is used for Num_Lock */ keymap_x11->num_lock_mask |= mask; } + else if (syms[j] == GDK_KEY_Scroll_Lock) + { + /* This modifier is used for Scroll_Lock */ + keymap_x11->scroll_lock_mask |= mask; + } } break; } @@ -594,6 +607,7 @@ update_lock_state (GdkX11Keymap *keymap_x11, gboolean have_lock_state; gboolean caps_lock_state; gboolean num_lock_state; + gboolean scroll_lock_state; guint modifier_state; /* ensure keymap_x11->num_lock_mask is initialized */ @@ -602,17 +616,20 @@ update_lock_state (GdkX11Keymap *keymap_x11, have_lock_state = keymap_x11->have_lock_state; caps_lock_state = keymap_x11->caps_lock_state; num_lock_state = keymap_x11->num_lock_state; + scroll_lock_state = keymap_x11->scroll_lock_state; modifier_state = keymap_x11->modifier_state; keymap_x11->have_lock_state = TRUE; keymap_x11->caps_lock_state = (locked_mods & GDK_LOCK_MASK) != 0; keymap_x11->num_lock_state = (locked_mods & keymap_x11->num_lock_mask) != 0; + keymap_x11->scroll_lock_state = (locked_mods & keymap_x11->scroll_lock_mask) != 0; /* FIXME: sanitize this */ keymap_x11->modifier_state = (guint)effective_mods; return !have_lock_state || (caps_lock_state != keymap_x11->caps_lock_state) || (num_lock_state != keymap_x11->num_lock_state) + || (scroll_lock_state != keymap_x11->scroll_lock_state) || (modifier_state != keymap_x11->modifier_state); } @@ -747,6 +764,16 @@ gdk_x11_keymap_get_num_lock_state (GdkKeymap *keymap) return keymap_x11->num_lock_state; } +static gboolean +gdk_x11_keymap_get_scroll_lock_state (GdkKeymap *keymap) +{ + GdkX11Keymap *keymap_x11 = GDK_X11_KEYMAP (keymap); + + ensure_lock_state (keymap); + + return keymap_x11->scroll_lock_state; +} + static guint gdk_x11_keymap_get_modifier_state (GdkKeymap *keymap) { @@ -1556,6 +1583,7 @@ gdk_x11_keymap_class_init (GdkX11KeymapClass *klass) keymap_class->have_bidi_layouts = gdk_x11_keymap_have_bidi_layouts; keymap_class->get_caps_lock_state = gdk_x11_keymap_get_caps_lock_state; keymap_class->get_num_lock_state = gdk_x11_keymap_get_num_lock_state; + keymap_class->get_scroll_lock_state = gdk_x11_keymap_get_scroll_lock_state; keymap_class->get_modifier_state = gdk_x11_keymap_get_modifier_state; keymap_class->get_entries_for_keyval = gdk_x11_keymap_get_entries_for_keyval; keymap_class->get_entries_for_keycode = gdk_x11_keymap_get_entries_for_keycode;