Merge lp:~gustavold/ginn/ginn.gustavo into lp:ginn

Proposed by Gustavo Luiz Duarte
Status: Merged
Merged at revision: 32
Proposed branch: lp:~gustavold/ginn/ginn.gustavo
Merge into: lp:ginn
Diff against target: 103 lines (+25/-8)
2 files modified
src/ginn.c (+13/-7)
src/xt.c (+12/-1)
To merge this branch: bzr merge lp:~gustavold/ginn/ginn.gustavo
Reviewer Review Type Date Requested Status
Mohamed IKBEL Boulabiar (community) Approve
Stephen M. Webb Pending
Review via email: mp+38778@code.launchpad.net

This proposal supersedes a proposal from 2010-10-18.

Description of the change

It provides necessary code for injecting pointer clicks (e.g. for scrolling) and gesture matching based on the gesture state (update vs finish).

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote : Posted in a previous version of this proposal

Hmm, mid-air collision!

Could you please bzr pull and resolve conflicts, then resubmit?

review: Needs Fixing
Revision history for this message
Gustavo Luiz Duarte (gustavold) wrote : Posted in a previous version of this proposal

Sorry for that. Conflicts resolved. Please let me know if you have any other consideration.

Revision history for this message
Mohamed IKBEL Boulabiar (boulabiar) wrote : Posted in a previous version of this proposal

Thanks Gustavo !
Sorry for the collision, can you just resubmit the xt.c file changes ?

review: Needs Fixing
Revision history for this message
Mohamed IKBEL Boulabiar (boulabiar) wrote :

Approved, but needs future fixes

review: Approve
lp:~gustavold/ginn/ginn.gustavo updated
32. By Mohamed IKBEL Boulabiar

Merge code from Gustavo to support modifiers in injected keystrokes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ginn.c'
2--- src/ginn.c 2010-10-18 20:50:21 +0000
3+++ src/ginn.c 2010-10-18 22:06:01 +0000
4@@ -30,6 +30,10 @@
5 #include <X11/Xlib.h>
6 #include <X11/keysym.h>
7
8+#define GINN_START 0
9+#define GINN_UPDATE 1
10+#define GINN_FINISH 2
11+
12 att config_attr[25] = { [0 ... 24] = {.attrName="", .val=0, .valMax=0 } };
13
14 static int
15@@ -41,7 +45,8 @@
16 gesture_match( GeisGestureType gesture_type,
17 GeisGestureId gesture_id,
18 GeisSize attr_count,
19- GeisGestureAttr *attrs)
20+ GeisGestureAttr *attrs,
21+ int state)
22 {
23 int i = 0;
24 int valid=1;
25@@ -50,15 +55,15 @@
26 //Drag
27 case 0: if (gesture_type==config_attr[1].val) {
28 if (attrs[9].float_val > config_attr[2].val)
29- injTest(XStringToKeysym(config_attr[0].attrName));
30+ injTest(XStringToKeysym(config_attr[0].attrName), NULL);
31 }
32 break;
33 //Pinch/Zoom
34 case 1: if (gesture_type==config_attr[1].val) {
35 /* if (attrs[9].float_val > config_attr[2].val)
36- injTest(XStringToKeysym(config_attr[0].attrName));
37+ injTest(XStringToKeysym(config_attr[0].attrName), NULL);
38 else if (attrs[9].float_val < -config_attr[2].val)
39- injTest(XK_KP_Subtract);
40+ injTest(XK_KP_Subtract, NULL);
41 */
42 int attrsI=9, cAttrI=3;
43 do {
44@@ -71,13 +76,13 @@
45 } else attrsI++;
46 } while ( (0!=strcmp(config_attr[cAttrI+1].attrName,"")) && attrsI<18 && valid );
47 if (valid)
48- injTest(XStringToKeysym(config_attr[0].attrName));
49+ injTest(XStringToKeysym(config_attr[0].attrName), NULL);
50 }
51 break;
52 //Rotate
53 case 2: if (gesture_type==config_attr[1].val) {
54 if (attrs[9].float_val > config_attr[2].val)
55- injTest(XStringToKeysym(config_attr[0].attrName));
56+ injTest(XStringToKeysym(config_attr[0].attrName), NULL);
57 }
58 break;
59 //Tap
60@@ -184,7 +189,7 @@
61 fprintf(stdout, "Gesture type %d updated\n", gesture_type);
62 for (i = 0; i < attr_count; ++i)
63 print_attr(&attrs[i]);
64- gesture_match(gesture_type, gesture_id, attr_count, attrs);
65+ gesture_match(gesture_type, gesture_id, attr_count, attrs, GINN_UPDATE);
66 }
67
68 static void
69@@ -198,6 +203,7 @@
70 fprintf(stdout, "Gesture type %d finished\n", gesture_type);
71 for (i = 0; i < attr_count; ++i)
72 print_attr(&attrs[i]);
73+ gesture_match(gesture_type, gesture_id, attr_count, attrs, GINN_FINISH);
74 }
75
76
77
78=== modified file 'src/xt.c'
79--- src/xt.c 2010-10-08 12:12:10 +0000
80+++ src/xt.c 2010-10-18 22:06:01 +0000
81@@ -22,11 +22,22 @@
82 #include <X11/keysym.h>
83
84 void
85-injTest(KeySym ks)
86+injTest(KeySym ks, KeySym modifier)
87 {
88 Display* disp = XOpenDisplay(NULL);
89+ if (modifier != NULL) XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, modifier), True, CurrentTime);
90 XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, ks), True, CurrentTime);
91 XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, ks), False, CurrentTime);
92+ if (modifier != NULL) XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, modifier), False, CurrentTime);
93+ XCloseDisplay(disp);
94+}
95+
96+void
97+injButton(int btn, KeySym modifier)
98+{
99+ Display* disp = XOpenDisplay(NULL);
100+ XTestFakeButtonEvent(disp, btn, True, CurrentTime);
101+ XTestFakeButtonEvent(disp, btn, False, CurrentTime);
102 XCloseDisplay(disp);
103 }
104