File: | ctk/ctkgesturesingle.c |
Warning: | line 199, column 7 This statement is never executed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* CTK - The GIMP Toolkit |
2 | * Copyright (C) 2012, One Laptop Per Child. |
3 | * Copyright (C) 2014, Red Hat, Inc. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | * |
18 | * Author(s): Carlos Garnacho <carlosg@gnome.org> |
19 | */ |
20 | |
21 | /** |
22 | * SECTION:ctkgesturesingle |
23 | * @Short_description: Base class for mouse/single-touch gestures |
24 | * @Title: CtkGestureSingle |
25 | * |
26 | * #CtkGestureSingle is a subclass of #CtkGesture, optimized (although |
27 | * not restricted) for dealing with mouse and single-touch gestures. Under |
28 | * interaction, these gestures stick to the first interacting sequence, which |
29 | * is accessible through ctk_gesture_single_get_current_sequence() while the |
30 | * gesture is being interacted with. |
31 | * |
32 | * By default gestures react to both %CDK_BUTTON_PRIMARY and touch |
33 | * events, ctk_gesture_single_set_touch_only() can be used to change the |
34 | * touch behavior. Callers may also specify a different mouse button number |
35 | * to interact with through ctk_gesture_single_set_button(), or react to any |
36 | * mouse button by setting 0. While the gesture is active, the button being |
37 | * currently pressed can be known through ctk_gesture_single_get_current_button(). |
38 | */ |
39 | |
40 | #include "config.h" |
41 | #include "ctkgesturesingle.h" |
42 | #include "ctkgesturesingleprivate.h" |
43 | #include "ctkprivate.h" |
44 | #include "ctkintl.h" |
45 | #include "ctkdebug.h" |
46 | |
47 | typedef struct _CtkGestureSinglePrivate CtkGestureSinglePrivate; |
48 | |
49 | struct _CtkGestureSinglePrivate |
50 | { |
51 | CdkEventSequence *current_sequence; |
52 | guint button; |
53 | guint current_button; |
54 | guint touch_only : 1; |
55 | guint exclusive : 1; |
56 | }; |
57 | |
58 | enum { |
59 | PROP_TOUCH_ONLY = 1, |
60 | PROP_EXCLUSIVE, |
61 | PROP_BUTTON, |
62 | LAST_PROP |
63 | }; |
64 | |
65 | static GParamSpec *properties[LAST_PROP] = { NULL((void*)0), }; |
66 | |
67 | G_DEFINE_TYPE_WITH_PRIVATE (CtkGestureSingle, ctk_gesture_single, CTK_TYPE_GESTURE)static void ctk_gesture_single_init (CtkGestureSingle *self); static void ctk_gesture_single_class_init (CtkGestureSingleClass *klass); static GType ctk_gesture_single_get_type_once (void ); static gpointer ctk_gesture_single_parent_class = ((void*) 0); static gint CtkGestureSingle_private_offset; static void ctk_gesture_single_class_intern_init (gpointer klass) { ctk_gesture_single_parent_class = g_type_class_peek_parent (klass); if (CtkGestureSingle_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkGestureSingle_private_offset); ctk_gesture_single_class_init ((CtkGestureSingleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_gesture_single_get_instance_private (CtkGestureSingle *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CtkGestureSingle_private_offset)))); } GType ctk_gesture_single_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_gesture_single_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_gesture_single_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_gesture_get_type ()), g_intern_static_string ("CtkGestureSingle" ), sizeof (CtkGestureSingleClass), (GClassInitFunc)(void (*)( void)) ctk_gesture_single_class_intern_init, sizeof (CtkGestureSingle ), (GInstanceInitFunc)(void (*)(void)) ctk_gesture_single_init , (GTypeFlags) 0); { {{ CtkGestureSingle_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkGestureSinglePrivate)); };} } return g_define_type_id; } |
68 | |
69 | static void |
70 | ctk_gesture_single_get_property (GObject *object, |
71 | guint prop_id, |
72 | GValue *value, |
73 | GParamSpec *pspec) |
74 | { |
75 | CtkGestureSinglePrivate *priv; |
76 | |
77 | priv = ctk_gesture_single_get_instance_private (CTK_GESTURE_SINGLE (object)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((object)), ((ctk_gesture_single_get_type ()) )))))); |
78 | |
79 | switch (prop_id) |
80 | { |
81 | case PROP_TOUCH_ONLY: |
82 | g_value_set_boolean (value, priv->touch_only); |
83 | break; |
84 | case PROP_EXCLUSIVE: |
85 | g_value_set_boolean (value, priv->exclusive); |
86 | break; |
87 | case PROP_BUTTON: |
88 | g_value_set_uint (value, priv->button); |
89 | break; |
90 | default: |
91 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkgesturesingle.c", 91, ("property"), _glib__property_id, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
92 | } |
93 | } |
94 | |
95 | static void |
96 | ctk_gesture_single_set_property (GObject *object, |
97 | guint prop_id, |
98 | const GValue *value, |
99 | GParamSpec *pspec) |
100 | { |
101 | switch (prop_id) |
102 | { |
103 | case PROP_TOUCH_ONLY: |
104 | ctk_gesture_single_set_touch_only (CTK_GESTURE_SINGLE (object)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((object)), ((ctk_gesture_single_get_type ()) ))))), |
105 | g_value_get_boolean (value)); |
106 | break; |
107 | case PROP_EXCLUSIVE: |
108 | ctk_gesture_single_set_exclusive (CTK_GESTURE_SINGLE (object)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((object)), ((ctk_gesture_single_get_type ()) ))))), |
109 | g_value_get_boolean (value)); |
110 | break; |
111 | case PROP_BUTTON: |
112 | ctk_gesture_single_set_button (CTK_GESTURE_SINGLE (object)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((object)), ((ctk_gesture_single_get_type ()) ))))), |
113 | g_value_get_uint (value)); |
114 | break; |
115 | default: |
116 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkgesturesingle.c", 116, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
117 | } |
118 | } |
119 | |
120 | static void |
121 | ctk_gesture_single_cancel (CtkGesture *gesture, |
122 | CdkEventSequence *sequence) |
123 | { |
124 | CtkGestureSinglePrivate *priv; |
125 | |
126 | priv = ctk_gesture_single_get_instance_private (CTK_GESTURE_SINGLE (gesture)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((gesture)), ((ctk_gesture_single_get_type () ))))))); |
127 | |
128 | if (sequence == priv->current_sequence) |
129 | priv->current_button = 0; |
130 | } |
131 | |
132 | static gboolean |
133 | ctk_gesture_single_handle_event (CtkEventController *controller, |
134 | const CdkEvent *event) |
135 | { |
136 | CdkEventSequence *sequence = NULL((void*)0); |
137 | CtkGestureSinglePrivate *priv; |
138 | CdkDevice *source_device; |
139 | CdkInputSource source; |
140 | guint button = 0, i; |
141 | gboolean retval, test_touchscreen = FALSE(0); |
142 | |
143 | source_device = cdk_event_get_source_device (event); |
144 | |
145 | if (!source_device) |
146 | return FALSE(0); |
147 | |
148 | priv = ctk_gesture_single_get_instance_private (CTK_GESTURE_SINGLE (controller)((((CtkGestureSingle*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((controller)), ((ctk_gesture_single_get_type ()))))))); |
149 | source = cdk_device_get_source (source_device); |
150 | |
151 | if (source != CDK_SOURCE_TOUCHSCREEN) |
152 | test_touchscreen = ctk_simulate_touchscreen (); |
153 | |
154 | switch (event->type) |
155 | { |
156 | case CDK_TOUCH_BEGIN: |
157 | case CDK_TOUCH_END: |
158 | case CDK_TOUCH_UPDATE: |
159 | if (priv->exclusive && !event->touch.emulating_pointer) |
160 | return FALSE(0); |
161 | |
162 | sequence = event->touch.sequence; |
163 | button = 1; |
164 | break; |
165 | case CDK_BUTTON_PRESS: |
166 | case CDK_BUTTON_RELEASE: |
167 | if (priv->touch_only && !test_touchscreen && source != CDK_SOURCE_TOUCHSCREEN) |
168 | return FALSE(0); |
169 | |
170 | button = event->button.button; |
171 | break; |
172 | case CDK_MOTION_NOTIFY: |
173 | if (!ctk_gesture_handles_sequence (CTK_GESTURE (controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((controller)), ((ctk_gesture_get_type ())))))), sequence)) |
174 | return FALSE(0); |
175 | if (priv->touch_only && !test_touchscreen && source != CDK_SOURCE_TOUCHSCREEN) |
176 | return FALSE(0); |
177 | |
178 | if (priv->current_button > 0 && priv->current_button <= 5 && |
179 | (event->motion.state & (CDK_BUTTON1_MASK << (priv->current_button - 1)))) |
180 | button = priv->current_button; |
181 | else if (priv->current_button == 0) |
182 | { |
183 | /* No current button, find out from the mask */ |
184 | for (i = 0; i < 3; i++) |
185 | { |
186 | if ((event->motion.state & (CDK_BUTTON1_MASK << i)) == 0) |
187 | continue; |
188 | button = i + 1; |
189 | break; |
190 | } |
191 | } |
192 | |
193 | break; |
194 | case CDK_TOUCH_CANCEL: |
195 | case CDK_GRAB_BROKEN: |
196 | case CDK_TOUCHPAD_SWIPE: |
197 | return CTK_EVENT_CONTROLLER_CLASS (ctk_gesture_single_parent_class)((((CtkEventControllerClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((ctk_gesture_single_parent_class)), ((ctk_event_controller_get_type ()))))))->handle_event (controller, |
198 | event); |
199 | break; |
This statement is never executed | |
200 | default: |
201 | return FALSE(0); |
202 | } |
203 | |
204 | if (button == 0 || |
205 | (priv->button != 0 && priv->button != button) || |
206 | (priv->current_button != 0 && priv->current_button != button)) |
207 | { |
208 | if (ctk_gesture_is_active (CTK_GESTURE (controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((controller)), ((ctk_gesture_get_type ())))))))) |
209 | ctk_event_controller_reset (controller); |
210 | return FALSE(0); |
211 | } |
212 | |
213 | if (event->type == CDK_BUTTON_PRESS || event->type == CDK_TOUCH_BEGIN || |
214 | event->type == CDK_MOTION_NOTIFY || event->type == CDK_TOUCH_UPDATE) |
215 | { |
216 | if (!ctk_gesture_is_active (CTK_GESTURE (controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((controller)), ((ctk_gesture_get_type ())))))))) |
217 | priv->current_sequence = sequence; |
218 | |
219 | priv->current_button = button; |
220 | } |
221 | |
222 | retval = CTK_EVENT_CONTROLLER_CLASS (ctk_gesture_single_parent_class)((((CtkEventControllerClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((ctk_gesture_single_parent_class)), ((ctk_event_controller_get_type ()))))))->handle_event (controller, event); |
223 | |
224 | if (sequence == priv->current_sequence && |
225 | (event->type == CDK_BUTTON_RELEASE || event->type == CDK_TOUCH_END)) |
226 | priv->current_button = 0; |
227 | else if (priv->current_sequence == sequence && |
228 | !ctk_gesture_handles_sequence (CTK_GESTURE (controller)((((CtkGesture*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((controller)), ((ctk_gesture_get_type ())))))), sequence)) |
229 | { |
230 | if (button == priv->current_button && event->type == CDK_BUTTON_PRESS) |
231 | priv->current_button = 0; |
232 | else if (sequence == priv->current_sequence && event->type == CDK_TOUCH_BEGIN) |
233 | priv->current_sequence = NULL((void*)0); |
234 | } |
235 | |
236 | return retval; |
237 | } |
238 | |
239 | static void |
240 | ctk_gesture_single_class_init (CtkGestureSingleClass *klass) |
241 | { |
242 | CtkEventControllerClass *controller_class = CTK_EVENT_CONTROLLER_CLASS (klass)((((CtkEventControllerClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ctk_event_controller_get_type () )))))); |
243 | CtkGestureClass *gesture_class = CTK_GESTURE_CLASS (klass)((((CtkGestureClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_gesture_get_type ())))))); |
244 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
245 | |
246 | object_class->get_property = ctk_gesture_single_get_property; |
247 | object_class->set_property = ctk_gesture_single_set_property; |
248 | |
249 | controller_class->handle_event = ctk_gesture_single_handle_event; |
250 | |
251 | gesture_class->cancel = ctk_gesture_single_cancel; |
252 | |
253 | /** |
254 | * CtkGestureSingle:touch-only: |
255 | * |
256 | * Whether the gesture handles only touch events. |
257 | * |
258 | * Since: 3.14 |
259 | */ |
260 | properties[PROP_TOUCH_ONLY] = |
261 | g_param_spec_boolean ("touch-only", |
262 | P_("Handle only touch events")g_dgettext("ctk30" "-properties","Handle only touch events"), |
263 | P_("Whether the gesture handles only touch events")g_dgettext("ctk30" "-properties","Whether the gesture handles only touch events" ), |
264 | FALSE(0), |
265 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
266 | |
267 | /** |
268 | * CtkGestureSingle:exclusive: |
269 | * |
270 | * Whether the gesture is exclusive. Exclusive gestures only listen to pointer |
271 | * and pointer emulated events. |
272 | * |
273 | * Since: 3.14 |
274 | */ |
275 | properties[PROP_EXCLUSIVE] = |
276 | g_param_spec_boolean ("exclusive", |
277 | P_("Whether the gesture is exclusive")g_dgettext("ctk30" "-properties","Whether the gesture is exclusive" ), |
278 | P_("Whether the gesture is exclusive")g_dgettext("ctk30" "-properties","Whether the gesture is exclusive" ), |
279 | FALSE(0), |
280 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
281 | |
282 | /** |
283 | * CtkGestureSingle:button: |
284 | * |
285 | * Mouse button number to listen to, or 0 to listen for any button. |
286 | * |
287 | * Since: 3.14 |
288 | */ |
289 | properties[PROP_BUTTON] = |
290 | g_param_spec_uint ("button", |
291 | P_("Button number")g_dgettext("ctk30" "-properties","Button number"), |
292 | P_("Button number to listen to")g_dgettext("ctk30" "-properties","Button number to listen to" ), |
293 | 0, G_MAXUINT(2147483647 *2U +1U), |
294 | CDK_BUTTON_PRIMARY(1), |
295 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
296 | |
297 | g_object_class_install_properties (object_class, LAST_PROP, properties); |
298 | } |
299 | |
300 | static void |
301 | _ctk_gesture_single_update_evmask (CtkGestureSingle *gesture) |
302 | { |
303 | CtkGestureSinglePrivate *priv; |
304 | CdkEventMask evmask; |
305 | |
306 | priv = ctk_gesture_single_get_instance_private (gesture); |
307 | evmask = CDK_TOUCH_MASK; |
308 | |
309 | if (!priv->touch_only || ctk_simulate_touchscreen ()) |
310 | evmask |= CDK_BUTTON_PRESS_MASK | CDK_BUTTON_RELEASE_MASK | |
311 | CDK_BUTTON_MOTION_MASK; |
312 | |
313 | ctk_event_controller_set_event_mask (CTK_EVENT_CONTROLLER (gesture)((((CtkEventController*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((gesture)), ((ctk_event_controller_get_type ())))))), evmask); |
314 | } |
315 | |
316 | static void |
317 | ctk_gesture_single_init (CtkGestureSingle *gesture) |
318 | { |
319 | CtkGestureSinglePrivate *priv; |
320 | |
321 | priv = ctk_gesture_single_get_instance_private (gesture); |
322 | priv->touch_only = FALSE(0); |
323 | priv->button = CDK_BUTTON_PRIMARY(1); |
324 | _ctk_gesture_single_update_evmask (gesture); |
325 | } |
326 | |
327 | /** |
328 | * ctk_gesture_single_get_touch_only: |
329 | * @gesture: a #CtkGestureSingle |
330 | * |
331 | * Returns %TRUE if the gesture is only triggered by touch events. |
332 | * |
333 | * Returns: %TRUE if the gesture only handles touch events |
334 | * |
335 | * Since: 3.14 |
336 | **/ |
337 | gboolean |
338 | ctk_gesture_single_get_touch_only (CtkGestureSingle *gesture) |
339 | { |
340 | CtkGestureSinglePrivate *priv; |
341 | |
342 | g_return_val_if_fail (CTK_IS_GESTURE_SINGLE (gesture), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return ((0)); } } while (0); |
343 | |
344 | priv = ctk_gesture_single_get_instance_private (gesture); |
345 | |
346 | return priv->touch_only; |
347 | } |
348 | |
349 | /** |
350 | * ctk_gesture_single_set_touch_only: |
351 | * @gesture: a #CtkGestureSingle |
352 | * @touch_only: whether @gesture handles only touch events |
353 | * |
354 | * If @touch_only is %TRUE, @gesture will only handle events of type |
355 | * #CDK_TOUCH_BEGIN, #CDK_TOUCH_UPDATE or #CDK_TOUCH_END. If %FALSE, |
356 | * mouse events will be handled too. |
357 | * |
358 | * Since: 3.14 |
359 | **/ |
360 | void |
361 | ctk_gesture_single_set_touch_only (CtkGestureSingle *gesture, |
362 | gboolean touch_only) |
363 | { |
364 | CtkGestureSinglePrivate *priv; |
365 | |
366 | g_return_if_fail (CTK_IS_GESTURE_SINGLE (gesture))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return ; } } while (0); |
367 | |
368 | touch_only = touch_only != FALSE(0); |
369 | priv = ctk_gesture_single_get_instance_private (gesture); |
370 | |
371 | if (priv->touch_only == touch_only) |
372 | return; |
373 | |
374 | priv->touch_only = touch_only; |
375 | _ctk_gesture_single_update_evmask (gesture); |
376 | g_object_notify_by_pspec (G_OBJECT (gesture)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), (((GType) ((20) << (2)))))))), properties[PROP_TOUCH_ONLY]); |
377 | } |
378 | |
379 | /** |
380 | * ctk_gesture_single_get_exclusive: |
381 | * @gesture: a #CtkGestureSingle |
382 | * |
383 | * Gets whether a gesture is exclusive. For more information, see |
384 | * ctk_gesture_single_set_exclusive(). |
385 | * |
386 | * Returns: Whether the gesture is exclusive |
387 | * |
388 | * Since: 3.14 |
389 | **/ |
390 | gboolean |
391 | ctk_gesture_single_get_exclusive (CtkGestureSingle *gesture) |
392 | { |
393 | CtkGestureSinglePrivate *priv; |
394 | |
395 | g_return_val_if_fail (CTK_IS_GESTURE_SINGLE (gesture), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return ((0)); } } while (0); |
396 | |
397 | priv = ctk_gesture_single_get_instance_private (gesture); |
398 | |
399 | return priv->exclusive; |
400 | } |
401 | |
402 | /** |
403 | * ctk_gesture_single_set_exclusive: |
404 | * @gesture: a #CtkGestureSingle |
405 | * @exclusive: %TRUE to make @gesture exclusive |
406 | * |
407 | * Sets whether @gesture is exclusive. An exclusive gesture will |
408 | * only handle pointer and "pointer emulated" touch events, so at |
409 | * any given time, there is only one sequence able to interact with |
410 | * those. |
411 | * |
412 | * Since: 3.14 |
413 | **/ |
414 | void |
415 | ctk_gesture_single_set_exclusive (CtkGestureSingle *gesture, |
416 | gboolean exclusive) |
417 | { |
418 | CtkGestureSinglePrivate *priv; |
419 | |
420 | g_return_if_fail (CTK_IS_GESTURE_SINGLE (gesture))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return ; } } while (0); |
421 | |
422 | exclusive = exclusive != FALSE(0); |
423 | priv = ctk_gesture_single_get_instance_private (gesture); |
424 | |
425 | if (priv->exclusive == exclusive) |
426 | return; |
427 | |
428 | priv->exclusive = exclusive; |
429 | _ctk_gesture_single_update_evmask (gesture); |
430 | g_object_notify_by_pspec (G_OBJECT (gesture)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), (((GType) ((20) << (2)))))))), properties[PROP_EXCLUSIVE]); |
431 | } |
432 | |
433 | /** |
434 | * ctk_gesture_single_get_button: |
435 | * @gesture: a #CtkGestureSingle |
436 | * |
437 | * Returns the button number @gesture listens for, or 0 if @gesture |
438 | * reacts to any button press. |
439 | * |
440 | * Returns: The button number, or 0 for any button |
441 | * |
442 | * Since: 3.14 |
443 | **/ |
444 | guint |
445 | ctk_gesture_single_get_button (CtkGestureSingle *gesture) |
446 | { |
447 | CtkGestureSinglePrivate *priv; |
448 | |
449 | g_return_val_if_fail (CTK_IS_GESTURE_SINGLE (gesture), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return (0); } } while (0); |
450 | |
451 | priv = ctk_gesture_single_get_instance_private (gesture); |
452 | |
453 | return priv->button; |
454 | } |
455 | |
456 | /** |
457 | * ctk_gesture_single_set_button: |
458 | * @gesture: a #CtkGestureSingle |
459 | * @button: button number to listen to, or 0 for any button |
460 | * |
461 | * Sets the button number @gesture listens to. If non-0, every |
462 | * button press from a different button number will be ignored. |
463 | * Touch events implicitly match with button 1. |
464 | * |
465 | * Since: 3.14 |
466 | **/ |
467 | void |
468 | ctk_gesture_single_set_button (CtkGestureSingle *gesture, |
469 | guint button) |
470 | { |
471 | CtkGestureSinglePrivate *priv; |
472 | |
473 | g_return_if_fail (CTK_IS_GESTURE_SINGLE (gesture))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return ; } } while (0); |
474 | |
475 | priv = ctk_gesture_single_get_instance_private (gesture); |
476 | |
477 | if (priv->button == button) |
478 | return; |
479 | |
480 | priv->button = button; |
481 | g_object_notify_by_pspec (G_OBJECT (gesture)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((gesture)), (((GType) ((20) << (2)))))))), properties[PROP_BUTTON]); |
482 | } |
483 | |
484 | /** |
485 | * ctk_gesture_single_get_current_button: |
486 | * @gesture: a #CtkGestureSingle |
487 | * |
488 | * Returns the button number currently interacting with @gesture, or 0 if there |
489 | * is none. |
490 | * |
491 | * Returns: The current button number |
492 | * |
493 | * Since: 3.14 |
494 | **/ |
495 | guint |
496 | ctk_gesture_single_get_current_button (CtkGestureSingle *gesture) |
497 | { |
498 | CtkGestureSinglePrivate *priv; |
499 | |
500 | g_return_val_if_fail (CTK_IS_GESTURE_SINGLE (gesture), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return (0); } } while (0); |
501 | |
502 | priv = ctk_gesture_single_get_instance_private (gesture); |
503 | |
504 | return priv->current_button; |
505 | } |
506 | |
507 | /** |
508 | * ctk_gesture_single_get_current_sequence: |
509 | * @gesture: a #CtkGestureSingle |
510 | * |
511 | * Returns the event sequence currently interacting with @gesture. |
512 | * This is only meaningful if ctk_gesture_is_active() returns %TRUE. |
513 | * |
514 | * Returns: (nullable): the current sequence |
515 | * |
516 | * Since: 3.14 |
517 | **/ |
518 | CdkEventSequence * |
519 | ctk_gesture_single_get_current_sequence (CtkGestureSingle *gesture) |
520 | { |
521 | CtkGestureSinglePrivate *priv; |
522 | |
523 | g_return_val_if_fail (CTK_IS_GESTURE_SINGLE (gesture), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((gesture)); GType __t = ((ctk_gesture_single_get_type ()) ); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_GESTURE_SINGLE (gesture)"); return (((void*)0)); } } while (0); |
524 | |
525 | priv = ctk_gesture_single_get_instance_private (gesture); |
526 | |
527 | return priv->current_sequence; |
528 | } |