File: | cdk/broadway/cdkdevice-broadway.c |
Warning: | line 358, column 3 Undefined or garbage value returned to caller |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | #include <stdlib.h> | |||
20 | ||||
21 | #include "cdkdevice-broadway.h" | |||
22 | ||||
23 | #include "cdkwindow.h" | |||
24 | #include "cdkprivate-broadway.h" | |||
25 | ||||
26 | static gboolean cdk_broadway_device_get_history (CdkDevice *device, | |||
27 | CdkWindow *window, | |||
28 | guint32 start, | |||
29 | guint32 stop, | |||
30 | CdkTimeCoord ***events, | |||
31 | gint *n_events); | |||
32 | static void cdk_broadway_device_get_state (CdkDevice *device, | |||
33 | CdkWindow *window, | |||
34 | gdouble *axes, | |||
35 | CdkModifierType *mask); | |||
36 | static void cdk_broadway_device_set_window_cursor (CdkDevice *device, | |||
37 | CdkWindow *window, | |||
38 | CdkCursor *cursor); | |||
39 | static void cdk_broadway_device_warp (CdkDevice *device, | |||
40 | CdkScreen *screen, | |||
41 | gdouble x, | |||
42 | gdouble y); | |||
43 | static void cdk_broadway_device_query_state (CdkDevice *device, | |||
44 | CdkWindow *window, | |||
45 | CdkWindow **root_window, | |||
46 | CdkWindow **child_window, | |||
47 | gdouble *root_x, | |||
48 | gdouble *root_y, | |||
49 | gdouble *win_x, | |||
50 | gdouble *win_y, | |||
51 | CdkModifierType *mask); | |||
52 | static CdkGrabStatus cdk_broadway_device_grab (CdkDevice *device, | |||
53 | CdkWindow *window, | |||
54 | gboolean owner_events, | |||
55 | CdkEventMask event_mask, | |||
56 | CdkWindow *confine_to, | |||
57 | CdkCursor *cursor, | |||
58 | guint32 time_); | |||
59 | static void cdk_broadway_device_ungrab (CdkDevice *device, | |||
60 | guint32 time_); | |||
61 | static CdkWindow * cdk_broadway_device_window_at_position (CdkDevice *device, | |||
62 | gdouble *win_x, | |||
63 | gdouble *win_y, | |||
64 | CdkModifierType *mask, | |||
65 | gboolean get_toplevel); | |||
66 | static void cdk_broadway_device_select_window_events (CdkDevice *device, | |||
67 | CdkWindow *window, | |||
68 | CdkEventMask event_mask); | |||
69 | ||||
70 | ||||
71 | G_DEFINE_TYPE (CdkBroadwayDevice, cdk_broadway_device, CDK_TYPE_DEVICE)static void cdk_broadway_device_init (CdkBroadwayDevice *self ); static void cdk_broadway_device_class_init (CdkBroadwayDeviceClass *klass); static GType cdk_broadway_device_get_type_once (void ); static gpointer cdk_broadway_device_parent_class = ((void* )0); static gint CdkBroadwayDevice_private_offset; static void cdk_broadway_device_class_intern_init (gpointer klass) { cdk_broadway_device_parent_class = g_type_class_peek_parent (klass); if (CdkBroadwayDevice_private_offset != 0) g_type_class_adjust_private_offset (klass, &CdkBroadwayDevice_private_offset ); cdk_broadway_device_class_init ((CdkBroadwayDeviceClass*) klass ); } __attribute__ ((__unused__)) static inline gpointer cdk_broadway_device_get_instance_private (CdkBroadwayDevice *self) { return (((gpointer) ((guint8*) ( self) + (glong) (CdkBroadwayDevice_private_offset)))); } GType cdk_broadway_device_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_broadway_device_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_broadway_device_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((cdk_device_get_type ()), g_intern_static_string ("CdkBroadwayDevice" ), sizeof (CdkBroadwayDeviceClass), (GClassInitFunc)(void (*) (void)) cdk_broadway_device_class_intern_init, sizeof (CdkBroadwayDevice ), (GInstanceInitFunc)(void (*)(void)) cdk_broadway_device_init , (GTypeFlags) 0); { {{};} } return g_define_type_id; } | |||
72 | ||||
73 | static void | |||
74 | cdk_broadway_device_class_init (CdkBroadwayDeviceClass *klass) | |||
75 | { | |||
76 | CdkDeviceClass *device_class = CDK_DEVICE_CLASS (klass)((((CdkDeviceClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((cdk_device_get_type ())))))); | |||
77 | ||||
78 | device_class->get_history = cdk_broadway_device_get_history; | |||
79 | device_class->get_state = cdk_broadway_device_get_state; | |||
80 | device_class->set_window_cursor = cdk_broadway_device_set_window_cursor; | |||
81 | device_class->warp = cdk_broadway_device_warp; | |||
82 | device_class->query_state = cdk_broadway_device_query_state; | |||
83 | device_class->grab = cdk_broadway_device_grab; | |||
84 | device_class->ungrab = cdk_broadway_device_ungrab; | |||
85 | device_class->window_at_position = cdk_broadway_device_window_at_position; | |||
86 | device_class->select_window_events = cdk_broadway_device_select_window_events; | |||
87 | } | |||
88 | ||||
89 | static void | |||
90 | cdk_broadway_device_init (CdkBroadwayDevice *device_core) | |||
91 | { | |||
92 | CdkDevice *device; | |||
93 | ||||
94 | device = CDK_DEVICE (device_core)((((CdkDevice*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((device_core)), ((cdk_device_get_type ())))))); | |||
95 | ||||
96 | _cdk_device_add_axis (device, CDK_NONE((CdkAtom)((gpointer) (gulong) (0))), CDK_AXIS_X, 0, 0, 1); | |||
97 | _cdk_device_add_axis (device, CDK_NONE((CdkAtom)((gpointer) (gulong) (0))), CDK_AXIS_Y, 0, 0, 1); | |||
98 | } | |||
99 | ||||
100 | static gboolean | |||
101 | cdk_broadway_device_get_history (CdkDevice *device G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
102 | CdkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
103 | guint32 start G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
104 | guint32 stop G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
105 | CdkTimeCoord ***events G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
106 | gint *n_events G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
107 | { | |||
108 | return FALSE(0); | |||
109 | } | |||
110 | ||||
111 | static void | |||
112 | cdk_broadway_device_get_state (CdkDevice *device, | |||
113 | CdkWindow *window, | |||
114 | gdouble *axes, | |||
115 | CdkModifierType *mask) | |||
116 | { | |||
117 | gdouble x, y; | |||
118 | ||||
119 | cdk_window_get_device_position_double (window, device, &x, &y, mask); | |||
120 | ||||
121 | if (axes) | |||
122 | { | |||
123 | axes[0] = x; | |||
124 | axes[1] = y; | |||
125 | } | |||
126 | } | |||
127 | ||||
128 | static void | |||
129 | cdk_broadway_device_set_window_cursor (CdkDevice *device G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
130 | CdkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
131 | CdkCursor *cursor G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
132 | { | |||
133 | } | |||
134 | ||||
135 | static void | |||
136 | cdk_broadway_device_warp (CdkDevice *device G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
137 | CdkScreen *screen G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
138 | gdouble x G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
139 | gdouble y G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
140 | { | |||
141 | } | |||
142 | ||||
143 | static void | |||
144 | cdk_broadway_device_query_state (CdkDevice *device, | |||
145 | CdkWindow *window, | |||
146 | CdkWindow **root_window, | |||
147 | CdkWindow **child_window, | |||
148 | gdouble *root_x, | |||
149 | gdouble *root_y, | |||
150 | gdouble *win_x, | |||
151 | gdouble *win_y, | |||
152 | CdkModifierType *mask) | |||
153 | { | |||
154 | CdkWindow *toplevel; | |||
155 | CdkWindowImplBroadway *impl; | |||
156 | CdkDisplay *display; | |||
157 | CdkBroadwayDisplay *broadway_display; | |||
158 | gint32 device_root_x, device_root_y; | |||
159 | guint32 mouse_toplevel_id; | |||
160 | CdkWindow *mouse_toplevel; | |||
161 | guint32 mask32; | |||
162 | ||||
163 | if (cdk_device_get_source (device) != CDK_SOURCE_MOUSE) | |||
164 | return; | |||
165 | ||||
166 | display = cdk_device_get_display (device); | |||
167 | broadway_display = CDK_BROADWAY_DISPLAY (display)((((CdkBroadwayDisplay*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((display)), ((cdk_broadway_display_get_type ())))))); | |||
168 | ||||
169 | impl = CDK_WINDOW_IMPL_BROADWAY (window->impl)((((CdkWindowImplBroadway*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->impl)), ((cdk_window_impl_broadway_get_type ())))))); | |||
170 | toplevel = impl->wrapper; | |||
171 | ||||
172 | if (root_window) | |||
173 | { | |||
174 | CdkScreen *screen; | |||
175 | ||||
176 | screen = cdk_window_get_screen (window); | |||
177 | *root_window = cdk_screen_get_root_window (screen); | |||
178 | } | |||
179 | ||||
180 | _cdk_broadway_server_query_mouse (broadway_display->server, | |||
181 | &mouse_toplevel_id, | |||
182 | &device_root_x, | |||
183 | &device_root_y, | |||
184 | &mask32); | |||
185 | mouse_toplevel = g_hash_table_lookup (broadway_display->id_ht, GUINT_TO_POINTER (mouse_toplevel_id)((gpointer) (gulong) (mouse_toplevel_id))); | |||
186 | ||||
187 | if (root_x) | |||
188 | *root_x = device_root_x; | |||
189 | if (root_y) | |||
190 | *root_y = device_root_y; | |||
191 | if (win_x) | |||
192 | *win_x = device_root_x - toplevel->x; | |||
193 | if (win_y) | |||
194 | *win_y = device_root_y - toplevel->y; | |||
195 | if (mask) | |||
196 | *mask = mask32; | |||
197 | if (child_window) | |||
198 | { | |||
199 | if (cdk_window_get_window_type (toplevel) == CDK_WINDOW_ROOT) | |||
200 | { | |||
201 | *child_window = mouse_toplevel; | |||
202 | if (*child_window == NULL((void*)0)) | |||
203 | *child_window = toplevel; | |||
204 | } | |||
205 | else | |||
206 | { | |||
207 | /* No native children */ | |||
208 | *child_window = toplevel; | |||
209 | } | |||
210 | } | |||
211 | ||||
212 | return; | |||
213 | } | |||
214 | ||||
215 | void | |||
216 | _cdk_broadway_window_grab_check_unmap (CdkWindow *window, | |||
217 | gulong serial) | |||
218 | { | |||
219 | CdkDisplay *display = cdk_window_get_display (window); | |||
220 | CdkDeviceManager *device_manager; | |||
221 | GList *devices, *d; | |||
222 | ||||
223 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" ; | |||
224 | device_manager = cdk_display_get_device_manager (display); | |||
225 | ||||
226 | /* Get all devices */ | |||
227 | devices = cdk_device_manager_list_devices (device_manager, CDK_DEVICE_TYPE_MASTER); | |||
228 | devices = g_list_concat (devices, cdk_device_manager_list_devices (device_manager, CDK_DEVICE_TYPE_SLAVE)); | |||
229 | devices = g_list_concat (devices, cdk_device_manager_list_devices (device_manager, CDK_DEVICE_TYPE_FLOATING)); | |||
230 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ; | |||
231 | ||||
232 | /* End all grabs on the newly hidden window */ | |||
233 | for (d = devices; d; d = d->next) | |||
234 | _cdk_display_end_device_grab (display, d->data, serial, window, TRUE(!(0))); | |||
235 | ||||
236 | g_list_free (devices); | |||
237 | } | |||
238 | ||||
239 | ||||
240 | void | |||
241 | _cdk_broadway_window_grab_check_destroy (CdkWindow *window) | |||
242 | { | |||
243 | CdkDisplay *display = cdk_window_get_display (window); | |||
244 | CdkDeviceManager *device_manager; | |||
245 | CdkDeviceGrabInfo *grab; | |||
246 | GList *devices, *d; | |||
247 | ||||
248 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" ; | |||
249 | device_manager = cdk_display_get_device_manager (display); | |||
250 | ||||
251 | /* Get all devices */ | |||
252 | devices = cdk_device_manager_list_devices (device_manager, CDK_DEVICE_TYPE_MASTER); | |||
253 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop ; | |||
254 | ||||
255 | for (d = devices; d; d = d->next) | |||
256 | { | |||
257 | /* Make sure there is no lasting grab in this native window */ | |||
258 | grab = _cdk_display_get_last_device_grab (display, d->data); | |||
259 | ||||
260 | if (grab && grab->native_window == window) | |||
261 | { | |||
262 | grab->serial_end = grab->serial_start; | |||
263 | grab->implicit_ungrab = TRUE(!(0)); | |||
264 | } | |||
265 | ||||
266 | } | |||
267 | ||||
268 | g_list_free (devices); | |||
269 | } | |||
270 | ||||
271 | ||||
272 | static CdkGrabStatus | |||
273 | cdk_broadway_device_grab (CdkDevice *device, | |||
274 | CdkWindow *window, | |||
275 | gboolean owner_events, | |||
276 | CdkEventMask event_mask, | |||
277 | CdkWindow *confine_to G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
278 | CdkCursor *cursor G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
279 | guint32 time_) | |||
280 | { | |||
281 | CdkDisplay *display; | |||
282 | CdkBroadwayDisplay *broadway_display; | |||
283 | ||||
284 | display = cdk_device_get_display (device); | |||
285 | broadway_display = CDK_BROADWAY_DISPLAY (display)((((CdkBroadwayDisplay*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((display)), ((cdk_broadway_display_get_type ())))))); | |||
286 | ||||
287 | if (cdk_device_get_source (device) == CDK_SOURCE_KEYBOARD) | |||
288 | { | |||
289 | /* Device is a keyboard */ | |||
290 | return CDK_GRAB_SUCCESS; | |||
291 | } | |||
292 | else | |||
293 | { | |||
294 | /* Device is a pointer */ | |||
295 | return _cdk_broadway_server_grab_pointer (broadway_display->server, | |||
296 | CDK_WINDOW_IMPL_BROADWAY (window->impl)((((CdkWindowImplBroadway*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->impl)), ((cdk_window_impl_broadway_get_type ()))))))->id, | |||
297 | owner_events, | |||
298 | event_mask, | |||
299 | time_); | |||
300 | } | |||
301 | } | |||
302 | ||||
303 | #define TIME_IS_LATER(time1, time2)( (( time1 > time2 ) && ( time1 - time2 < ((guint32 )-1)/2 )) || (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) ) \ | |||
304 | ( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \ | |||
305 | (( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \ | |||
306 | ) | |||
307 | ||||
308 | static void | |||
309 | cdk_broadway_device_ungrab (CdkDevice *device, | |||
310 | guint32 time_) | |||
311 | { | |||
312 | CdkDisplay *display; | |||
313 | CdkBroadwayDisplay *broadway_display; | |||
314 | guint32 serial; | |||
315 | ||||
316 | display = cdk_device_get_display (device); | |||
317 | broadway_display = CDK_BROADWAY_DISPLAY (display)((((CdkBroadwayDisplay*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((display)), ((cdk_broadway_display_get_type ())))))); | |||
318 | ||||
319 | if (cdk_device_get_source (device) == CDK_SOURCE_KEYBOARD) | |||
320 | { | |||
321 | /* Device is a keyboard */ | |||
322 | } | |||
323 | else | |||
324 | { | |||
325 | /* Device is a pointer */ | |||
326 | serial = _cdk_broadway_server_ungrab_pointer (broadway_display->server, time_); | |||
327 | ||||
328 | if (serial != 0) | |||
329 | { | |||
330 | CdkDeviceGrabInfo *grab; | |||
331 | ||||
332 | grab = _cdk_display_get_last_device_grab (display, device); | |||
333 | if (grab && | |||
334 | (time_ == CDK_CURRENT_TIME0L || | |||
335 | grab->time == CDK_CURRENT_TIME0L || | |||
336 | !TIME_IS_LATER (grab->time, time_)( (( grab->time > time_ ) && ( grab->time - time_ < ((guint32)-1)/2 )) || (( grab->time < time_ ) && ( time_ - grab->time > ((guint32)-1)/2 )) ))) | |||
337 | grab->serial_end = serial; | |||
338 | } | |||
339 | } | |||
340 | } | |||
341 | ||||
342 | static CdkWindow * | |||
343 | cdk_broadway_device_window_at_position (CdkDevice *device, | |||
344 | gdouble *win_x, | |||
345 | gdouble *win_y, | |||
346 | CdkModifierType *mask, | |||
347 | gboolean get_toplevel G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
348 | { | |||
349 | CdkScreen *screen; | |||
350 | CdkWindow *root_window; | |||
351 | CdkWindow *window; | |||
| ||||
352 | ||||
353 | screen = cdk_display_get_default_screen (cdk_device_get_display (device)); | |||
354 | root_window = cdk_screen_get_root_window (screen); | |||
355 | ||||
356 | cdk_broadway_device_query_state (device, root_window, NULL((void*)0), &window, NULL((void*)0), NULL((void*)0), win_x, win_y, mask); | |||
357 | ||||
358 | return window; | |||
| ||||
359 | } | |||
360 | ||||
361 | static void | |||
362 | cdk_broadway_device_select_window_events (CdkDevice *device G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
363 | CdkWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
364 | CdkEventMask event_mask G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
365 | { | |||
366 | } |