Merge lp:~oif-team/libgrip/devtype_expose into lp:libgrip

Proposed by Jussi Pakkanen
Status: Rejected
Rejected by: Chase Douglas
Proposed branch: lp:~oif-team/libgrip/devtype_expose
Merge into: lp:libgrip
Diff against target: 141 lines (+43/-10)
2 files modified
src/gripgesturemanager.c (+39/-10)
src/gripgesturemanager.h (+4/-0)
To merge this branch: bzr merge lp:~oif-team/libgrip/devtype_expose
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Review via email: mp+68802@code.launchpad.net

Description of the change

This branch adds device type information to event structures. It is added at the end so that ABI is not broken. This makes things easier for app developers, as they don't have to have different callback functions for different device types.

The most common change between device types is that dragging is usually inverted when dragging with a touchpad.

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

I'm OK with this.

review: Approve
Revision history for this message
Chase Douglas (chasedouglas) wrote :

Unmerged revisions

53. By Jussi Pakkanen

Add device type at the ends of event structs.

52. By Jussi Pakkanen

Factore out device type detection.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gripgesturemanager.c'
2--- src/gripgesturemanager.c 2011-07-11 12:07:13 +0000
3+++ src/gripgesturemanager.c 2011-07-22 08:27:26 +0000
4@@ -148,26 +148,50 @@
5 gesture_finish
6 };
7
8-static void device_added (void *cookie, GeisInputDeviceId id, void *attrs)
9+static void get_device_flags(void *attrs, gboolean *direct, gboolean *independent)
10 {
11- GripDevices *devices = (GripDevices *) cookie;
12 GeisGestureAttr *a;
13- gboolean direct = FALSE;
14- gboolean independent = FALSE;
15-
16+
17+ *direct = FALSE;
18+ *independent = FALSE;
19 for (a = attrs; a->name; a++)
20 {
21 if (g_strcmp0(GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH, a->name) == 0)
22- direct = a->boolean_val;
23+ *direct = a->boolean_val;
24 else if (g_strcmp0(GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH, a->name) == 0)
25- independent = a->boolean_val;
26+ *independent = a->boolean_val;
27 }
28+}
29+
30+static GripDeviceType determine_device_type (void *attrs)
31+{
32+ gboolean direct = FALSE;
33+ gboolean independent = FALSE;
34+
35+ get_device_flags(attrs, &direct, &independent);
36
37 if (direct && !independent)
38+ return GRIP_DEVICE_TOUCHSCREEN;
39+ else if (!direct && !independent)
40+ return GRIP_DEVICE_TOUCHPAD;
41+ else if (!direct && independent)
42+ return GRIP_DEVICE_INDEPENDENT;
43+
44+ g_critical("Unknown touch device type.");
45+ return GRIP_DEVICE_TOUCHSCREEN;
46+}
47+
48+
49+static void device_added (void *cookie, GeisInputDeviceId id, void *attrs)
50+{
51+ GripDevices *devices = (GripDevices *) cookie;
52+ GripDeviceType type = determine_device_type(attrs);
53+
54+ if (type == GRIP_DEVICE_TOUCHSCREEN)
55 g_array_append_val (devices->touchscreen, id);
56- else if (!direct && !independent)
57+ if (type == GRIP_DEVICE_TOUCHPAD)
58 g_array_append_val (devices->touchpad, id);
59- else if (!direct && independent)
60+ if (type == GRIP_DEVICE_INDEPENDENT)
61 g_array_append_val (devices->independent, id);
62 }
63
64@@ -610,7 +634,8 @@
65
66 if (binding->type == type)
67 {
68- GripGestureEvent *event = grip_gesture_event_new (type);
69+ GripGestureEvent *event = grip_gesture_event_new (type);
70+ GripDeviceType device_type = determine_device_type(attrs);
71
72 if (type == GRIP_GESTURE_DRAG)
73 {
74@@ -621,6 +646,7 @@
75 drag->fingers = drag_gesture_handle_properties (drag,
76 attr_count,
77 attrs);
78+ drag->device_type = device_type;
79
80 if (drag->fingers == binding->touches)
81 {
82@@ -645,6 +671,7 @@
83 pinch->fingers = pinch_gesture_handle_properties (pinch,
84 attr_count,
85 attrs);
86+ pinch->device_type = device_type;
87
88 if (pinch->fingers == binding->touches)
89 {
90@@ -669,6 +696,7 @@
91 rotate->fingers = rotate_gesture_handle_properties (rotate,
92 attr_count,
93 attrs);
94+ rotate->device_type = device_type;
95
96 if (rotate->fingers == binding->touches)
97 {
98@@ -693,6 +721,7 @@
99 tap->fingers = tap_gesture_handle_properties (tap,
100 attr_count,
101 attrs);
102+ tap->device_type = device_type;
103
104 if (tap->fingers == binding->touches)
105 {
106
107=== modified file 'src/gripgesturemanager.h'
108--- src/gripgesturemanager.h 2011-06-20 13:06:17 +0000
109+++ src/gripgesturemanager.h 2011-07-22 08:27:26 +0000
110@@ -92,6 +92,7 @@
111 gdouble velocity_y;
112 gdouble position_x;
113 gdouble position_y;
114+ GripDeviceType device_type;
115 };
116
117 struct _GripEventGesturePinch
118@@ -110,6 +111,7 @@
119 gdouble radius;
120 gfloat position_x;
121 gfloat position_y;
122+ GripDeviceType device_type;
123 };
124
125 struct _GripEventGestureRotate
126@@ -128,6 +130,7 @@
127 gdouble angle;
128 gfloat position_x;
129 gfloat position_y;
130+ GripDeviceType device_type;
131 };
132
133 struct _GripEventGestureTap
134@@ -145,6 +148,7 @@
135 gfloat focus_y;
136 gfloat position_x;
137 gfloat position_y;
138+ GripDeviceType device_type;
139 };
140
141 union _GripGestureEvent

Subscribers

People subscribed via source and target branches

to all changes: