Bug Summary

File:ctk/ctkgesturesingle.c
Warning:line 199, column 7
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ctkgesturesingle.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.25.5" -D CTK_BINARY_VERSION="3.0.0" -D CTK_COMPILATION -D CTK_PRINT_BACKEND_ENABLE_UNSUPPORTED -D CTK_LIBDIR="/usr/lib" -D CTK_LOCALEDIR="/usr/share/locale" -D CTK_DATADIR="/usr/share" -D CTK_DATA_PREFIX="/usr" -D CTK_SYSCONFDIR="/usr/etc" -D CTK_HOST="x86_64-pc-linux-gnu" -D CTK_PRINT_BACKENDS="file,cups" -D X11_DATA_PREFIX="/usr" -D ISO_CODES_PREFIX="" -I .. -I ../ctk -I .. -I ../cdk -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/ctk -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-170037-43636-1 -x c ctkgesturesingle.c
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
47typedef struct _CtkGestureSinglePrivate CtkGestureSinglePrivate;
48
49struct _CtkGestureSinglePrivate
50{
51 CdkEventSequence *current_sequence;
52 guint button;
53 guint current_button;
54 guint touch_only : 1;
55 guint exclusive : 1;
56};
57
58enum {
59 PROP_TOUCH_ONLY = 1,
60 PROP_EXCLUSIVE,
61 PROP_BUTTON,
62 LAST_PROP
63};
64
65static GParamSpec *properties[LAST_PROP] = { NULL((void*)0), };
66
67G_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
69static void
70ctk_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
95static void
96ctk_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
120static void
121ctk_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
132static gboolean
133ctk_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
239static void
240ctk_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
300static 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
316static void
317ctk_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 **/
337gboolean
338ctk_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 **/
360void
361ctk_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 **/
390gboolean
391ctk_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 **/
414void
415ctk_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 **/
444guint
445ctk_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 **/
467void
468ctk_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 **/
495guint
496ctk_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 **/
518CdkEventSequence *
519ctk_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}