Bug 107000 – Add signals to GdkKeymap for monitoring caps_lock, etc.
2008-09-29 Matthias Clasen <mclasen@redhat.com> Bug 107000 – Add signals to GdkKeymap for monitoring caps_lock, etc. * gdk/gdk.symbols: * gdk/gdkkeys.[ch]: Add a new GdkKeymap::state-changed signal, and a gdk_keymap_get_caps_lock_state function. * gdk/x11/gdkkeys-x11.c: Implement it here. For now, only emit state-changed when caps lock lockedness changes. * gdk/x11/gdkdisplay-x11.c: Also select for modifier lock status changes in the XkbSelectEventDetails call. svn path=/trunk/; revision=21545
This commit is contained in:

committed by
Matthias Clasen

parent
978e780018
commit
859aaf903d
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
2008-09-29 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Bug 107000 – Add signals to GdkKeymap for monitoring caps_lock, etc.
|
||||||
|
|
||||||
|
* gdk/gdk.symbols:
|
||||||
|
* gdk/gdkkeys.[ch]: Add a new GdkKeymap::state-changed signal, and
|
||||||
|
a gdk_keymap_get_caps_lock_state function.
|
||||||
|
|
||||||
|
* gdk/x11/gdkkeys-x11.c: Implement it here. For now, only emit
|
||||||
|
state-changed when caps lock lockedness changes.
|
||||||
|
|
||||||
|
* gdk/x11/gdkdisplay-x11.c: Also select for modifier lock status
|
||||||
|
changes in the XkbSelectEventDetails call.
|
||||||
|
|
||||||
2008-09-29 Kristian Rietveld <kris@imendio.com>
|
2008-09-29 Kristian Rietveld <kris@imendio.com>
|
||||||
|
|
||||||
Bug 487624 - Tooltips doesn't get updated if ther's no mouse motion
|
Bug 487624 - Tooltips doesn't get updated if ther's no mouse motion
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2008-09-29 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gdk/gdk-sections.txt: Add gdk_keymap_get_caps_locks_state.
|
||||||
|
|
||||||
2008-09-17 Matthias Clasen <mclasen@redhat.com>
|
2008-09-17 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* === Released 2.14.2 ===
|
* === Released 2.14.2 ===
|
||||||
|
@ -992,6 +992,7 @@ gdk_keymap_get_entries_for_keyval
|
|||||||
gdk_keymap_get_entries_for_keycode
|
gdk_keymap_get_entries_for_keycode
|
||||||
gdk_keymap_get_direction
|
gdk_keymap_get_direction
|
||||||
gdk_keymap_have_bidi_layouts
|
gdk_keymap_have_bidi_layouts
|
||||||
|
gdk_keymap_get_caps_lock_state
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
gdk_keyval_name
|
gdk_keyval_name
|
||||||
|
@ -829,6 +829,7 @@ gdk_keymap_get_entries_for_keycode
|
|||||||
gdk_keymap_get_entries_for_keyval
|
gdk_keymap_get_entries_for_keyval
|
||||||
gdk_keymap_get_for_display
|
gdk_keymap_get_for_display
|
||||||
gdk_keymap_have_bidi_layouts
|
gdk_keymap_have_bidi_layouts
|
||||||
|
gdk_keymap_get_caps_lock_state
|
||||||
gdk_keymap_lookup_key
|
gdk_keymap_lookup_key
|
||||||
gdk_keymap_translate_keyboard_state
|
gdk_keymap_translate_keyboard_state
|
||||||
gdk_keyval_convert_case
|
gdk_keyval_convert_case
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
enum {
|
enum {
|
||||||
DIRECTION_CHANGED,
|
DIRECTION_CHANGED,
|
||||||
KEYS_CHANGED,
|
KEYS_CHANGED,
|
||||||
|
STATE_CHANGED,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,6 +82,26 @@ gdk_keymap_class_init (GdkKeymapClass *klass)
|
|||||||
g_cclosure_marshal_VOID__VOID,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE,
|
G_TYPE_NONE,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GdkKeymap::state-changed:
|
||||||
|
* @keymap: the object on which the signal is emitted
|
||||||
|
*
|
||||||
|
* The ::state-changed signal is emitted when the state of the
|
||||||
|
* keyboard changes, e.g when the Caps Lock is turned on or off.
|
||||||
|
* See gdk_keyboard_get_caps_lock_state().
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
|
*/
|
||||||
|
signals[STATE_CHANGED] =
|
||||||
|
g_signal_new ("state_changed",
|
||||||
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (GdkKeymapClass, state_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -75,6 +75,7 @@ struct _GdkKeymapClass
|
|||||||
|
|
||||||
void (*direction_changed) (GdkKeymap *keymap);
|
void (*direction_changed) (GdkKeymap *keymap);
|
||||||
void (*keys_changed) (GdkKeymap *keymap);
|
void (*keys_changed) (GdkKeymap *keymap);
|
||||||
|
void (*state_changed) (GdkKeymap *keymap);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gdk_keymap_get_type (void) G_GNUC_CONST;
|
GType gdk_keymap_get_type (void) G_GNUC_CONST;
|
||||||
@ -106,6 +107,7 @@ gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
|
|||||||
gint *n_entries);
|
gint *n_entries);
|
||||||
PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
|
PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
|
||||||
gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
|
gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
|
||||||
|
gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap);
|
||||||
|
|
||||||
/* Key values
|
/* Key values
|
||||||
*/
|
*/
|
||||||
|
@ -356,7 +356,7 @@ gdk_display_open (const gchar *display_name)
|
|||||||
XkbSelectEventDetails (display_x11->xdisplay,
|
XkbSelectEventDetails (display_x11->xdisplay,
|
||||||
XkbUseCoreKbd, XkbStateNotify,
|
XkbUseCoreKbd, XkbStateNotify,
|
||||||
XkbAllStateComponentsMask,
|
XkbAllStateComponentsMask,
|
||||||
XkbGroupLockMask);
|
XkbGroupLockMask|XkbModifierLockMask);
|
||||||
|
|
||||||
XkbSetDetectableAutoRepeat (display_x11->xdisplay,
|
XkbSetDetectableAutoRepeat (display_x11->xdisplay,
|
||||||
True,
|
True,
|
||||||
|
@ -82,9 +82,10 @@ struct _GdkKeymapX11
|
|||||||
GdkModifierType group_switch_mask;
|
GdkModifierType group_switch_mask;
|
||||||
GdkModifierType num_lock_mask;
|
GdkModifierType num_lock_mask;
|
||||||
GdkModifierType modmap[8];
|
GdkModifierType modmap[8];
|
||||||
gboolean sun_keypad;
|
|
||||||
PangoDirection current_direction;
|
PangoDirection current_direction;
|
||||||
gboolean have_direction;
|
guint sun_keypad : 1;
|
||||||
|
guint have_direction : 1;
|
||||||
|
guint caps_lock_state : 1;
|
||||||
guint current_serial;
|
guint current_serial;
|
||||||
|
|
||||||
#ifdef HAVE_XKB
|
#ifdef HAVE_XKB
|
||||||
@ -656,12 +657,17 @@ get_num_groups (GdkKeymap *keymap,
|
|||||||
return xkb->ctrls->num_groups;
|
return xkb->ctrls->num_groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
update_direction (GdkKeymapX11 *keymap_x11,
|
update_direction (GdkKeymapX11 *keymap_x11,
|
||||||
gint group)
|
gint group)
|
||||||
{
|
{
|
||||||
XkbDescPtr xkb = get_xkb (keymap_x11);
|
XkbDescPtr xkb = get_xkb (keymap_x11);
|
||||||
Atom group_atom;
|
Atom group_atom;
|
||||||
|
gboolean had_direction;
|
||||||
|
PangoDirection old_direction;
|
||||||
|
|
||||||
|
had_direction = keymap_x11->have_direction;
|
||||||
|
old_direction = keymap_x11->current_direction;
|
||||||
|
|
||||||
group_atom = xkb->names->groups[group];
|
group_atom = xkb->names->groups[group];
|
||||||
|
|
||||||
@ -672,6 +678,21 @@ update_direction (GdkKeymapX11 *keymap_x11,
|
|||||||
keymap_x11->current_group_atom = group_atom;
|
keymap_x11->current_group_atom = group_atom;
|
||||||
keymap_x11->have_direction = TRUE;
|
keymap_x11->have_direction = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return !had_direction || old_direction != keymap_x11->current_direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
update_lock_state (GdkKeymapX11 *keymap_x11,
|
||||||
|
gint locked_mods)
|
||||||
|
{
|
||||||
|
gboolean caps_lock_state;
|
||||||
|
|
||||||
|
caps_lock_state = keymap_x11->caps_lock_state;
|
||||||
|
|
||||||
|
keymap_x11->caps_lock_state = (locked_mods & GDK_LOCK_MASK) != 0;
|
||||||
|
|
||||||
|
return caps_lock_state != keymap_x11->caps_lock_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* keep this in sync with the XkbSelectEventDetails() call
|
/* keep this in sync with the XkbSelectEventDetails() call
|
||||||
@ -684,19 +705,16 @@ _gdk_keymap_state_changed (GdkDisplay *display,
|
|||||||
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
|
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
|
||||||
XkbEvent *xkb_event = (XkbEvent *)xevent;
|
XkbEvent *xkb_event = (XkbEvent *)xevent;
|
||||||
|
|
||||||
|
g_print ("keymap state changed\n");
|
||||||
if (display_x11->keymap)
|
if (display_x11->keymap)
|
||||||
{
|
{
|
||||||
GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (display_x11->keymap);
|
GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (display_x11->keymap);
|
||||||
gboolean had_direction;
|
|
||||||
PangoDirection direction;
|
|
||||||
|
|
||||||
had_direction = keymap_x11->have_direction;
|
if (update_direction (keymap_x11, XkbStateGroup (&xkb_event->state)))
|
||||||
direction = keymap_x11->current_direction;
|
g_signal_emit_by_name (keymap_x11, "direction-changed");
|
||||||
|
|
||||||
update_direction (keymap_x11, XkbStateGroup (&xkb_event->state));
|
if (update_lock_state (keymap_x11, xkb_event->state.locked_mods))
|
||||||
|
g_signal_emit_by_name (keymap_x11, "state-changed");
|
||||||
if (!had_direction || direction != keymap_x11->current_direction)
|
|
||||||
g_signal_emit_by_name (keymap_x11, "direction_changed");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -792,6 +810,29 @@ gdk_keymap_have_bidi_layouts (GdkKeymap *keymap)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_keymap_get_caps_lock_state:
|
||||||
|
* @keymap: a #GdkKeymap
|
||||||
|
*
|
||||||
|
* Returns wether the Caps Lock modifer is locked.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if Caps Lock is on
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gdk_keymap_get_caps_lock_state (GdkKeymap *keymap)
|
||||||
|
{
|
||||||
|
GdkKeymapX11 *keymap_x11;
|
||||||
|
|
||||||
|
keymap = GET_EFFECTIVE_KEYMAP (keymap);
|
||||||
|
|
||||||
|
keymap_x11 = GDK_KEYMAP_X11 (keymap);
|
||||||
|
|
||||||
|
return keymap_x11->caps_lock_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_keymap_get_entries_for_keyval:
|
* gdk_keymap_get_entries_for_keyval:
|
||||||
* @keymap: a #GdkKeymap, or %NULL to use the default keymap
|
* @keymap: a #GdkKeymap, or %NULL to use the default keymap
|
||||||
|
Reference in New Issue
Block a user