Merge lp:~jpakkane/libgrip/input_type_expose into lp:libgrip

Proposed by Jussi Pakkanen
Status: Merged
Merged at revision: 56
Proposed branch: lp:~jpakkane/libgrip/input_type_expose
Merge into: lp:libgrip
Diff against target: 122 lines (+36/-31)
5 files modified
src/gripgesturemanager.c (+0/-16)
src/gripgesturemanager.h (+0/-13)
src/gripinputdevice.c (+14/-2)
src/gripinputdevice.h (+18/-0)
src/libgrip.ver (+4/-0)
To merge this branch: bzr merge lp:~jpakkane/libgrip/input_type_expose
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Review via email: mp+70829@code.launchpad.net

Description of the change

Expose input type detector function through API.

I moved it to gripinputdevice.c/h because it seemed like a more natural place.

I would have called the function grip_input_device_get_type but that one already exists and is used by the Glib object system (I think).

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

Exactly how I would have done it.

review: Approve

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-08-08 09:44:29 +0000
+++ src/gripgesturemanager.c 2011-08-09 08:39:29 +0000
@@ -419,22 +419,6 @@
419 return input_device;419 return input_device;
420}420}
421421
422static
423GripDeviceType
424grip_get_device_type (GripInputDevice *input_device) {
425 gboolean is_direct = grip_input_device_is_direct (input_device);
426 gboolean is_independent = grip_input_device_is_independent (input_device);
427 if (is_direct && !is_independent)
428 return GRIP_DEVICE_TOUCHSCREEN;
429 if (!is_direct && !is_independent)
430 return GRIP_DEVICE_TOUCHPAD;
431 if (!is_direct && is_independent)
432 return GRIP_DEVICE_INDEPENDENT;
433
434 g_critical("Unknown touch device type.");
435 return GRIP_DEVICE_TOUCHSCREEN;
436}
437
438/*422/*
439 * registration_for_input_device:423 * registration_for_input_device:
440 * @registrations: A collection of #GripGestureRegistration424 * @registrations: A collection of #GripGestureRegistration
441425
=== modified file 'src/gripgesturemanager.h'
--- src/gripgesturemanager.h 2011-08-03 22:18:13 +0000
+++ src/gripgesturemanager.h 2011-08-09 08:39:29 +0000
@@ -123,19 +123,6 @@
123 GRIP_GESTURE_TAP = 15123 GRIP_GESTURE_TAP = 15
124} GripGestureType;124} GripGestureType;
125125
126/**
127 * GripDeviceType:
128 * @GRIP_DEVICE_TOUCHSCREEN: device is a touchscreen.
129 * @GRIP_DEVICE_TOUCHPAD: device is a touchpad
130 * @GRIP_DEVICE_INDEPENDENT: device is a Magic Mouse
131 *
132 * Describes certain properties of a gesture input device.
133 */
134typedef enum {
135 GRIP_DEVICE_TOUCHSCREEN = 1,
136 GRIP_DEVICE_TOUCHPAD = 2,
137 GRIP_DEVICE_INDEPENDENT = 4,
138} GripDeviceType;
139126
140#define GRIP_DEVICE_ALL (GRIP_DEVICE_TOUCHSCREEN | GRIP_DEVICE_TOUCHPAD | GRIP_DEVICE_INDEPENDENT)127#define GRIP_DEVICE_ALL (GRIP_DEVICE_TOUCHSCREEN | GRIP_DEVICE_TOUCHPAD | GRIP_DEVICE_INDEPENDENT)
141128
142129
=== modified file 'src/gripinputdevice.c'
--- src/gripinputdevice.c 2011-08-04 00:39:00 +0000
+++ src/gripinputdevice.c 2011-08-09 08:39:29 +0000
@@ -322,5 +322,17 @@
322 G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));322 G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
323}323}
324324
325325GripDeviceType
326326grip_get_device_type (GripInputDevice *input_device) {
327 gboolean is_direct = grip_input_device_is_direct (input_device);
328 gboolean is_independent = grip_input_device_is_independent (input_device);
329 if (is_direct && !is_independent)
330 return GRIP_DEVICE_TOUCHSCREEN;
331 if (!is_direct && !is_independent)
332 return GRIP_DEVICE_TOUCHPAD;
333 if (!is_direct && is_independent)
334 return GRIP_DEVICE_INDEPENDENT;
335
336 g_critical("Unknown touch device type.");
337 return GRIP_DEVICE_TOUCHSCREEN;
338}
327339
=== modified file 'src/gripinputdevice.h'
--- src/gripinputdevice.h 2011-08-04 00:39:00 +0000
+++ src/gripinputdevice.h 2011-08-09 08:39:29 +0000
@@ -27,6 +27,20 @@
27G_BEGIN_DECLS27G_BEGIN_DECLS
2828
29/**29/**
30 * GripDeviceType:
31 * @GRIP_DEVICE_TOUCHSCREEN: device is a touchscreen.
32 * @GRIP_DEVICE_TOUCHPAD: device is a touchpad
33 * @GRIP_DEVICE_INDEPENDENT: device is a Magic Mouse
34 *
35 * Describes certain properties of a gesture input device.
36 */
37typedef enum {
38 GRIP_DEVICE_TOUCHSCREEN = 1,
39 GRIP_DEVICE_TOUCHPAD = 2,
40 GRIP_DEVICE_INDEPENDENT = 4,
41} GripDeviceType;
42
43/**
30 * SECTION:GripInputDevice44 * SECTION:GripInputDevice
31 *45 *
32 * The Grip input device represents input devices known to the uTouch gesture46 * The Grip input device represents input devices known to the uTouch gesture
@@ -99,6 +113,10 @@
99AxisExtents *113AxisExtents *
100grip_input_device_get_y_extents(GripInputDevice *input_device);114grip_input_device_get_y_extents(GripInputDevice *input_device);
101115
116
117GripDeviceType
118grip_get_device_type (GripInputDevice *input_device);
119
102G_END_DECLS120G_END_DECLS
103121
104#endif /* GRIP_INPUT_DEVICE_H_ */122#endif /* GRIP_INPUT_DEVICE_H_ */
105123
=== modified file 'src/libgrip.ver'
--- src/libgrip.ver 2011-08-04 00:39:00 +0000
+++ src/libgrip.ver 2011-08-09 08:39:29 +0000
@@ -53,3 +53,7 @@
53 grip_input_device_is_independent;53 grip_input_device_is_independent;
54} GRIP_0.1;54} GRIP_0.1;
5555
56GRIP_0.3 {
57 global:
58 grip_get_device_type;
59} GRIP_0.2.2;

Subscribers

People subscribed via source and target branches