[caribou: 14/23] Use gdk_x11_display_get_user_time() instead of gtk_get_current_event_time()



commit 1e6448d0c33462cf668563922cd22ab6f3e826eb
Author: Dan Winship <danw gnome org>
Date:   Fri Aug 5 12:32:42 2011 -0400

    Use gdk_x11_display_get_user_time() instead of gtk_get_current_event_time()
    
    XFocusChangeEvents don't have timestamps, so
    gtk_get_current_event_time() will return 0 inside the
    has-toplevel-focus notification handler. So use the last user
    interaction time instead.

 modules/gtk2/Makefile.am             |    1 +
 modules/gtk3/Makefile.am             |    1 +
 modules/gtk3/caribou-gtk-module.vala |   10 +++++++++-
 3 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/modules/gtk2/Makefile.am b/modules/gtk2/Makefile.am
index 2580827..f59aabd 100644
--- a/modules/gtk2/Makefile.am
+++ b/modules/gtk2/Makefile.am
@@ -9,6 +9,7 @@ libcaribou_gtk_module_la_SOURCES = \
 libcaribou_gtk_module_la_VALAFLAGS = \
 	-h caribou-gtk-module.h \
 	--vapidir=. \
+	--pkg gdk-x11-2.0 \
 	--pkg gtk+-2.0 \
 	-D GTK2 \
 	$(VALAGLAFS)
diff --git a/modules/gtk3/Makefile.am b/modules/gtk3/Makefile.am
index c7a86f5..0f5aa1b 100644
--- a/modules/gtk3/Makefile.am
+++ b/modules/gtk3/Makefile.am
@@ -9,6 +9,7 @@ libcaribou_gtk_module_la_SOURCES = \
 libcaribou_gtk_module_la_VALAFLAGS = \
 	-h caribou-gtk-module.h \
 	--vapidir=. \
+	--pkg gdk-x11-3.0 \
 	--pkg gtk+-3.0 \
 	$(VALAGLAFS)
 
diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala
index 4441f97..bbbac05 100644
--- a/modules/gtk3/caribou-gtk-module.vala
+++ b/modules/gtk3/caribou-gtk-module.vala
@@ -12,10 +12,13 @@ namespace Caribou {
     class GtkModule {
         private GLib.HashTable<Gtk.Window, bool> windows;
         private Keyboard keyboard;
+        private Gdk.Display display;
 
         public GtkModule () {
             windows = new GLib.HashTable<Gtk.Window, bool> (null, null);
             try {
+                display = Gdk.Display.get_default ();
+
                 keyboard = Bus.get_proxy_sync (BusType.SESSION,
                                                "org.gnome.Caribou.Keyboard",
                                                "/org/gnome/Caribou/Keyboard");
@@ -58,7 +61,12 @@ namespace Caribou {
         }
 
         private void do_focus_change (Gtk.Widget? widget) {
-            uint32 timestamp = Gtk.get_current_event_time ();
+#if GTK2
+            uint32 timestamp = Gdk.x11_display_get_user_time (display);
+#else
+            uint32 timestamp = Gdk.X11Display.get_user_time (display);
+#endif
+
             if (widget != null && (widget is Gtk.Entry || widget is Gtk.TextView) && widget is Gtk.Editable) {
                 Gdk.Window current_window = widget.get_window ();
                 int x = 0, y = 0, w = 0, h = 0;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]