Debian Codegraph @

gtk/gtkgesturedrag.c

raw symbols SCIP
1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2014, Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Author(s): Carlos Garnacho <[email protected]>
18 */
19
20 /**
21 * GtkGestureDrag:
22 *
23 * Recognizes drag gestures.
24 *
25 * The drag operation itself can be tracked throughout the
26 * [[email protected]::drag-begin],
27 * [[email protected]::drag-update] and
28 * [[email protected]::drag-end] signals, and the relevant
29 * coordinates can be extracted through
30 * [[email protected]_offset] and
31 * [[email protected]_start_point].
32 */
33 #include "config.h"cxx . . $ `<file>/build/config.h`/
34 #include "gtkgesturedrag.h"cxx . . $ `<file>/gtk/gtkgesturedrag.h`/
35 #include "gtkgesturedragprivate.h"cxx . . $ `<file>/gtk/gtkgesturedragprivate.h`/
36 #include "gtkmarshalers.h"cxx . . $ `<file>/build/gtk/gtkmarshalers.h`/
37 #include "gtkprivate.h"cxx . . $ `<file>/gtk/gtkprivate.h`/
38
39 typedef struct _GtkGestureDragPrivatecxx . . $ _GtkGestureDragPrivate# GtkGestureDragPrivatecxx . . $ GtkGestureDragPrivate#;
40 typedef struct _EventDatacxx . . $ _EventData# EventDatacxx . . $ EventData#;
41
42 struct _GtkGestureDragPrivatecxx . . $ _GtkGestureDragPrivate#
43 {
44 double start_xcxx . . $ _GtkGestureDragPrivate#start_x.;
45 double start_ycxx . . $ _GtkGestureDragPrivate#start_y.;
46 double last_xcxx . . $ _GtkGestureDragPrivate#last_x.;
47 double last_ycxx . . $ _GtkGestureDragPrivate#last_y.;
48 };
49
50 enumcxx . . $ $anonymous_type_252907e8cec9243a_0# {
51 DRAG_BEGINcxx . . $ DRAG_BEGIN.,
52 DRAG_UPDATEcxx . . $ DRAG_UPDATE.,
53 DRAG_ENDcxx . . $ DRAG_END.,
54 N_SIGNALScxx . . $ N_SIGNALS.
55 };
56
57 static guintcxx . . $ guint# signalscxx . . $ signals.[N_SIGNALScxx . . $ N_SIGNALS.] = { 0 };
58
59 G_DEFINE_TYPE_WITH_PRIVATEcxx . . $ `<external>/9567554376676449156/gtype.h:1876:9`! (GtkGestureDrag, gtk_gesture_drag, GTK_TYPE_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:31:9`!)
60
61 static gbooleancxx . . $ gboolean#
62 gtk_gesture_drag_filter_eventcxx . . $ gtk_gesture_drag_filter_event(7ad650e377e57494). (GtkEventControllercxx . . $ GtkEventController# *controller,
63 GdkEventcxx . . $ GdkEvent# *event)
64 {
65 /* Let touchpad swipe events go through, only if they match n-points */
66 if (gdk_event_get_event_typecxx . . $ gdk_event_get_event_type(af0289f7121992bc). (event) == GDK_TOUCHPAD_SWIPEcxx . . $ GDK_TOUCHPAD_SWIPE.)
67 {
68 guintcxx . . $ guint# n_points;
69 guintcxx . . $ guint# n_fingers;
70
71 g_object_getcxx . . $ g_object_get(1ac911bdc4e9a14d). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (controller), "n-points", &n_points, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
72 n_fingers = gdk_touchpad_event_get_n_fingerscxx . . $ gdk_touchpad_event_get_n_fingers(2d406c81f4428913). (event);
73
74 if (n_fingers == n_points)
75 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
76 else
77 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
78 }
79
80 return GTK_EVENT_CONTROLLER_CLASScxx . . $ `gtk/gtkeventcontroller.h:36:9`! (gtk_gesture_drag_parent_class)->filter_eventcxx . . $ _GtkEventControllerClass#filter_event. (controller, event);
81 }
82
83 static void
84 gtk_gesture_drag_begincxx . . $ gtk_gesture_drag_begin(4613efcc89ef386). (GtkGesturecxx . . $ GtkGesture# *gesture,
85 GdkEventSequencecxx . . $ GdkEventSequence# *sequence)
86 {
87 GtkGestureDragPrivatecxx . . $ GtkGestureDragPrivate# *priv;
88 GdkEventSequencecxx . . $ GdkEventSequence# *current;
89
90 current = gtk_gesture_single_get_current_sequencecxx . . $ gtk_gesture_single_get_current_sequence(eacc6d2458a1513d). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture));
91
92 priv = gtk_gesture_drag_get_instance_privatecxx . . $ gtk_gesture_drag_get_instance_private(3aef8f58c46a2974). (GTK_GESTURE_DRAGcxx . . $ `gtk/gtkgesturedrag.h:31:9`! (gesture));
93 gtk_gesture_get_pointcxx . . $ gtk_gesture_get_point(c2c448b15d15778f). (gesture, current, &priv->start_xcxx . . $ _GtkGestureDragPrivate#start_x., &priv->start_ycxx . . $ _GtkGestureDragPrivate#start_y.);
94 priv->last_xcxx . . $ _GtkGestureDragPrivate#last_x. = priv->start_xcxx . . $ _GtkGestureDragPrivate#start_x.;
95 priv->last_ycxx . . $ _GtkGestureDragPrivate#last_y. = priv->start_ycxx . . $ _GtkGestureDragPrivate#start_y.;
96
97 g_signal_emitcxx . . $ g_signal_emit(cc3f7c2ba1c6a182). (gesture, signalscxx . . $ signals.[DRAG_BEGINcxx . . $ DRAG_BEGIN.], 0, priv->start_xcxx . . $ _GtkGestureDragPrivate#start_x., priv->start_ycxx . . $ _GtkGestureDragPrivate#start_y.);
98 }
99
100 static void
101 gtk_gesture_drag_updatecxx . . $ gtk_gesture_drag_update(4613efcc89ef386). (GtkGesturecxx . . $ GtkGesture# *gesture,
102 GdkEventSequencecxx . . $ GdkEventSequence# *sequence)
103 {
104 GtkGestureDragPrivatecxx . . $ GtkGestureDragPrivate# *priv;
105 double x, y;
106
107 priv = gtk_gesture_drag_get_instance_privatecxx . . $ gtk_gesture_drag_get_instance_private(3aef8f58c46a2974). (GTK_GESTURE_DRAGcxx . . $ `gtk/gtkgesturedrag.h:31:9`! (gesture));
108 gtk_gesture_get_pointcxx . . $ gtk_gesture_get_point(c2c448b15d15778f). (gesture, sequence, &priv->last_xcxx . . $ _GtkGestureDragPrivate#last_x., &priv->last_ycxx . . $ _GtkGestureDragPrivate#last_y.);
109 x = priv->last_xcxx . . $ _GtkGestureDragPrivate#last_x. - priv->start_xcxx . . $ _GtkGestureDragPrivate#start_x.;
110 y = priv->last_ycxx . . $ _GtkGestureDragPrivate#last_y. - priv->start_ycxx . . $ _GtkGestureDragPrivate#start_y.;
111
112 g_signal_emitcxx . . $ g_signal_emit(cc3f7c2ba1c6a182). (gesture, signalscxx . . $ signals.[DRAG_UPDATEcxx . . $ DRAG_UPDATE.], 0, x, y);
113 }
114
115 static void
116 gtk_gesture_drag_endcxx . . $ gtk_gesture_drag_end(4613efcc89ef386). (GtkGesturecxx . . $ GtkGesture# *gesture,
117 GdkEventSequencecxx . . $ GdkEventSequence# *sequence)
118 {
119 GtkGestureDragPrivatecxx . . $ GtkGestureDragPrivate# *priv;
120 GdkEventSequencecxx . . $ GdkEventSequence# *current;
121 double x, y;
122
123 current = gtk_gesture_single_get_current_sequencecxx . . $ gtk_gesture_single_get_current_sequence(eacc6d2458a1513d). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture));
124
125 priv = gtk_gesture_drag_get_instance_privatecxx . . $ gtk_gesture_drag_get_instance_private(3aef8f58c46a2974). (GTK_GESTURE_DRAGcxx . . $ `gtk/gtkgesturedrag.h:31:9`! (gesture));
126 gtk_gesture_get_pointcxx . . $ gtk_gesture_get_point(c2c448b15d15778f). (gesture, current, &priv->last_xcxx . . $ _GtkGestureDragPrivate#last_x., &priv->last_ycxx . . $ _GtkGestureDragPrivate#last_y.);
127 x = priv->last_xcxx . . $ _GtkGestureDragPrivate#last_x. - priv->start_xcxx . . $ _GtkGestureDragPrivate#start_x.;
128 y = priv->last_ycxx . . $ _GtkGestureDragPrivate#last_y. - priv->start_ycxx . . $ _GtkGestureDragPrivate#start_y.;
129
130 g_signal_emitcxx . . $ g_signal_emit(cc3f7c2ba1c6a182). (gesture, signalscxx . . $ signals.[DRAG_ENDcxx . . $ DRAG_END.], 0, x, y);
131 }
132
133 static void
134 gtk_gesture_drag_class_initcxx . . $ gtk_gesture_drag_class_init(f4e3272d8269d3ad). (GtkGestureDragClasscxx . . $ GtkGestureDragClass# *klass)
135 {
136 GtkGestureClasscxx . . $ GtkGestureClass# *gesture_class = GTK_GESTURE_CLASScxx . . $ `gtk/gtkgesture.h:33:9`! (klass);
137 GtkEventControllerClasscxx . . $ GtkEventControllerClass# *event_controller_class = GTK_EVENT_CONTROLLER_CLASScxx . . $ `gtk/gtkeventcontroller.h:36:9`! (klass);
138
139 event_controller_class->filter_eventcxx . . $ _GtkEventControllerClass#filter_event. = gtk_gesture_drag_filter_eventcxx . . $ gtk_gesture_drag_filter_event(7ad650e377e57494).;
140
141 gesture_class->begincxx . . $ _GtkGestureClass#begin. = gtk_gesture_drag_begincxx . . $ gtk_gesture_drag_begin(4613efcc89ef386).;
142 gesture_class->updatecxx . . $ _GtkGestureClass#update. = gtk_gesture_drag_updatecxx . . $ gtk_gesture_drag_update(4613efcc89ef386).;
143 gesture_class->endcxx . . $ _GtkGestureClass#end. = gtk_gesture_drag_endcxx . . $ gtk_gesture_drag_end(4613efcc89ef386).;
144
145 /**
146 * GtkGestureDrag::drag-begin:
147 * @gesture: the object which received the signal
148 * @start_x: X coordinate, relative to the widget allocation
149 * @start_y: Y coordinate, relative to the widget allocation
150 *
151 * Emitted whenever dragging starts.
152 */
153 signalscxx . . $ signals.[DRAG_BEGINcxx . . $ DRAG_BEGIN.] =
154 g_signal_newcxx . . $ g_signal_new(b0aa5e8090fb95c0). (I_cxx . . $ `gdk/gdkprivate.h:35:9`!("drag-begin"),
155 G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (klass),
156 G_SIGNAL_RUN_LASTcxx . . $ G_SIGNAL_RUN_LAST.,
157 G_STRUCT_OFFSETcxx . . $ `<external>/12741050725406041920/gmacros.h:1005:9`! (GtkGestureDragClass, drag_begin),
158 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
159 _gtk_marshal_VOID__DOUBLE_DOUBLEcxx . . $ _gtk_marshal_VOID__DOUBLE_DOUBLE(cba270afb0f82555).,
160 G_TYPE_NONEcxx . . $ `<external>/9567554376676449156/gtype.h:72:9`!, 2, G_TYPE_DOUBLEcxx . . $ `<external>/9567554376676449156/gtype.h:159:9`!, G_TYPE_DOUBLEcxx . . $ `<external>/9567554376676449156/gtype.h:159:9`!);
161 g_signal_set_va_marshallercxx . . $ g_signal_set_va_marshaller(4fd870c04a9d6fe7). (signalscxx . . $ signals.[DRAG_BEGINcxx . . $ DRAG_BEGIN.],
162 G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (klass),
163 _gtk_marshal_VOID__DOUBLE_DOUBLEvcxx . . $ _gtk_marshal_VOID__DOUBLE_DOUBLEv(d309f4be92d1737c).);
164 /**
165 * GtkGestureDrag::drag-update:
166 * @gesture: the object which received the signal
167 * @offset_x: X offset, relative to the start point
168 * @offset_y: Y offset, relative to the start point
169 *
170 * Emitted whenever the dragging point moves.
171 */
172 signalscxx . . $ signals.[DRAG_UPDATEcxx . . $ DRAG_UPDATE.] =
173 g_signal_newcxx . . $ g_signal_new(b0aa5e8090fb95c0). (I_cxx . . $ `gdk/gdkprivate.h:35:9`!("drag-update"),
174 G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (klass),
175 G_SIGNAL_RUN_LASTcxx . . $ G_SIGNAL_RUN_LAST.,
176 G_STRUCT_OFFSETcxx . . $ `<external>/12741050725406041920/gmacros.h:1005:9`! (GtkGestureDragClass, drag_update),
177 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
178 _gtk_marshal_VOID__DOUBLE_DOUBLEcxx . . $ _gtk_marshal_VOID__DOUBLE_DOUBLE(cba270afb0f82555).,
179 G_TYPE_NONEcxx . . $ `<external>/9567554376676449156/gtype.h:72:9`!, 2, G_TYPE_DOUBLEcxx . . $ `<external>/9567554376676449156/gtype.h:159:9`!, G_TYPE_DOUBLEcxx . . $ `<external>/9567554376676449156/gtype.h:159:9`!);
180 g_signal_set_va_marshallercxx . . $ g_signal_set_va_marshaller(4fd870c04a9d6fe7). (signalscxx . . $ signals.[DRAG_UPDATEcxx . . $ DRAG_UPDATE.],
181 G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (klass),
182 _gtk_marshal_VOID__DOUBLE_DOUBLEvcxx . . $ _gtk_marshal_VOID__DOUBLE_DOUBLEv(d309f4be92d1737c).);
183 /**
184 * GtkGestureDrag::drag-end:
185 * @gesture: the object which received the signal
186 * @offset_x: X offset, relative to the start point
187 * @offset_y: Y offset, relative to the start point
188 *
189 * Emitted whenever the dragging is finished.
190 */
191 signalscxx . . $ signals.[DRAG_ENDcxx . . $ DRAG_END.] =
192 g_signal_newcxx . . $ g_signal_new(b0aa5e8090fb95c0). (I_cxx . . $ `gdk/gdkprivate.h:35:9`!("drag-end"),
193 G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (klass),
194 G_SIGNAL_RUN_LASTcxx . . $ G_SIGNAL_RUN_LAST.,
195 G_STRUCT_OFFSETcxx . . $ `<external>/12741050725406041920/gmacros.h:1005:9`! (GtkGestureDragClass, drag_end),
196 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
197 _gtk_marshal_VOID__DOUBLE_DOUBLEcxx . . $ _gtk_marshal_VOID__DOUBLE_DOUBLE(cba270afb0f82555).,
198 G_TYPE_NONEcxx . . $ `<external>/9567554376676449156/gtype.h:72:9`!, 2, G_TYPE_DOUBLEcxx . . $ `<external>/9567554376676449156/gtype.h:159:9`!, G_TYPE_DOUBLEcxx . . $ `<external>/9567554376676449156/gtype.h:159:9`!);
199 g_signal_set_va_marshallercxx . . $ g_signal_set_va_marshaller(4fd870c04a9d6fe7). (signalscxx . . $ signals.[DRAG_ENDcxx . . $ DRAG_END.],
200 G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (klass),
201 _gtk_marshal_VOID__DOUBLE_DOUBLEvcxx . . $ _gtk_marshal_VOID__DOUBLE_DOUBLEv(d309f4be92d1737c).);
202 }
203
204 static void
205 gtk_gesture_drag_initcxx . . $ gtk_gesture_drag_init(43db018dee1fa5e8). (GtkGestureDragcxx . . $ GtkGestureDrag# *gesture)
206 {
207 }
208
209 /**
210 * gtk_gesture_drag_new:
211 *
212 * Returns a newly created `GtkGesture` that recognizes drags.
213 *
214 * Returns: a newly created `GtkGestureDrag`
215 **/
216 GtkGesturecxx . . $ GtkGesture# *
217 gtk_gesture_drag_newcxx . . $ gtk_gesture_drag_new(5d22ad75f7119eec). (void)
218 {
219 return g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_GESTURE_DRAGcxx . . $ `gtk/gtkgesturedrag.h:30:9`!,
220 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
221 }
222
223 /**
224 * gtk_gesture_drag_get_start_point:
225 * @gesture: a `GtkGesture`
226 * @x: (out) (optional): X coordinate for the drag start point
227 * @y: (out) (optional): Y coordinate for the drag start point
228 *
229 * Gets the point where the drag started.
230 *
231 * If the @gesture is active, this function returns %TRUE
232 * and fills in @x and @y with the drag start coordinates,
233 * in widget-relative coordinates.
234 *
235 * Returns: %TRUE if the gesture is active
236 */
237 gbooleancxx . . $ gboolean#
238 gtk_gesture_drag_get_start_pointcxx . . $ gtk_gesture_drag_get_start_point(6882bde6afecff9c). (GtkGestureDragcxx . . $ GtkGestureDrag# *gesture,
239 double *x,
240 double *y)
241 {
242 GtkGestureDragPrivatecxx . . $ GtkGestureDragPrivate# *priv;
243 GdkEventSequencecxx . . $ GdkEventSequence# *sequence;
244
245 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_GESTURE_DRAGcxx . . $ `gtk/gtkgesturedrag.h:33:9`! (gesture), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
246
247 sequence = gtk_gesture_single_get_current_sequencecxx . . $ gtk_gesture_single_get_current_sequence(eacc6d2458a1513d). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture));
248
249 if (!gtk_gesture_handles_sequencecxx . . $ gtk_gesture_handles_sequence(6aa08b709753b55f). (GTK_GESTUREcxx . . $ `gtk/gtkgesture.h:32:9`! (gesture), sequence))
250 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
251
252 priv = gtk_gesture_drag_get_instance_privatecxx . . $ gtk_gesture_drag_get_instance_private(3aef8f58c46a2974). (gesture);
253
254 if (x)
255 *x = priv->start_xcxx . . $ _GtkGestureDragPrivate#start_x.;
256
257 if (y)
258 *y = priv->start_ycxx . . $ _GtkGestureDragPrivate#start_y.;
259
260 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
261 }
262
263 /**
264 * gtk_gesture_drag_get_offset:
265 * @gesture: a `GtkGesture`
266 * @x: (out) (optional): X offset for the current point
267 * @y: (out) (optional): Y offset for the current point
268 *
269 * Gets the offset from the start point.
270 *
271 * If the @gesture is active, this function returns %TRUE and
272 * fills in @x and @y with the coordinates of the current point,
273 * as an offset to the starting drag point.
274 *
275 * Returns: %TRUE if the gesture is active
276 */
277 gbooleancxx . . $ gboolean#
278 gtk_gesture_drag_get_offsetcxx . . $ gtk_gesture_drag_get_offset(6882bde6afecff9c). (GtkGestureDragcxx . . $ GtkGestureDrag# *gesture,
279 double *x,
280 double *y)
281 {
282 GtkGestureDragPrivatecxx . . $ GtkGestureDragPrivate# *priv;
283 GdkEventSequencecxx . . $ GdkEventSequence# *sequence;
284
285 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_GESTURE_DRAGcxx . . $ `gtk/gtkgesturedrag.h:33:9`! (gesture), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
286
287 sequence = gtk_gesture_single_get_current_sequencecxx . . $ gtk_gesture_single_get_current_sequence(eacc6d2458a1513d). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture));
288
289 if (!gtk_gesture_handles_sequencecxx . . $ gtk_gesture_handles_sequence(6aa08b709753b55f). (GTK_GESTUREcxx . . $ `gtk/gtkgesture.h:32:9`! (gesture), sequence))
290 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
291
292 priv = gtk_gesture_drag_get_instance_privatecxx . . $ gtk_gesture_drag_get_instance_private(3aef8f58c46a2974). (gesture);
293
294 if (x)
295 *x = priv->last_xcxx . . $ _GtkGestureDragPrivate#last_x. - priv->start_xcxx . . $ _GtkGestureDragPrivate#start_x.;
296
297 if (y)
298 *y = priv->last_ycxx . . $ _GtkGestureDragPrivate#last_y. - priv->start_ycxx . . $ _GtkGestureDragPrivate#start_y.;
299
300 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
301 }