+2005-09-20 Matthias Clasen <mclasen@redhat.com>
+
+ Avoid unnecessary XkbGetState() calls and XkbStateNotify
+ events. (#151555, Søren Sandmann)
+
+ * gdk/x11/gdkdisplay-x11.c (gdk_display_open): Use
+ XkbSelectEventDetails() to select XkbStateNotify events
+ for only the state we care about.
+
+ * gdk/x11/gdkprivate-x11.h:
+ * gdk/x11/gdkkeys-x11.c (_gdk_keymap_state_changed): Pass
+ the event into the function and update the keymap state from
+ the state information contained in the event. Adjust all callers.
+
2005-09-19 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c: Use g_list_nth_data() instead of g_list_nth()->data
+2005-09-20 Matthias Clasen <mclasen@redhat.com>
+
+ Avoid unnecessary XkbGetState() calls and XkbStateNotify
+ events. (#151555, Søren Sandmann)
+
+ * gdk/x11/gdkdisplay-x11.c (gdk_display_open): Use
+ XkbSelectEventDetails() to select XkbStateNotify events
+ for only the state we care about.
+
+ * gdk/x11/gdkprivate-x11.h:
+ * gdk/x11/gdkkeys-x11.c (_gdk_keymap_state_changed): Pass
+ the event into the function and update the keymap state from
+ the state information contained in the event. Adjust all callers.
+
2005-09-19 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c: Use g_list_nth_data() instead of g_list_nth()->data
XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);
+ /* keep this in sync with _gdk_keymap_state_changed() */
+ XkbSelectEventDetails (display_x11->xdisplay,
+ XkbUseCoreKbd, XkbStateNotify,
+ XkbGroupLockMask, XkbGroupLockMask);
+
XkbSetDetectableAutoRepeat (display_x11->xdisplay,
True,
&detectable_autorepeat_supported);
}
static void
-update_direction (GdkKeymapX11 *keymap_x11)
+update_direction (GdkKeymapX11 *keymap_x11,
+ gint group)
{
XkbDescRec *xkb = get_xkb (keymap_x11);
- XkbStateRec state_rec;
- GdkDisplay *display = GDK_KEYMAP (keymap_x11)->display;
- gint group;
Atom group_atom;
- XkbGetState (GDK_DISPLAY_XDISPLAY (display), XkbUseCoreKbd, &state_rec);
- group = XkbGroupLock (&state_rec);
group_atom = xkb->names->groups[group];
/* a group change? */
}
}
-static void
-_gdk_keymap_direction_changed (GdkKeymapX11 *keymap_x11)
-{
- gboolean had_direction;
- PangoDirection direction;
-
- had_direction = keymap_x11->have_direction;
- direction = keymap_x11->current_direction;
-
- update_direction (keymap_x11);
-
- if (!had_direction || direction != keymap_x11->current_direction)
- g_signal_emit_by_name (keymap_x11, "direction_changed");
-}
-
-
+/* keep this in sync with the XkbSelectEventDetails() call
+ * in gdk_display_open()
+ */
void
-_gdk_keymap_state_changed (GdkDisplay *display)
+_gdk_keymap_state_changed (GdkDisplay *display,
+ XEvent *xevent)
{
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
+ XkbEvent *xkb_event = (XkbEvent *)xevent;
if (display_x11->keymap)
{
GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (display_x11->keymap);
+ gboolean had_direction;
+ PangoDirection direction;
+
+ had_direction = keymap_x11->have_direction;
+ direction = keymap_x11->current_direction;
- _gdk_keymap_direction_changed (keymap_x11);
+ update_direction (keymap_x11, xkb_event->state.locked_group);
+
+ if (!had_direction || direction != keymap_x11->current_direction)
+ g_signal_emit_by_name (keymap_x11, "direction_changed");
}
}
if (KEYMAP_USE_XKB (keymap))
{
GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (keymap);
-
+
if (!keymap_x11->have_direction)
- update_direction (keymap_x11);
+ {
+ GdkDisplay *display = GDK_KEYMAP (keymap_x11)->display;
+ XkbStateRec state_rec;
+
+ XkbGetState (GDK_DISPLAY_XDISPLAY (display), XkbUseCoreKbd,
+ &state_rec);
+ update_direction (keymap_x11, XkbGroupLock (&state_rec));
+ }
return keymap_x11->current_direction;
}