diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index dffb376e7..47ca604a5 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -859,6 +859,9 @@ gdk_display_x11_finalize (GObject *object) _gdk_x11_cursor_display_finalize (GDK_DISPLAY_OBJECT(display_x11)); _gdk_x11_scroll_finalize (GDK_DISPLAY_OBJECT(display_x11)); + /* Empty the translate/antiexpose queue */ + _gdk_x11_display_free_translate_queue (GDK_DISPLAY_OBJECT (display_x11)); + /* Atom Hashtable */ g_hash_table_destroy (display_x11->atom_from_virtual); g_hash_table_destroy (display_x11->atom_to_virtual); diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c index ab8cf4b3b..c68a80fa6 100644 --- a/gdk/x11/gdkgeometry-x11.c +++ b/gdk/x11/gdkgeometry-x11.c @@ -159,6 +159,19 @@ queue_item_free (GdkWindowQueueItem *item) g_free (item); } +void +_gdk_x11_display_free_translate_queue (GdkDisplay *display) +{ + GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display); + + if (display_x11->translate_queue) + { + g_queue_foreach (display_x11->translate_queue, (GFunc) queue_item_free, NULL); + g_queue_free (display_x11->translate_queue); + display_x11->translate_queue = NULL; + } +} + static void gdk_window_queue (GdkWindow *window, GdkWindowQueueItem *item) diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c index 9e377a035..9a270e5de 100644 --- a/gdk/x11/gdkkeys-x11.c +++ b/gdk/x11/gdkkeys-x11.c @@ -86,6 +86,7 @@ struct _GdkKeymapX11 PangoDirection current_direction; guint sun_keypad : 1; guint have_direction : 1; + guint have_lock_state : 1; guint caps_lock_state : 1; guint current_serial; @@ -166,6 +167,7 @@ gdk_keymap_x11_init (GdkKeymapX11 *keymap) keymap->group_switch_mask = 0; keymap->lock_keysym = GDK_Caps_Lock; keymap->have_direction = FALSE; + keymap->have_lock_state = FALSE; keymap->current_serial = 0; #ifdef HAVE_XKB @@ -704,13 +706,17 @@ static gboolean update_lock_state (GdkKeymapX11 *keymap_x11, gint locked_mods) { + gboolean have_lock_state; gboolean caps_lock_state; + have_lock_state = keymap_x11->have_lock_state; caps_lock_state = keymap_x11->caps_lock_state; + keymap_x11->have_lock_state = TRUE; keymap_x11->caps_lock_state = (locked_mods & GDK_LOCK_MASK) != 0; - return caps_lock_state != keymap_x11->caps_lock_state; + return !have_lock_state + || caps_lock_state != keymap_x11->caps_lock_state; } /* keep this in sync with the XkbSelectEventDetails() call @@ -852,6 +858,19 @@ gdk_keymap_get_caps_lock_state (GdkKeymap *keymap) keymap_x11 = GDK_KEYMAP_X11 (keymap); +#ifdef HAVE_XKB + /* The lock state is otherwise only tracked from XkbStateNotify + * events, so query it explicitly the first time. + */ + if (KEYMAP_USE_XKB (keymap) && !keymap_x11->have_lock_state) + { + XkbStateRec state_rec; + + XkbGetState (KEYMAP_XDISPLAY (keymap), XkbUseCoreKbd, &state_rec); + update_lock_state (keymap_x11, state_rec.locked_mods); + } +#endif /* HAVE_XKB */ + return keymap_x11->caps_lock_state; } diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index d268e7dfc..a9b30a570 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -144,6 +144,7 @@ void _gdk_x11_window_set_root_origin (GdkWindow *window, gint y); gboolean _gdk_x11_window_queue_antiexpose (GdkWindow *window, GdkRegion *area); +void _gdk_x11_display_free_translate_queue (GdkDisplay *display); void _gdk_x11_window_queue_translation (GdkWindow *window, GdkGC *gc, GdkRegion *area,