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
=== modified file 'src/gripgesturemanager.c'
--- src/gripgesturemanager.c 2011-07-11 12:07:13 +0000
+++ src/gripgesturemanager.c 2011-07-22 08:27:26 +0000
@@ -148,26 +148,50 @@
148 gesture_finish148 gesture_finish
149};149};
150150
151static void device_added (void *cookie, GeisInputDeviceId id, void *attrs)151static void get_device_flags(void *attrs, gboolean *direct, gboolean *independent)
152{152{
153 GripDevices *devices = (GripDevices *) cookie;
154 GeisGestureAttr *a;153 GeisGestureAttr *a;
155 gboolean direct = FALSE;154
156 gboolean independent = FALSE;155 *direct = FALSE;
157 156 *independent = FALSE;
158 for (a = attrs; a->name; a++)157 for (a = attrs; a->name; a++)
159 {158 {
160 if (g_strcmp0(GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH, a->name) == 0)159 if (g_strcmp0(GEIS_DEVICE_ATTRIBUTE_DIRECT_TOUCH, a->name) == 0)
161 direct = a->boolean_val;160 *direct = a->boolean_val;
162 else if (g_strcmp0(GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH, a->name) == 0)161 else if (g_strcmp0(GEIS_DEVICE_ATTRIBUTE_INDEPENDENT_TOUCH, a->name) == 0)
163 independent = a->boolean_val;162 *independent = a->boolean_val;
164 }163 }
164}
165
166static GripDeviceType determine_device_type (void *attrs)
167{
168 gboolean direct = FALSE;
169 gboolean independent = FALSE;
170
171 get_device_flags(attrs, &direct, &independent);
165172
166 if (direct && !independent)173 if (direct && !independent)
174 return GRIP_DEVICE_TOUCHSCREEN;
175 else if (!direct && !independent)
176 return GRIP_DEVICE_TOUCHPAD;
177 else if (!direct && independent)
178 return GRIP_DEVICE_INDEPENDENT;
179
180 g_critical("Unknown touch device type.");
181 return GRIP_DEVICE_TOUCHSCREEN;
182}
183
184
185static void device_added (void *cookie, GeisInputDeviceId id, void *attrs)
186{
187 GripDevices *devices = (GripDevices *) cookie;
188 GripDeviceType type = determine_device_type(attrs);
189
190 if (type == GRIP_DEVICE_TOUCHSCREEN)
167 g_array_append_val (devices->touchscreen, id);191 g_array_append_val (devices->touchscreen, id);
168 else if (!direct && !independent)192 if (type == GRIP_DEVICE_TOUCHPAD)
169 g_array_append_val (devices->touchpad, id);193 g_array_append_val (devices->touchpad, id);
170 else if (!direct && independent)194 if (type == GRIP_DEVICE_INDEPENDENT)
171 g_array_append_val (devices->independent, id);195 g_array_append_val (devices->independent, id);
172}196}
173197
@@ -610,7 +634,8 @@
610634
611 if (binding->type == type)635 if (binding->type == type)
612 {636 {
613 GripGestureEvent *event = grip_gesture_event_new (type);637 GripGestureEvent *event = grip_gesture_event_new (type);
638 GripDeviceType device_type = determine_device_type(attrs);
614639
615 if (type == GRIP_GESTURE_DRAG)640 if (type == GRIP_GESTURE_DRAG)
616 {641 {
@@ -621,6 +646,7 @@
621 drag->fingers = drag_gesture_handle_properties (drag,646 drag->fingers = drag_gesture_handle_properties (drag,
622 attr_count,647 attr_count,
623 attrs);648 attrs);
649 drag->device_type = device_type;
624650
625 if (drag->fingers == binding->touches)651 if (drag->fingers == binding->touches)
626 {652 {
@@ -645,6 +671,7 @@
645 pinch->fingers = pinch_gesture_handle_properties (pinch,671 pinch->fingers = pinch_gesture_handle_properties (pinch,
646 attr_count,672 attr_count,
647 attrs);673 attrs);
674 pinch->device_type = device_type;
648675
649 if (pinch->fingers == binding->touches)676 if (pinch->fingers == binding->touches)
650 {677 {
@@ -669,6 +696,7 @@
669 rotate->fingers = rotate_gesture_handle_properties (rotate,696 rotate->fingers = rotate_gesture_handle_properties (rotate,
670 attr_count,697 attr_count,
671 attrs);698 attrs);
699 rotate->device_type = device_type;
672700
673 if (rotate->fingers == binding->touches)701 if (rotate->fingers == binding->touches)
674 {702 {
@@ -693,6 +721,7 @@
693 tap->fingers = tap_gesture_handle_properties (tap,721 tap->fingers = tap_gesture_handle_properties (tap,
694 attr_count,722 attr_count,
695 attrs);723 attrs);
724 tap->device_type = device_type;
696725
697 if (tap->fingers == binding->touches)726 if (tap->fingers == binding->touches)
698 {727 {
699728
=== modified file 'src/gripgesturemanager.h'
--- src/gripgesturemanager.h 2011-06-20 13:06:17 +0000
+++ src/gripgesturemanager.h 2011-07-22 08:27:26 +0000
@@ -92,6 +92,7 @@
92 gdouble velocity_y;92 gdouble velocity_y;
93 gdouble position_x;93 gdouble position_x;
94 gdouble position_y;94 gdouble position_y;
95 GripDeviceType device_type;
95};96};
9697
97struct _GripEventGesturePinch98struct _GripEventGesturePinch
@@ -110,6 +111,7 @@
110 gdouble radius;111 gdouble radius;
111 gfloat position_x;112 gfloat position_x;
112 gfloat position_y;113 gfloat position_y;
114 GripDeviceType device_type;
113};115};
114116
115struct _GripEventGestureRotate117struct _GripEventGestureRotate
@@ -128,6 +130,7 @@
128 gdouble angle;130 gdouble angle;
129 gfloat position_x;131 gfloat position_x;
130 gfloat position_y;132 gfloat position_y;
133 GripDeviceType device_type;
131};134};
132135
133struct _GripEventGestureTap136struct _GripEventGestureTap
@@ -145,6 +148,7 @@
145 gfloat focus_y;148 gfloat focus_y;
146 gfloat position_x;149 gfloat position_x;
147 gfloat position_y;150 gfloat position_y;
151 GripDeviceType device_type;
148};152};
149153
150union _GripGestureEvent154union _GripGestureEvent

Subscribers

People subscribed via source and target branches

to all changes: