*** empty log message ***

This commit is contained in:
Matthias Clasen 2005-09-20 05:28:34 +00:00
parent 9b64ff7f38
commit cd63ed1eb4
6 changed files with 62 additions and 28 deletions

View File

@ -1,3 +1,17 @@
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> 2005-09-19 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c: Use g_list_nth_data() instead of g_list_nth()->data * gtk/gtkiconview.c: Use g_list_nth_data() instead of g_list_nth()->data

View File

@ -1,3 +1,17 @@
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> 2005-09-19 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkiconview.c: Use g_list_nth_data() instead of g_list_nth()->data * gtk/gtkiconview.c: Use g_list_nth_data() instead of g_list_nth()->data

View File

@ -281,6 +281,11 @@ gdk_display_open (const gchar *display_name)
XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask, XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
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, XkbSetDetectableAutoRepeat (display_x11->xdisplay,
True, True,
&detectable_autorepeat_supported); &detectable_autorepeat_supported);

View File

@ -2050,7 +2050,7 @@ gdk_event_translate (GdkDisplay *display,
break; break;
case XkbStateNotify: case XkbStateNotify:
_gdk_keymap_state_changed (display); _gdk_keymap_state_changed (display, xevent);
break; break;
} }
} }

View File

@ -536,16 +536,12 @@ get_direction (XkbDescRec *xkb,
} }
static void static void
update_direction (GdkKeymapX11 *keymap_x11) update_direction (GdkKeymapX11 *keymap_x11,
gint group)
{ {
XkbDescRec *xkb = get_xkb (keymap_x11); XkbDescRec *xkb = get_xkb (keymap_x11);
XkbStateRec state_rec;
GdkDisplay *display = GDK_KEYMAP (keymap_x11)->display;
gint group;
Atom group_atom; Atom group_atom;
XkbGetState (GDK_DISPLAY_XDISPLAY (display), XkbUseCoreKbd, &state_rec);
group = XkbGroupLock (&state_rec);
group_atom = xkb->names->groups[group]; group_atom = xkb->names->groups[group];
/* a group change? */ /* a group change? */
@ -609,33 +605,30 @@ update_direction (GdkKeymapX11 *keymap_x11)
} }
} }
static void /* keep this in sync with the XkbSelectEventDetails() call
_gdk_keymap_direction_changed (GdkKeymapX11 *keymap_x11) * in gdk_display_open()
*/
void
_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; gboolean had_direction;
PangoDirection direction; PangoDirection direction;
had_direction = keymap_x11->have_direction; had_direction = keymap_x11->have_direction;
direction = keymap_x11->current_direction; direction = keymap_x11->current_direction;
update_direction (keymap_x11); update_direction (keymap_x11, xkb_event->state.locked_group);
if (!had_direction || direction != keymap_x11->current_direction) if (!had_direction || direction != keymap_x11->current_direction)
g_signal_emit_by_name (keymap_x11, "direction_changed"); g_signal_emit_by_name (keymap_x11, "direction_changed");
} }
void
_gdk_keymap_state_changed (GdkDisplay *display)
{
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
if (display_x11->keymap)
{
GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (display_x11->keymap);
_gdk_keymap_direction_changed (keymap_x11);
}
} }
#endif /* HAVE_XKB */ #endif /* HAVE_XKB */
@ -662,7 +655,14 @@ gdk_keymap_get_direction (GdkKeymap *keymap)
GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (keymap); GdkKeymapX11 *keymap_x11 = GDK_KEYMAP_X11 (keymap);
if (!keymap_x11->have_direction) 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; return keymap_x11->current_direction;
} }

View File

@ -139,7 +139,8 @@ gboolean _gdk_moveresize_handle_event (XEvent *event);
gboolean _gdk_moveresize_configure_done (GdkDisplay *display, gboolean _gdk_moveresize_configure_done (GdkDisplay *display,
GdkWindow *window); GdkWindow *window);
void _gdk_keymap_state_changed (GdkDisplay *display); void _gdk_keymap_state_changed (GdkDisplay *display,
XEvent *event);
void _gdk_keymap_keys_changed (GdkDisplay *display); void _gdk_keymap_keys_changed (GdkDisplay *display);
gint _gdk_x11_get_group_for_state (GdkDisplay *display, gint _gdk_x11_get_group_for_state (GdkDisplay *display,
GdkModifierType state); GdkModifierType state);