[caribou] libcaribou: simplify using xtst.vapi provided by vala



commit 0a643fd9e6e87d5e74da7cc00bb0c63ee79d1330
Author: Daiki Ueno <ueno unixuser org>
Date:   Sat Oct 6 19:42:06 2012 +0900

    libcaribou: simplify using xtst.vapi provided by vala
    
    XTest.send_fake_key event and X.keysym_to_keycode are now
    available in vapi files in vala distribution.  Also fix some
    compiler warnings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685607

 libcaribou/Makefile.am        |    2 +-
 libcaribou/external-libs.vapi |   15 ---------------
 libcaribou/xadapter.vala      |   11 +++++++----
 3 files changed, 8 insertions(+), 20 deletions(-)
---
diff --git a/libcaribou/Makefile.am b/libcaribou/Makefile.am
index f41af5a..d7053e1 100644
--- a/libcaribou/Makefile.am
+++ b/libcaribou/Makefile.am
@@ -9,7 +9,7 @@ libcaribou_la_VALAFLAGS = \
 	-H caribou.h --vapi caribou-1.0.vapi \
 	-h caribou-internals.h \
 	--vapidir=. \
-	--pkg x11 --pkg gdk-3.0 --pkg gio-2.0 --pkg gee-1.0 \
+	--pkg x11 --pkg xtst --pkg gdk-3.0 --pkg gio-2.0 --pkg gee-1.0 \
 	--pkg libxklavier --pkg external-libs --pkg gdk-x11-3.0 --pkg libxml-2.0 \
 	--internal-vapi caribou-internals-1.0.vapi \
 	--library caribou-1.0 --gir _Caribou-1.0.gir \
diff --git a/libcaribou/external-libs.vapi b/libcaribou/external-libs.vapi
index 4a41020..e2c73db 100644
--- a/libcaribou/external-libs.vapi
+++ b/libcaribou/external-libs.vapi
@@ -1,20 +1,5 @@
 using X;
 
-[CCode (cprefix = "", lower_case_cprefix = "",
-        cheader_filename = "X11/extensions/XTest.h")]
-namespace XTest {
-    [CCode (cname = "XTestFakeKeyEvent")]
-    public int fake_key_event (Display dpy, uchar keycode, bool key_press,
-                               ulong delay);
-}
-
-[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "X11/Xlib.h")]
-namespace X {
-    [CCode (cname = "XKeycodeToKeysym")]
-    public int keycode_to_keysym (Display dpy, uchar keycode, int index);
-
-}
-
 [CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "X11/XKBlib.h")]
 namespace Xkb {
 
diff --git a/libcaribou/xadapter.vala b/libcaribou/xadapter.vala
index 4d5c7c1..fba9df9 100644
--- a/libcaribou/xadapter.vala
+++ b/libcaribou/xadapter.vala
@@ -25,7 +25,7 @@ namespace Caribou {
         public delegate void KeyButtonCallback (uint keybuttoncode, bool pressed);
 
         private class KeyButtonHandler {
-            public KeyButtonCallback cb { get; private set; }
+            public unowned KeyButtonCallback cb { get; private set; }
             public KeyButtonHandler (KeyButtonCallback cb) {
                 this.cb = cb;
             }
@@ -128,7 +128,7 @@ namespace Caribou {
 
             for (i = xkbdesc.max_key_code; i >= xkbdesc.min_key_code; --i) {
                 if (xkbdesc.map.key_sym_map[i].kt_index[0] == Xkb.OneLevelIndex) {
-                    if (X.keycode_to_keysym (this.xdisplay, i, 0) != 0) {
+                    if (this.xdisplay.keycode_to_keysym (i, 0) != 0) {
                         Gdk.error_trap_push ();
                         this.xdisplay.grab_key (i, 0,
                                     Gdk.x11_get_default_root_xwindow (), true,
@@ -148,8 +148,8 @@ namespace Caribou {
         private void replace_keycode (uint keysym) {
             if (this.reserved_keycode == 0) {
                 this.reserved_keycode = get_reserved_keycode ();
-                this.reserved_keysym = X.keycode_to_keysym (this.xdisplay,
-                                                            this.reserved_keycode, 0);
+                this.reserved_keysym = (uint) this.xdisplay.keycode_to_keysym (
+                    this.reserved_keycode, 0);
             }
 
             this.xdisplay.flush ();
@@ -181,6 +181,9 @@ namespace Caribou {
             Gdk.Keymap kmap= Gdk.Keymap.get_default ();
             Gdk.KeymapKey[] kmk;
 
+            keycode = 0;
+            modmask = 0;
+
             if (!kmap.get_entries_for_keyval (keyval, out kmk))
                 return false;
 



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