Bug Summary

File:cdk/x11/cdkdevice-xi2.c
Warning:line 776, column 11
Assigned value is garbage or undefined

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 cdkdevice-xi2.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/cdk/x11 -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -D G_LOG_DOMAIN="Cdk" -D G_LOG_USE_STRUCTURED=1 -D CDK_COMPILATION -I ../.. -I ../../cdk -I ../../cdk -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/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -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/cdk/x11 -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-172131-43638-1 -x c cdkdevice-xi2.c
1/* CDK - The GIMP Drawing Kit
2 * Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
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
18#include "config.h"
19
20#include "cdkx11device-xi2.h"
21#include "cdkdeviceprivate.h"
22
23#include "cdkintl.h"
24#include "cdkasync.h"
25#include "cdkprivate-x11.h"
26
27#include <stdlib.h>
28#include <X11/Xlib.h>
29#include <X11/Xutil.h>
30#include <X11/extensions/XInput2.h>
31
32#include <math.h>
33
34/* for the use of round() */
35#include "fallback-c89.c"
36
37typedef struct _ScrollValuator ScrollValuator;
38
39struct _ScrollValuator
40{
41 guint n_valuator : 4;
42 guint direction : 4;
43 guint last_value_valid : 1;
44 gdouble last_value;
45 gdouble increment;
46};
47
48struct _CdkX11DeviceXI2
49{
50 CdkDevice parent_instance;
51
52 gint device_id;
53 GArray *scroll_valuators;
54 gdouble *last_axes;
55};
56
57struct _CdkX11DeviceXI2Class
58{
59 CdkDeviceClass parent_class;
60};
61
62G_DEFINE_TYPE (CdkX11DeviceXI2, cdk_x11_device_xi2, CDK_TYPE_DEVICE)static void cdk_x11_device_xi2_init (CdkX11DeviceXI2 *self); static
void cdk_x11_device_xi2_class_init (CdkX11DeviceXI2Class *klass
); static GType cdk_x11_device_xi2_get_type_once (void); static
gpointer cdk_x11_device_xi2_parent_class = ((void*)0); static
gint CdkX11DeviceXI2_private_offset; static void cdk_x11_device_xi2_class_intern_init
(gpointer klass) { cdk_x11_device_xi2_parent_class = g_type_class_peek_parent
(klass); if (CdkX11DeviceXI2_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CdkX11DeviceXI2_private_offset); cdk_x11_device_xi2_class_init
((CdkX11DeviceXI2Class*) klass); } __attribute__ ((__unused__
)) static inline gpointer cdk_x11_device_xi2_get_instance_private
(CdkX11DeviceXI2 *self) { return (((gpointer) ((guint8*) (self
) + (glong) (CdkX11DeviceXI2_private_offset)))); } GType cdk_x11_device_xi2_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
= cdk_x11_device_xi2_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 cdk_x11_device_xi2_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((cdk_device_get_type ()), g_intern_static_string ("CdkX11DeviceXI2"
), sizeof (CdkX11DeviceXI2Class), (GClassInitFunc)(void (*)(void
)) cdk_x11_device_xi2_class_intern_init, sizeof (CdkX11DeviceXI2
), (GInstanceInitFunc)(void (*)(void)) cdk_x11_device_xi2_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
63
64
65static void cdk_x11_device_xi2_finalize (GObject *object);
66static void cdk_x11_device_xi2_get_property (GObject *object,
67 guint prop_id,
68 GValue *value,
69 GParamSpec *pspec);
70static void cdk_x11_device_xi2_set_property (GObject *object,
71 guint prop_id,
72 const GValue *value,
73 GParamSpec *pspec);
74
75static void cdk_x11_device_xi2_get_state (CdkDevice *device,
76 CdkWindow *window,
77 gdouble *axes,
78 CdkModifierType *mask);
79static void cdk_x11_device_xi2_set_window_cursor (CdkDevice *device,
80 CdkWindow *window,
81 CdkCursor *cursor);
82static void cdk_x11_device_xi2_warp (CdkDevice *device,
83 CdkScreen *screen,
84 gdouble x,
85 gdouble y);
86static void cdk_x11_device_xi2_query_state (CdkDevice *device,
87 CdkWindow *window,
88 CdkWindow **root_window,
89 CdkWindow **child_window,
90 gdouble *root_x,
91 gdouble *root_y,
92 gdouble *win_x,
93 gdouble *win_y,
94 CdkModifierType *mask);
95
96static CdkGrabStatus cdk_x11_device_xi2_grab (CdkDevice *device,
97 CdkWindow *window,
98 gboolean owner_events,
99 CdkEventMask event_mask,
100 CdkWindow *confine_to,
101 CdkCursor *cursor,
102 guint32 time_);
103static void cdk_x11_device_xi2_ungrab (CdkDevice *device,
104 guint32 time_);
105
106static CdkWindow * cdk_x11_device_xi2_window_at_position (CdkDevice *device,
107 gdouble *win_x,
108 gdouble *win_y,
109 CdkModifierType *mask,
110 gboolean get_toplevel);
111static void cdk_x11_device_xi2_select_window_events (CdkDevice *device,
112 CdkWindow *window,
113 CdkEventMask event_mask);
114
115
116enum {
117 PROP_0,
118 PROP_DEVICE_ID
119};
120
121static void
122cdk_x11_device_xi2_class_init (CdkX11DeviceXI2Class *klass)
123{
124 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
125 CdkDeviceClass *device_class = CDK_DEVICE_CLASS (klass)((((CdkDeviceClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((cdk_device_get_type ()))))))
;
126
127 object_class->finalize = cdk_x11_device_xi2_finalize;
128 object_class->get_property = cdk_x11_device_xi2_get_property;
129 object_class->set_property = cdk_x11_device_xi2_set_property;
130
131 device_class->get_state = cdk_x11_device_xi2_get_state;
132 device_class->set_window_cursor = cdk_x11_device_xi2_set_window_cursor;
133 device_class->warp = cdk_x11_device_xi2_warp;
134 device_class->query_state = cdk_x11_device_xi2_query_state;
135 device_class->grab = cdk_x11_device_xi2_grab;
136 device_class->ungrab = cdk_x11_device_xi2_ungrab;
137 device_class->window_at_position = cdk_x11_device_xi2_window_at_position;
138 device_class->select_window_events = cdk_x11_device_xi2_select_window_events;
139
140 g_object_class_install_property (object_class,
141 PROP_DEVICE_ID,
142 g_param_spec_int ("device-id",
143 P_("Device ID")dgettext("ctk30" "-properties","Device ID"),
144 P_("Device identifier")dgettext("ctk30" "-properties","Device identifier"),
145 0, G_MAXINT2147483647, 0,
146 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
147}
148
149static void
150cdk_x11_device_xi2_init (CdkX11DeviceXI2 *device)
151{
152 device->scroll_valuators = g_array_new (FALSE(0), FALSE(0), sizeof (ScrollValuator));
153}
154
155static void
156cdk_x11_device_xi2_finalize (GObject *object)
157{
158 CdkX11DeviceXI2 *device = CDK_X11_DEVICE_XI2 (object)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((cdk_x11_device_xi2_get_type ()))))))
;
159
160 g_array_free (device->scroll_valuators, TRUE(!(0)));
161 g_free (device->last_axes);
162
163 G_OBJECT_CLASS (cdk_x11_device_xi2_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((cdk_x11_device_xi2_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
164}
165
166static void
167cdk_x11_device_xi2_get_property (GObject *object,
168 guint prop_id,
169 GValue *value,
170 GParamSpec *pspec)
171{
172 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (object)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((cdk_x11_device_xi2_get_type ()))))))
;
173
174 switch (prop_id)
175 {
176 case PROP_DEVICE_ID:
177 g_value_set_int (value, device_xi2->device_id);
178 break;
179 default:
180 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'"
, "cdkdevice-xi2.c", 180, ("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)
;
181 break;
182 }
183}
184
185static void
186cdk_x11_device_xi2_set_property (GObject *object,
187 guint prop_id,
188 const GValue *value,
189 GParamSpec *pspec)
190{
191 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (object)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((cdk_x11_device_xi2_get_type ()))))))
;
192
193 switch (prop_id)
194 {
195 case PROP_DEVICE_ID:
196 device_xi2->device_id = g_value_get_int (value);
197 break;
198 default:
199 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'"
, "cdkdevice-xi2.c", 199, ("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)
;
200 break;
201 }
202}
203
204static void
205cdk_x11_device_xi2_get_state (CdkDevice *device,
206 CdkWindow *window,
207 gdouble *axes,
208 CdkModifierType *mask)
209{
210 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
211
212 if (axes)
213 {
214 CdkDisplay *display;
215 XIDeviceInfo *info;
216 gint i, j, ndevices;
217
218 display = cdk_device_get_display (device);
219
220 cdk_x11_display_error_trap_push (display);
221 info = XIQueryDevice (CDK_DISPLAY_XDISPLAY (display)(((((CdkX11Display*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((display)), ((cdk_x11_display_get_type()))))))->xdisplay
)
,
222 device_xi2->device_id, &ndevices);
223 cdk_x11_display_error_trap_pop_ignored (display);
224
225 for (i = 0, j = 0; info && i < info->num_classes; i++)
226 {
227 XIAnyClassInfo *class_info = info->classes[i];
228 CdkAxisUse use;
229 gdouble value;
230
231 if (class_info->type != XIValuatorClass2)
232 continue;
233
234 value = ((XIValuatorClassInfo *) class_info)->value;
235 use = cdk_device_get_axis_use (device, j);
236
237 switch (use)
238 {
239 case CDK_AXIS_X:
240 case CDK_AXIS_Y:
241 case CDK_AXIS_IGNORE:
242 if (cdk_device_get_mode (device) == CDK_MODE_WINDOW)
243 _cdk_device_translate_window_coord (device, window, j, value, &axes[j]);
244 else
245 {
246 gint root_x, root_y;
247
248 /* FIXME: Maybe root coords chaching should happen here */
249 cdk_window_get_origin (window, &root_x, &root_y);
250 _cdk_device_translate_screen_coord (device, window,
251 root_x, root_y,
252 j, value,
253 &axes[j]);
254 }
255 break;
256 default:
257 _cdk_device_translate_axis (device, j, value, &axes[j]);
258 break;
259 }
260
261 j++;
262 }
263
264 if (info)
265 XIFreeDeviceInfo (info);
266 }
267
268 if (mask)
269 cdk_x11_device_xi2_query_state (device, window,
270 NULL((void*)0), NULL((void*)0),
271 NULL((void*)0), NULL((void*)0),
272 NULL((void*)0), NULL((void*)0),
273 mask);
274}
275
276static void
277cdk_x11_device_xi2_set_window_cursor (CdkDevice *device,
278 CdkWindow *window,
279 CdkCursor *cursor)
280{
281 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
282
283 /* Non-master devices don't have a cursor */
284 if (cdk_device_get_device_type (device) != CDK_DEVICE_TYPE_MASTER)
285 return;
286
287 if (cursor)
288 XIDefineCursor (CDK_WINDOW_XDISPLAY (window)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((cdk_window_get_screen (window)))), ((cdk_x11_screen_get_type
()))))))->xdisplay)
,
289 device_xi2->device_id,
290 CDK_WINDOW_XID (window)(((((CdkWindowImplX11*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((((((CdkWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((cdk_window_get_type ()))))))
->impl)), ((cdk_window_impl_x11_get_type ()))))))->xid)
,
291 cdk_x11_cursor_get_xcursor (cursor));
292 else
293 XIUndefineCursor (CDK_WINDOW_XDISPLAY (window)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((cdk_window_get_screen (window)))), ((cdk_x11_screen_get_type
()))))))->xdisplay)
,
294 device_xi2->device_id,
295 CDK_WINDOW_XID (window)(((((CdkWindowImplX11*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((((((CdkWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((cdk_window_get_type ()))))))
->impl)), ((cdk_window_impl_x11_get_type ()))))))->xid)
);
296}
297
298static void
299cdk_x11_device_xi2_warp (CdkDevice *device,
300 CdkScreen *screen,
301 gdouble x,
302 gdouble y)
303{
304 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
305 Window dest;
306
307 dest = CDK_WINDOW_XID (cdk_screen_get_root_window (screen))(((((CdkWindowImplX11*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((((((CdkWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cdk_screen_get_root_window (screen))), (
(cdk_window_get_type ()))))))->impl)), ((cdk_window_impl_x11_get_type
()))))))->xid)
;
308
309 XIWarpPointer (CDK_SCREEN_XDISPLAY (screen)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((cdk_x11_screen_get_type ()))))))->xdisplay
)
,
310 device_xi2->device_id,
311 None0L, dest,
312 0, 0, 0, 0,
313 round (x * CDK_X11_SCREEN(screen)((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((cdk_x11_screen_get_type ()))))))
->window_scale),
314 round (y * CDK_X11_SCREEN(screen)((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((cdk_x11_screen_get_type ()))))))
->window_scale));
315}
316
317static void
318cdk_x11_device_xi2_query_state (CdkDevice *device,
319 CdkWindow *window,
320 CdkWindow **root_window,
321 CdkWindow **child_window,
322 gdouble *root_x,
323 gdouble *root_y,
324 gdouble *win_x,
325 gdouble *win_y,
326 CdkModifierType *mask)
327{
328 CdkWindowImplX11 *impl = CDK_WINDOW_IMPL_X11 (window->impl)((((CdkWindowImplX11*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((window->impl)), ((cdk_window_impl_x11_get_type
()))))))
;
329 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
330 CdkDisplay *display;
331 CdkScreen *default_screen;
332 Window xroot_window, xchild_window;
333 gdouble xroot_x, xroot_y, xwin_x, xwin_y;
334 XIButtonState button_state;
335 XIModifierState mod_state;
336 XIGroupState group_state;
337
338 display = cdk_window_get_display (window);
339 default_screen = cdk_display_get_default_screen (display);
340
341 if (cdk_device_get_device_type (device) == CDK_DEVICE_TYPE_SLAVE)
342 {
343 CdkDevice *master = cdk_device_get_associated_device (device);
344
345 if (master)
346 _cdk_device_query_state (master, window, root_window, child_window,
347 root_x, root_y, win_x, win_y, mask);
348 return;
349 }
350
351 if (!CDK_X11_DISPLAY (display)((((CdkX11Display*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((display)), ((cdk_x11_display_get_type()))))))
->trusted_client ||
352 !XIQueryPointer (CDK_WINDOW_XDISPLAY (window)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((cdk_window_get_screen (window)))), ((cdk_x11_screen_get_type
()))))))->xdisplay)
,
353 device_xi2->device_id,
354 CDK_WINDOW_XID (window)(((((CdkWindowImplX11*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((((((CdkWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((cdk_window_get_type ()))))))
->impl)), ((cdk_window_impl_x11_get_type ()))))))->xid)
,
355 &xroot_window,
356 &xchild_window,
357 &xroot_x, &xroot_y,
358 &xwin_x, &xwin_y,
359 &button_state,
360 &mod_state,
361 &group_state))
362 {
363 XSetWindowAttributes attributes;
364 Display *xdisplay;
365 Window xwindow, w;
366
367 /* FIXME: untrusted clients not multidevice-safe */
368 xdisplay = CDK_SCREEN_XDISPLAY (default_screen)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((default_screen)), ((cdk_x11_screen_get_type ()))))))->
xdisplay)
;
369 xwindow = CDK_SCREEN_XROOTWIN (default_screen)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((default_screen)), ((cdk_x11_screen_get_type ()))))))->
xroot_window)
;
370
371 w = XCreateWindow (xdisplay, xwindow, 0, 0, 1, 1, 0,
372 CopyFromParent0L, InputOnly2, CopyFromParent0L,
373 0, &attributes);
374 XIQueryPointer (xdisplay, device_xi2->device_id,
375 w,
376 &xroot_window,
377 &xchild_window,
378 &xroot_x, &xroot_y,
379 &xwin_x, &xwin_y,
380 &button_state,
381 &mod_state,
382 &group_state);
383 XDestroyWindow (xdisplay, w);
384 }
385
386 if (root_window)
387 *root_window = cdk_x11_window_lookup_for_display (display, xroot_window);
388
389 if (child_window)
390 *child_window = cdk_x11_window_lookup_for_display (display, xchild_window);
391
392 if (root_x)
393 *root_x = xroot_x / impl->window_scale;
394
395 if (root_y)
396 *root_y = xroot_y / impl->window_scale;
397
398 if (win_x)
399 *win_x = xwin_x / impl->window_scale;
400
401 if (win_y)
402 *win_y = xwin_y / impl->window_scale;
403
404 if (mask)
405 *mask = _cdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
406
407 free (button_state.mask);
408}
409
410static CdkGrabStatus
411cdk_x11_device_xi2_grab (CdkDevice *device,
412 CdkWindow *window,
413 gboolean owner_events,
414 CdkEventMask event_mask,
415 CdkWindow *confine_to G_GNUC_UNUSED__attribute__ ((__unused__)),
416 CdkCursor *cursor,
417 guint32 time_)
418{
419 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
420 CdkX11DeviceManagerXI2 *device_manager_xi2;
421 CdkDisplay *display;
422 XIEventMask mask;
423 Window xwindow;
424 Cursor xcursor;
425 gint status;
426
427 display = cdk_device_get_display (device);
428 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
429 device_manager_xi2 = CDK_X11_DEVICE_MANAGER_XI2 (cdk_display_get_device_manager (display))((((CdkX11DeviceManagerXI2*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cdk_display_get_device_manager (display)
)), ((cdk_x11_device_manager_xi2_get_type ()))))))
;
430 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
431
432 /* FIXME: confine_to is actually unused */
433
434 xwindow = CDK_WINDOW_XID (window)(((((CdkWindowImplX11*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((((((CdkWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((cdk_window_get_type ()))))))
->impl)), ((cdk_window_impl_x11_get_type ()))))))->xid)
;
435
436 if (!cursor)
437 xcursor = None0L;
438 else
439 {
440 _cdk_x11_cursor_update_theme (cursor);
441 xcursor = cdk_x11_cursor_get_xcursor (cursor);
442 }
443
444 mask.deviceid = device_xi2->device_id;
445 mask.mask = _cdk_x11_device_xi2_translate_event_mask (device_manager_xi2,
446 event_mask,
447 &mask.mask_len);
448
449#ifdef G_ENABLE_DEBUG1
450 if (CDK_DEBUG_CHECK (NOGRABS)(_cdk_debug_flags & CDK_DEBUG_NOGRABS))
451 status = GrabSuccess0;
452 else
453#endif
454 status = XIGrabDevice (CDK_DISPLAY_XDISPLAY (display)(((((CdkX11Display*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((display)), ((cdk_x11_display_get_type()))))))->xdisplay
)
,
455 device_xi2->device_id,
456 xwindow,
457 time_,
458 xcursor,
459 GrabModeAsync1, GrabModeAsync1,
460 owner_events,
461 &mask);
462
463 g_free (mask.mask);
464
465 _cdk_x11_display_update_grab_info (display, device, status);
466
467 return _cdk_x11_convert_grab_status (status);
468}
469
470static void
471cdk_x11_device_xi2_ungrab (CdkDevice *device,
472 guint32 time_)
473{
474 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
475 CdkDisplay *display;
476 gulong serial;
477
478 display = cdk_device_get_display (device);
479 serial = NextRequest (CDK_DISPLAY_XDISPLAY (display))(((_XPrivDisplay)((((((CdkX11Display*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((display)), ((cdk_x11_display_get_type())
)))))->xdisplay)))->request + 1)
;
480
481 XIUngrabDevice (CDK_DISPLAY_XDISPLAY (display)(((((CdkX11Display*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((display)), ((cdk_x11_display_get_type()))))))->xdisplay
)
, device_xi2->device_id, time_);
482
483 _cdk_x11_display_update_grab_info_ungrab (display, device, time_, serial);
484}
485
486static CdkWindow *
487cdk_x11_device_xi2_window_at_position (CdkDevice *device,
488 gdouble *win_x,
489 gdouble *win_y,
490 CdkModifierType *mask,
491 gboolean get_toplevel)
492{
493 CdkWindowImplX11 *impl;
494 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
495 CdkDisplay *display;
496 CdkScreen *screen;
497 Display *xdisplay;
498 CdkWindow *window;
499 Window xwindow, root, child, last = None0L;
500 gdouble xroot_x, xroot_y, xwin_x, xwin_y;
501 XIButtonState button_state = { 0 };
502 XIModifierState mod_state;
503 XIGroupState group_state;
504 Boolint retval;
505
506 display = cdk_device_get_display (device);
507 screen = cdk_display_get_default_screen (display);
508
509 cdk_x11_display_error_trap_push (display);
510
511 /* This function really only works if the mouse pointer is held still
512 * during its operation. If it moves from one leaf window to another
513 * than we'll end up with inaccurate values for win_x, win_y
514 * and the result.
515 */
516 cdk_x11_display_grab (display);
517
518 xdisplay = CDK_SCREEN_XDISPLAY (screen)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((cdk_x11_screen_get_type ()))))))->xdisplay
)
;
519 xwindow = CDK_SCREEN_XROOTWIN (screen)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((screen)), ((cdk_x11_screen_get_type ()))))))->xroot_window
)
;
520
521 if (G_LIKELY (CDK_X11_DISPLAY (display)->trusted_client)(((((CdkX11Display*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((display)), ((cdk_x11_display_get_type()))))))->trusted_client
)
)
1
Assuming field 'trusted_client' is 0
2
Taking false branch
522 {
523 XIQueryPointer (xdisplay,
524 device_xi2->device_id,
525 xwindow,
526 &root, &child,
527 &xroot_x, &xroot_y,
528 &xwin_x, &xwin_y,
529 &button_state,
530 &mod_state,
531 &group_state);
532
533 if (root == xwindow)
534 xwindow = child;
535 else
536 xwindow = root;
537 }
538 else
539 {
540 gint width, height;
541 GList *toplevels, *list;
542 Window pointer_window;
543
544 /* FIXME: untrusted clients case not multidevice-safe */
545 pointer_window = None0L;
546
547 screen = cdk_display_get_default_screen (display);
548 toplevels = cdk_screen_get_toplevel_windows (screen);
549 for (list = toplevels; list != NULL((void*)0); list = list->next)
3
Assuming 'list' is equal to NULL
4
Loop condition is false. Execution continues on line 609
550 {
551 window = CDK_WINDOW (list->data)((((CdkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list->data)), ((cdk_window_get_type ()))))))
;
552 xwindow = CDK_WINDOW_XID (window)(((((CdkWindowImplX11*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((((((CdkWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((cdk_window_get_type ()))))))
->impl)), ((cdk_window_impl_x11_get_type ()))))))->xid)
;
553
554 /* Free previous button mask, if any */
555 g_free (button_state.mask);
556
557 retval = XIQueryPointer (xdisplay,
558 device_xi2->device_id,
559 xwindow,
560 &root, &child,
561 &xroot_x, &xroot_y,
562 &xwin_x, &xwin_y,
563 &button_state,
564 &mod_state,
565 &group_state);
566 if (!retval)
567 continue;
568
569 if (child != None0L)
570 {
571 pointer_window = child;
572 break;
573 }
574 cdk_window_get_geometry (window, NULL((void*)0), NULL((void*)0), &width, &height);
575 if (xwin_x >= 0 && xwin_y >= 0 && xwin_x < width && xwin_y < height)
576 {
577 /* A childless toplevel, or below another window? */
578 XSetWindowAttributes attributes;
579 Window w;
580
581 free (button_state.mask);
582
583 w = XCreateWindow (xdisplay, xwindow, (int)xwin_x, (int)xwin_y, 1, 1, 0,
584 CopyFromParent0L, InputOnly2, CopyFromParent0L,
585 0, &attributes);
586 XMapWindow (xdisplay, w);
587 XIQueryPointer (xdisplay,
588 device_xi2->device_id,
589 xwindow,
590 &root, &child,
591 &xroot_x, &xroot_y,
592 &xwin_x, &xwin_y,
593 &button_state,
594 &mod_state,
595 &group_state);
596 XDestroyWindow (xdisplay, w);
597 if (child == w)
598 {
599 pointer_window = xwindow;
600 break;
601 }
602 }
603
604 g_list_free (toplevels);
605 if (pointer_window != None0L)
606 break;
607 }
608
609 xwindow = pointer_window;
610 }
611
612 while (xwindow)
5
Loop condition is false. Execution continues on line 638
613 {
614 last = xwindow;
615 free (button_state.mask);
616
617 retval = XIQueryPointer (xdisplay,
618 device_xi2->device_id,
619 xwindow,
620 &root, &xwindow,
621 &xroot_x, &xroot_y,
622 &xwin_x, &xwin_y,
623 &button_state,
624 &mod_state,
625 &group_state);
626 if (!retval)
627 break;
628
629 if (get_toplevel && last != root &&
630 (window = cdk_x11_window_lookup_for_display (display, last)) != NULL((void*)0) &&
631 CDK_WINDOW_TYPE (window)((((CdkWindow *)(window)))->window_type) != CDK_WINDOW_FOREIGN)
632 {
633 xwindow = last;
634 break;
635 }
636 }
637
638 cdk_x11_display_ungrab (display);
639
640 if (cdk_x11_display_error_trap_pop (display) == 0)
6
Assuming the condition is true
7
Taking true branch
641 {
642 window = cdk_x11_window_lookup_for_display (display, last);
643 impl = NULL((void*)0);
644 if (window)
8
Assuming 'window' is null
9
Taking false branch
645 impl = CDK_WINDOW_IMPL_X11 (window->impl)((((CdkWindowImplX11*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((window->impl)), ((cdk_window_impl_x11_get_type
()))))))
;
646
647 if (mask)
10
Assuming 'mask' is non-null
11
Taking true branch
648 *mask = _cdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
12
Calling '_cdk_x11_device_xi2_translate_state'
649
650 free (button_state.mask);
651 }
652 else
653 {
654 window = NULL((void*)0);
655
656 if (mask)
657 *mask = 0;
658 }
659
660 if (win_x)
661 *win_x = (window) ? (xwin_x / impl->window_scale) : -1;
662
663 if (win_y)
664 *win_y = (window) ? (xwin_y / impl->window_scale) : -1;
665
666
667 return window;
668}
669
670static void
671cdk_x11_device_xi2_select_window_events (CdkDevice *device,
672 CdkWindow *window,
673 CdkEventMask event_mask)
674{
675 CdkX11DeviceXI2 *device_xi2 = CDK_X11_DEVICE_XI2 (device)((((CdkX11DeviceXI2*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_x11_device_xi2_get_type ()))))))
;
676 CdkX11DeviceManagerXI2 *device_manager_xi2;
677 CdkDisplay *display;
678 XIEventMask evmask;
679
680 display = cdk_device_get_display (device);
681 G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
;
682 device_manager_xi2 = CDK_X11_DEVICE_MANAGER_XI2 (cdk_display_get_device_manager (display))((((CdkX11DeviceManagerXI2*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cdk_display_get_device_manager (display)
)), ((cdk_x11_device_manager_xi2_get_type ()))))))
;
683 G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ;
684
685 evmask.deviceid = device_xi2->device_id;
686 evmask.mask = _cdk_x11_device_xi2_translate_event_mask (device_manager_xi2,
687 event_mask,
688 &evmask.mask_len);
689
690 XISelectEvents (CDK_WINDOW_XDISPLAY (window)(((((CdkX11Screen*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((cdk_window_get_screen (window)))), ((cdk_x11_screen_get_type
()))))))->xdisplay)
,
691 CDK_WINDOW_XID (window)(((((CdkWindowImplX11*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((((((CdkWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), ((cdk_window_get_type ()))))))
->impl)), ((cdk_window_impl_x11_get_type ()))))))->xid)
,
692 &evmask, 1);
693
694 g_free (evmask.mask);
695}
696
697guchar *
698_cdk_x11_device_xi2_translate_event_mask (CdkX11DeviceManagerXI2 *device_manager_xi2,
699 CdkEventMask event_mask,
700 gint *len)
701{
702 guchar *mask;
703 gint minor;
704
705 g_object_get (device_manager_xi2, "minor", &minor, NULL((void*)0));
706
707 *len = XIMaskLen (XI_LASTEVENT)(((32) >> 3) + 1);
708 mask = g_new0 (guchar, *len)((guchar *) g_malloc0_n ((*len), sizeof (guchar)));
709
710 if (event_mask & CDK_POINTER_MOTION_MASK ||
711 event_mask & CDK_POINTER_MOTION_HINT_MASK)
712 XISetMask (mask, XI_Motion)(((unsigned char*)(mask))[(6)>>3] |= (1 << ((6) &
7)))
;
713
714 if (event_mask & CDK_BUTTON_MOTION_MASK ||
715 event_mask & CDK_BUTTON1_MOTION_MASK ||
716 event_mask & CDK_BUTTON2_MOTION_MASK ||
717 event_mask & CDK_BUTTON3_MOTION_MASK)
718 {
719 XISetMask (mask, XI_ButtonPress)(((unsigned char*)(mask))[(4)>>3] |= (1 << ((4) &
7)))
;
720 XISetMask (mask, XI_ButtonRelease)(((unsigned char*)(mask))[(5)>>3] |= (1 << ((5) &
7)))
;
721 XISetMask (mask, XI_Motion)(((unsigned char*)(mask))[(6)>>3] |= (1 << ((6) &
7)))
;
722 }
723
724 if (event_mask & CDK_SCROLL_MASK)
725 {
726 XISetMask (mask, XI_ButtonPress)(((unsigned char*)(mask))[(4)>>3] |= (1 << ((4) &
7)))
;
727 XISetMask (mask, XI_ButtonRelease)(((unsigned char*)(mask))[(5)>>3] |= (1 << ((5) &
7)))
;
728 }
729
730 if (event_mask & CDK_BUTTON_PRESS_MASK)
731 XISetMask (mask, XI_ButtonPress)(((unsigned char*)(mask))[(4)>>3] |= (1 << ((4) &
7)))
;
732
733 if (event_mask & CDK_BUTTON_RELEASE_MASK)
734 XISetMask (mask, XI_ButtonRelease)(((unsigned char*)(mask))[(5)>>3] |= (1 << ((5) &
7)))
;
735
736 if (event_mask & CDK_KEY_PRESS_MASK)
737 XISetMask (mask, XI_KeyPress)(((unsigned char*)(mask))[(2)>>3] |= (1 << ((2) &
7)))
;
738
739 if (event_mask & CDK_KEY_RELEASE_MASK)
740 XISetMask (mask, XI_KeyRelease)(((unsigned char*)(mask))[(3)>>3] |= (1 << ((3) &
7)))
;
741
742 if (event_mask & CDK_ENTER_NOTIFY_MASK)
743 XISetMask (mask, XI_Enter)(((unsigned char*)(mask))[(7)>>3] |= (1 << ((7) &
7)))
;
744
745 if (event_mask & CDK_LEAVE_NOTIFY_MASK)
746 XISetMask (mask, XI_Leave)(((unsigned char*)(mask))[(8)>>3] |= (1 << ((8) &
7)))
;
747
748 if (event_mask & CDK_FOCUS_CHANGE_MASK)
749 {
750 XISetMask (mask, XI_FocusIn)(((unsigned char*)(mask))[(9)>>3] |= (1 << ((9) &
7)))
;
751 XISetMask (mask, XI_FocusOut)(((unsigned char*)(mask))[(10)>>3] |= (1 << ((10)
& 7)))
;
752 }
753
754#ifdef XINPUT_2_21
755 /* XInput 2.2 includes multitouch support */
756 if (minor >= 2 &&
757 event_mask & CDK_TOUCH_MASK)
758 {
759 XISetMask (mask, XI_TouchBegin)(((unsigned char*)(mask))[(18)>>3] |= (1 << ((18)
& 7)))
;
760 XISetMask (mask, XI_TouchUpdate)(((unsigned char*)(mask))[(19)>>3] |= (1 << ((19)
& 7)))
;
761 XISetMask (mask, XI_TouchEnd)(((unsigned char*)(mask))[(20)>>3] |= (1 << ((20)
& 7)))
;
762 }
763#endif /* XINPUT_2_2 */
764
765 return mask;
766}
767
768guint
769_cdk_x11_device_xi2_translate_state (XIModifierState *mods_state,
770 XIButtonState *buttons_state,
771 XIGroupState *group_state)
772{
773 guint state = 0;
774
775 if (mods_state
12.1
'mods_state' is non-null
)
13
Taking true branch
776 state = mods_state->effective;
14
Assigned value is garbage or undefined
777
778 if (buttons_state)
779 {
780 gint len, i;
781
782 /* We're only interested in the first 3 buttons */
783 len = MIN (3, buttons_state->mask_len * 8)(((3) < (buttons_state->mask_len * 8)) ? (3) : (buttons_state
->mask_len * 8))
;
784
785 for (i = 1; i <= len; i++)
786 {
787 if (!XIMaskIsSet (buttons_state->mask, i)(((unsigned char*)(buttons_state->mask))[(i)>>3] &
(1 << ((i) & 7)))
)
788 continue;
789
790 switch (i)
791 {
792 case 1:
793 state |= CDK_BUTTON1_MASK;
794 break;
795 case 2:
796 state |= CDK_BUTTON2_MASK;
797 break;
798 case 3:
799 state |= CDK_BUTTON3_MASK;
800 break;
801 default:
802 break;
803 }
804 }
805 }
806
807 if (group_state)
808 state |= (group_state->effective) << 13;
809
810 return state;
811}
812
813void
814_cdk_x11_device_xi2_add_scroll_valuator (CdkX11DeviceXI2 *device,
815 guint n_valuator,
816 CdkScrollDirection direction,
817 gdouble increment)
818{
819 ScrollValuator scroll;
820
821 g_return_if_fail (CDK_IS_X11_DEVICE_XI2 (device))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_x11_device_xi2_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 ("Cdk", ((const char
*) (__func__)), "CDK_IS_X11_DEVICE_XI2 (device)"); return; } }
while (0)
;
822 g_return_if_fail (n_valuator < cdk_device_get_n_axes (CDK_DEVICE (device)))do { if ((n_valuator < cdk_device_get_n_axes (((((CdkDevice
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((device
)), ((cdk_device_get_type ()))))))))) { } else { g_return_if_fail_warning
("Cdk", ((const char*) (__func__)), "n_valuator < cdk_device_get_n_axes (CDK_DEVICE (device))"
); return; } } while (0)
;
823
824 scroll.n_valuator = n_valuator;
825 scroll.direction = direction;
826 scroll.last_value_valid = FALSE(0);
827 scroll.increment = increment;
828
829 g_array_append_val (device->scroll_valuators, scroll)g_array_append_vals (device->scroll_valuators, &(scroll
), 1)
;
830}
831
832gboolean
833_cdk_x11_device_xi2_get_scroll_delta (CdkX11DeviceXI2 *device,
834 guint n_valuator,
835 gdouble valuator_value,
836 CdkScrollDirection *direction_ret,
837 gdouble *delta_ret)
838{
839 guint i;
840
841 g_return_val_if_fail (CDK_IS_X11_DEVICE_XI2 (device), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_x11_device_xi2_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 ("Cdk", ((const char
*) (__func__)), "CDK_IS_X11_DEVICE_XI2 (device)"); return ((0
)); } } while (0)
;
842 g_return_val_if_fail (n_valuator < cdk_device_get_n_axes (CDK_DEVICE (device)), FALSE)do { if ((n_valuator < cdk_device_get_n_axes (((((CdkDevice
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((device
)), ((cdk_device_get_type ()))))))))) { } else { g_return_if_fail_warning
("Cdk", ((const char*) (__func__)), "n_valuator < cdk_device_get_n_axes (CDK_DEVICE (device))"
); return ((0)); } } while (0)
;
843
844 for (i = 0; i < device->scroll_valuators->len; i++)
845 {
846 ScrollValuator *scroll;
847
848 scroll = &g_array_index (device->scroll_valuators, ScrollValuator, i)(((ScrollValuator*) (void *) (device->scroll_valuators)->
data) [(i)])
;
849
850 if (scroll->n_valuator == n_valuator)
851 {
852 if (direction_ret)
853 *direction_ret = scroll->direction;
854
855 if (delta_ret)
856 *delta_ret = 0;
857
858 if (scroll->last_value_valid)
859 {
860 if (delta_ret)
861 *delta_ret = (valuator_value - scroll->last_value) / scroll->increment;
862
863 scroll->last_value = valuator_value;
864 }
865 else
866 {
867 scroll->last_value = valuator_value;
868 scroll->last_value_valid = TRUE(!(0));
869 }
870
871 return TRUE(!(0));
872 }
873 }
874
875 return FALSE(0);
876}
877
878void
879_cdk_device_xi2_reset_scroll_valuators (CdkX11DeviceXI2 *device)
880{
881 guint i;
882
883 for (i = 0; i < device->scroll_valuators->len; i++)
884 {
885 ScrollValuator *scroll;
886
887 scroll = &g_array_index (device->scroll_valuators, ScrollValuator, i)(((ScrollValuator*) (void *) (device->scroll_valuators)->
data) [(i)])
;
888 scroll->last_value_valid = FALSE(0);
889 }
890}
891
892void
893_cdk_device_xi2_unset_scroll_valuators (CdkX11DeviceXI2 *device)
894{
895 if (device->scroll_valuators->len > 0)
896 g_array_remove_range (device->scroll_valuators, 0,
897 device->scroll_valuators->len);
898}
899
900gint
901_cdk_x11_device_xi2_get_id (CdkX11DeviceXI2 *device)
902{
903 g_return_val_if_fail (CDK_IS_X11_DEVICE_XI2 (device), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((device)); GType __t = ((cdk_x11_device_xi2_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 ("Cdk", ((const char
*) (__func__)), "CDK_IS_X11_DEVICE_XI2 (device)"); return (0)
; } } while (0)
;
904
905 return device->device_id;
906}
907
908gdouble
909cdk_x11_device_xi2_get_last_axis_value (CdkX11DeviceXI2 *device,
910 gint n_axis)
911{
912 if (n_axis >= cdk_device_get_n_axes (CDK_DEVICE (device)((((CdkDevice*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((device)), ((cdk_device_get_type ()))))))
))
913 return 0;
914
915 if (!device->last_axes)
916 return 0;
917
918 return device->last_axes[n_axis];
919}
920
921void
922cdk_x11_device_xi2_store_axes (CdkX11DeviceXI2 *device,
923 gdouble *axes,
924 gint n_axes)
925{
926 g_free (device->last_axes);
927
928 if (axes && n_axes)
929 device->last_axes = g_memdup2 (axes, sizeof (gdouble) * n_axes);
930 else
931 device->last_axes = NULL((void*)0);
932}