[gdk] Add gdk_keymap_get_num_lock_state

https://bugzilla.gnome.org/show_bug.cgi?id=623239
This commit is contained in:
William Jon McCann 2010-07-01 18:45:06 -04:00
parent 319d2bb4f1
commit 0cfb94cdd4
6 changed files with 67 additions and 4 deletions

View File

@ -1758,6 +1758,24 @@ gdk_keymap_get_caps_lock_state (GdkKeymap *keymap)
return FALSE;
}
/**
* gdk_keymap_get_num_lock_state:
* @keymap: a #GdkKeymap
*
* Returns whether the Num Lock modifer is locked.
*
* Returns: %TRUE if Num Lock is on
*
* Since: 3.0
*/
gboolean
gdk_keymap_get_num_lock_state (GdkKeymap *keymap)
{
/* FIXME: Can we implement this? */
return FALSE;
}
/**
* gdk_keymap_get_entries_for_keycode:
* @keymap: a #GdkKeymap or %NULL to use the default keymap

View File

@ -861,6 +861,7 @@ gdk_keymap_get_entries_for_keyval
gdk_keymap_get_for_display
gdk_keymap_have_bidi_layouts
gdk_keymap_get_caps_lock_state
gdk_keymap_get_num_lock_state
gdk_keymap_lookup_key
gdk_keymap_translate_keyboard_state
gdk_keymap_add_virtual_modifiers
@ -878,6 +879,7 @@ gdk_keymap_get_entries_for_keycode
gdk_keymap_get_entries_for_keyval
gdk_keymap_get_for_display
gdk_keymap_get_caps_lock_state
gdk_keymap_get_num_lock_state
gdk_keymap_lookup_key
gdk_keymap_translate_keyboard_state
gdk_keymap_add_virtual_modifiers

View File

@ -108,6 +108,7 @@ gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap);
gboolean gdk_keymap_get_num_lock_state (GdkKeymap *keymap);
void gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state);
gboolean gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,

View File

@ -451,6 +451,13 @@ gdk_keymap_get_caps_lock_state (GdkKeymap *keymap)
return FALSE;
}
gboolean
gdk_keymap_get_num_lock_state (GdkKeymap *keymap)
{
/* FIXME: Implement this. */
return FALSE;
}
gboolean
gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,

View File

@ -536,6 +536,12 @@ gdk_keymap_get_caps_lock_state (GdkKeymap *keymap)
return ((GetKeyState (VK_CAPITAL) & 1) != 0);
}
gboolean
gdk_keymap_get_num_lock_state (GdkKeymap *keymap)
{
return ((GetKeyState (VK_NUMLOCK) & 1) != 0);
}
gboolean
gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,

View File

@ -86,6 +86,7 @@ struct _GdkKeymapX11
guint sun_keypad : 1;
guint have_direction : 1;
guint caps_lock_state : 1;
guint num_lock_state : 1;
guint current_serial;
#ifdef HAVE_XKB
@ -276,6 +277,9 @@ get_xkb (GdkKeymapX11 *keymap_x11)
keymap_x11->current_serial = display_x11->keymap_serial;
if (keymap_x11->num_lock_mask == 0)
keymap_x11->num_lock_mask = XkbKeysymToModifiers (KEYMAP_XDISPLAY (GDK_KEYMAP (keymap_x11)), XK_Num_Lock);
return keymap_x11->xkb_desc;
}
#endif /* HAVE_XKB */
@ -687,12 +691,16 @@ update_lock_state (GdkKeymapX11 *keymap_x11,
gint locked_mods)
{
gboolean caps_lock_state;
gboolean num_lock_state;
caps_lock_state = keymap_x11->caps_lock_state;
num_lock_state = keymap_x11->num_lock_state;
keymap_x11->caps_lock_state = (locked_mods & GDK_LOCK_MASK) != 0;
return caps_lock_state != keymap_x11->caps_lock_state;
keymap_x11->num_lock_state = (locked_mods & keymap_x11->num_lock_mask) != 0;
return (caps_lock_state != keymap_x11->caps_lock_state)
|| (num_lock_state != keymap_x11->num_lock_state);
}
/* keep this in sync with the XkbSelectEventDetails() call
@ -713,7 +721,7 @@ _gdk_keymap_state_changed (GdkDisplay *display,
g_signal_emit_by_name (keymap_x11, "direction-changed");
if (update_lock_state (keymap_x11, xkb_event->state.locked_mods))
g_signal_emit_by_name (keymap_x11, "state-changed");
g_signal_emit_by_name (keymap_x11, "state-changed");
}
}
@ -831,6 +839,27 @@ gdk_keymap_get_caps_lock_state (GdkKeymap *keymap)
return keymap_x11->caps_lock_state;
}
/**
* gdk_keymap_get_num_lock_state:
* @keymap: a #GdkKeymap
*
* Returns whether the Num Lock modifer is locked.
*
* Returns: %TRUE if Num Lock is on
*
* Since: 3.0
*/
gboolean
gdk_keymap_get_num_lock_state (GdkKeymap *keymap)
{
GdkKeymapX11 *keymap_x11;
keymap = GET_EFFECTIVE_KEYMAP (keymap);
keymap_x11 = GDK_KEYMAP_X11 (keymap);
return keymap_x11->num_lock_state;
}
/**
* gdk_keymap_get_entries_for_keyval: