1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gdk.Device;
26 
27 private import gdk.Cursor;
28 private import gdk.Display;
29 private import gdk.Screen;
30 private import gdk.Window;
31 private import glib.ListG;
32 private import glib.Str;
33 private import gobject.ObjectG;
34 private import gobject.Signals;
35 private import gtkc.gdk;
36 public  import gtkc.gdktypes;
37 
38 
39 /**
40  * The #GdkDevice object represents a single input device, such
41  * as a keyboard, a mouse, a touchpad, etc.
42  * 
43  * See the #GdkDeviceManager documentation for more information
44  * about the various kinds of master and slave devices, and their
45  * relationships.
46  */
47 public class Device : ObjectG
48 {
49 	/** the main Gtk struct */
50 	protected GdkDevice* gdkDevice;
51 
52 	/** Get the main Gtk struct */
53 	public GdkDevice* getDeviceStruct()
54 	{
55 		return gdkDevice;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gdkDevice;
62 	}
63 
64 	protected override void setStruct(GObject* obj)
65 	{
66 		gdkDevice = cast(GdkDevice*)obj;
67 		super.setStruct(obj);
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GdkDevice* gdkDevice, bool ownedRef = false)
74 	{
75 		this.gdkDevice = gdkDevice;
76 		super(cast(GObject*)gdkDevice, ownedRef);
77 	}
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return gdk_device_get_type();
84 	}
85 
86 	/**
87 	 * Frees an array of #GdkTimeCoord that was returned by gdk_device_get_history().
88 	 *
89 	 * Params:
90 	 *     events = an array of #GdkTimeCoord.
91 	 *     nEvents = the length of the array.
92 	 */
93 	public static void freeHistory(GdkTimeCoord*[] events)
94 	{
95 		gdk_device_free_history(events.ptr, cast(int)events.length);
96 	}
97 
98 	/**
99 	 * Determines information about the current keyboard grab.
100 	 * This is not public API and must not be used by applications.
101 	 *
102 	 * Deprecated: The symbol was never meant to be used outside
103 	 * of GTK+
104 	 *
105 	 * Params:
106 	 *     display = the display for which to get the grab information
107 	 *     device = device to get the grab information from
108 	 *     grabWindow = location to store current grab window
109 	 *     ownerEvents = location to store boolean indicating whether
110 	 *         the @owner_events flag to gdk_keyboard_grab() or
111 	 *         gdk_pointer_grab() was %TRUE.
112 	 *
113 	 * Return: %TRUE if this application currently has the
114 	 *     keyboard grabbed.
115 	 */
116 	public static bool grabInfoLibgtkOnly(Display display, Device device, out Window grabWindow, out bool ownerEvents)
117 	{
118 		GdkWindow* outgrabWindow = null;
119 		int outownerEvents;
120 		
121 		auto p = gdk_device_grab_info_libgtk_only((display is null) ? null : display.getDisplayStruct(), (device is null) ? null : device.getDeviceStruct(), &outgrabWindow, &outownerEvents) != 0;
122 		
123 		grabWindow = ObjectG.getDObject!(Window)(outgrabWindow);
124 		ownerEvents = (outownerEvents == 1);
125 		
126 		return p;
127 	}
128 
129 	/**
130 	 * Returns the associated device to @device, if @device is of type
131 	 * %GDK_DEVICE_TYPE_MASTER, it will return the paired pointer or
132 	 * keyboard.
133 	 *
134 	 * If @device is of type %GDK_DEVICE_TYPE_SLAVE, it will return
135 	 * the master device to which @device is attached to.
136 	 *
137 	 * If @device is of type %GDK_DEVICE_TYPE_FLOATING, %NULL will be
138 	 * returned, as there is no associated device.
139 	 *
140 	 * Return: The associated device, or
141 	 *     %NULL
142 	 *
143 	 * Since: 3.0
144 	 */
145 	public Device getAssociatedDevice()
146 	{
147 		auto p = gdk_device_get_associated_device(gdkDevice);
148 		
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 		
154 		return ObjectG.getDObject!(Device)(cast(GdkDevice*) p);
155 	}
156 
157 	/**
158 	 * Interprets an array of double as axis values for a given device,
159 	 * and locates the value in the array for a given axis use.
160 	 *
161 	 * Params:
162 	 *     axes = pointer to an array of axes
163 	 *     use = the use to look for
164 	 *     value = location to store the found value.
165 	 *
166 	 * Return: %TRUE if the given axis use was found, otherwise %FALSE
167 	 */
168 	public bool getAxis(double[] axes, GdkAxisUse use, out double value)
169 	{
170 		return gdk_device_get_axis(gdkDevice, axes.ptr, use, &value) != 0;
171 	}
172 
173 	/**
174 	 * Returns the axis use for @index_.
175 	 *
176 	 * Params:
177 	 *     index = the index of the axis.
178 	 *
179 	 * Return: a #GdkAxisUse specifying how the axis is used.
180 	 *
181 	 * Since: 2.20
182 	 */
183 	public GdkAxisUse getAxisUse(uint index)
184 	{
185 		return gdk_device_get_axis_use(gdkDevice, index);
186 	}
187 
188 	/**
189 	 * Interprets an array of double as axis values for a given device,
190 	 * and locates the value in the array for a given axis label, as returned
191 	 * by gdk_device_list_axes()
192 	 *
193 	 * Params:
194 	 *     axes = pointer to an array of axes
195 	 *     axisLabel = #GdkAtom with the axis label.
196 	 *     value = location to store the found value.
197 	 *
198 	 * Return: %TRUE if the given axis use was found, otherwise %FALSE.
199 	 *
200 	 * Since: 3.0
201 	 */
202 	public bool getAxisValue(double[] axes, GdkAtom axisLabel, out double value)
203 	{
204 		return gdk_device_get_axis_value(gdkDevice, axes.ptr, axisLabel, &value) != 0;
205 	}
206 
207 	/**
208 	 * Returns the device type for @device.
209 	 *
210 	 * Return: the #GdkDeviceType for @device.
211 	 *
212 	 * Since: 3.0
213 	 */
214 	public GdkDeviceType getDeviceType()
215 	{
216 		return gdk_device_get_device_type(gdkDevice);
217 	}
218 
219 	/**
220 	 * Returns the #GdkDisplay to which @device pertains.
221 	 *
222 	 * Return: a #GdkDisplay. This memory is owned
223 	 *     by GTK+, and must not be freed or unreffed.
224 	 *
225 	 * Since: 3.0
226 	 */
227 	public Display getDisplay()
228 	{
229 		auto p = gdk_device_get_display(gdkDevice);
230 		
231 		if(p is null)
232 		{
233 			return null;
234 		}
235 		
236 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p);
237 	}
238 
239 	/**
240 	 * Determines whether the pointer follows device motion.
241 	 * This is not meaningful for keyboard devices, which don't have a pointer.
242 	 *
243 	 * Return: %TRUE if the pointer follows device motion
244 	 *
245 	 * Since: 2.20
246 	 */
247 	public bool getHasCursor()
248 	{
249 		return gdk_device_get_has_cursor(gdkDevice) != 0;
250 	}
251 
252 	/**
253 	 * Obtains the motion history for a pointer device; given a starting and
254 	 * ending timestamp, return all events in the motion history for
255 	 * the device in the given range of time. Some windowing systems
256 	 * do not support motion history, in which case, %FALSE will
257 	 * be returned. (This is not distinguishable from the case where
258 	 * motion history is supported and no events were found.)
259 	 *
260 	 * Note that there is also gdk_window_set_event_compression() to get
261 	 * more motion events delivered directly, independent of the windowing
262 	 * system.
263 	 *
264 	 * Params:
265 	 *     window = the window with respect to which which the event coordinates will be reported
266 	 *     start = starting timestamp for range of events to return
267 	 *     stop = ending timestamp for the range of events to return
268 	 *     events = location to store a newly-allocated array of #GdkTimeCoord, or
269 	 *         %NULL
270 	 *     nEvents = location to store the length of
271 	 *         @events, or %NULL
272 	 *
273 	 * Return: %TRUE if the windowing system supports motion history and
274 	 *     at least one event was found.
275 	 */
276 	public bool getHistory(Window window, uint start, uint stop, out GdkTimeCoord*[] events)
277 	{
278 		GdkTimeCoord** outevents = null;
279 		int nEvents;
280 		
281 		auto p = gdk_device_get_history(gdkDevice, (window is null) ? null : window.getWindowStruct(), start, stop, &outevents, &nEvents) != 0;
282 		
283 		events = outevents[0 .. nEvents];
284 		
285 		return p;
286 	}
287 
288 	/**
289 	 * If @index_ has a valid keyval, this function will return %TRUE
290 	 * and fill in @keyval and @modifiers with the keyval settings.
291 	 *
292 	 * Params:
293 	 *     index = the index of the macro button to get.
294 	 *     keyval = return value for the keyval.
295 	 *     modifiers = return value for modifiers.
296 	 *
297 	 * Return: %TRUE if keyval is set for @index.
298 	 *
299 	 * Since: 2.20
300 	 */
301 	public bool getKey(uint index, out uint keyval, out GdkModifierType modifiers)
302 	{
303 		return gdk_device_get_key(gdkDevice, index, &keyval, &modifiers) != 0;
304 	}
305 
306 	/**
307 	 * Gets information about which window the given pointer device is in, based on events
308 	 * that have been received so far from the display server. If another application
309 	 * has a pointer grab, or this application has a grab with owner_events = %FALSE,
310 	 * %NULL may be returned even if the pointer is physically over one of this
311 	 * application's windows.
312 	 *
313 	 * Return: the last window the device
314 	 *
315 	 * Since: 3.12
316 	 */
317 	public Window getLastEventWindow()
318 	{
319 		auto p = gdk_device_get_last_event_window(gdkDevice);
320 		
321 		if(p is null)
322 		{
323 			return null;
324 		}
325 		
326 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
327 	}
328 
329 	/**
330 	 * Determines the mode of the device.
331 	 *
332 	 * Return: a #GdkInputSource
333 	 *
334 	 * Since: 2.20
335 	 */
336 	public GdkInputMode getMode()
337 	{
338 		return gdk_device_get_mode(gdkDevice);
339 	}
340 
341 	/**
342 	 * Returns the number of axes the device currently has.
343 	 *
344 	 * Return: the number of axes.
345 	 *
346 	 * Since: 3.0
347 	 */
348 	public int getNAxes()
349 	{
350 		return gdk_device_get_n_axes(gdkDevice);
351 	}
352 
353 	/**
354 	 * Returns the number of keys the device currently has.
355 	 *
356 	 * Return: the number of keys.
357 	 *
358 	 * Since: 2.24
359 	 */
360 	public int getNKeys()
361 	{
362 		return gdk_device_get_n_keys(gdkDevice);
363 	}
364 
365 	/**
366 	 * Determines the name of the device.
367 	 *
368 	 * Return: a name
369 	 *
370 	 * Since: 2.20
371 	 */
372 	public string getName()
373 	{
374 		return Str.toString(gdk_device_get_name(gdkDevice));
375 	}
376 
377 	/**
378 	 * Gets the current location of @device. As a slave device
379 	 * coordinates are those of its master pointer, This function
380 	 * may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
381 	 * unless there is an ongoing grab on them, see gdk_device_grab().
382 	 *
383 	 * Params:
384 	 *     screen = location to store the #GdkScreen
385 	 *         the @device is on, or %NULL.
386 	 *     x = location to store root window X coordinate of @device, or %NULL.
387 	 *     y = location to store root window Y coordinate of @device, or %NULL.
388 	 *
389 	 * Since: 3.0
390 	 */
391 	public void getPosition(out Screen screen, out int x, out int y)
392 	{
393 		GdkScreen* outscreen = null;
394 		
395 		gdk_device_get_position(gdkDevice, &outscreen, &x, &y);
396 		
397 		screen = ObjectG.getDObject!(Screen)(outscreen);
398 	}
399 
400 	/**
401 	 * Gets the current location of @device in double precision. As a slave device's
402 	 * coordinates are those of its master pointer, this function
403 	 * may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
404 	 * unless there is an ongoing grab on them. See gdk_device_grab().
405 	 *
406 	 * Params:
407 	 *     screen = location to store the #GdkScreen
408 	 *         the @device is on, or %NULL.
409 	 *     x = location to store root window X coordinate of @device, or %NULL.
410 	 *     y = location to store root window Y coordinate of @device, or %NULL.
411 	 *
412 	 * Since: 3.10
413 	 */
414 	public void getPositionDouble(out Screen screen, out double x, out double y)
415 	{
416 		GdkScreen* outscreen = null;
417 		
418 		gdk_device_get_position_double(gdkDevice, &outscreen, &x, &y);
419 		
420 		screen = ObjectG.getDObject!(Screen)(outscreen);
421 	}
422 
423 	/**
424 	 * Returns the product ID of this device, or %NULL if this information couldn't
425 	 * be obtained. This ID is retrieved from the device, and is thus constant for
426 	 * it. See gdk_device_get_vendor_id() for more information.
427 	 *
428 	 * Return: the product ID, or %NULL
429 	 *
430 	 * Since: 3.16
431 	 */
432 	public string getProductId()
433 	{
434 		return Str.toString(gdk_device_get_product_id(gdkDevice));
435 	}
436 
437 	/**
438 	 * Determines the type of the device.
439 	 *
440 	 * Return: a #GdkInputSource
441 	 *
442 	 * Since: 2.20
443 	 */
444 	public GdkInputSource getSource()
445 	{
446 		return gdk_device_get_source(gdkDevice);
447 	}
448 
449 	/**
450 	 * Gets the current state of a pointer device relative to @window. As a slave
451 	 * device’s coordinates are those of its master pointer, this
452 	 * function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
453 	 * unless there is an ongoing grab on them. See gdk_device_grab().
454 	 *
455 	 * Params:
456 	 *     window = a #GdkWindow.
457 	 *     axes = an array of doubles to store the values of
458 	 *         the axes of @device in, or %NULL.
459 	 *     mask = location to store the modifiers, or %NULL.
460 	 */
461 	public void getState(Window window, double[] axes, out GdkModifierType mask)
462 	{
463 		gdk_device_get_state(gdkDevice, (window is null) ? null : window.getWindowStruct(), axes.ptr, &mask);
464 	}
465 
466 	/**
467 	 * Returns the vendor ID of this device, or %NULL if this information couldn't
468 	 * be obtained. This ID is retrieved from the device, and is thus constant for
469 	 * it.
470 	 *
471 	 * This function, together with gdk_device_get_product_id(), can be used to eg.
472 	 * compose #GSettings paths to store settings for this device.
473 	 *
474 	 * |[<!-- language="C" -->
475 	 * static GSettings *
476 	 * get_device_settings (GdkDevice *device)
477 	 * {
478 	 * const gchar *vendor, *product;
479 	 * GSettings *settings;
480 	 * GdkDevice *device;
481 	 * gchar *path;
482 	 *
483 	 * vendor = gdk_device_get_vendor_id (device);
484 	 * product = gdk_device_get_product_id (device);
485 	 *
486 	 * path = g_strdup_printf ("/org/example/app/devices/%s:%s/", vendor, product);
487 	 * settings = g_settings_new_with_path (DEVICE_SCHEMA, path);
488 	 * g_free (path);
489 	 *
490 	 * return settings;
491 	 * }
492 	 * ]|
493 	 *
494 	 * Return: the vendor ID, or %NULL
495 	 *
496 	 * Since: 3.16
497 	 */
498 	public string getVendorId()
499 	{
500 		return Str.toString(gdk_device_get_vendor_id(gdkDevice));
501 	}
502 
503 	/**
504 	 * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
505 	 * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
506 	 *
507 	 * As a slave device coordinates are those of its master pointer, This
508 	 * function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
509 	 * unless there is an ongoing grab on them, see gdk_device_grab().
510 	 *
511 	 * Params:
512 	 *     winX = return location for the X coordinate of the device location,
513 	 *         relative to the window origin, or %NULL.
514 	 *     winY = return location for the Y coordinate of the device location,
515 	 *         relative to the window origin, or %NULL.
516 	 *
517 	 * Return: the #GdkWindow under the
518 	 *     device position, or %NULL.
519 	 *
520 	 * Since: 3.0
521 	 */
522 	public Window getWindowAtPosition(out int winX, out int winY)
523 	{
524 		auto p = gdk_device_get_window_at_position(gdkDevice, &winX, &winY);
525 		
526 		if(p is null)
527 		{
528 			return null;
529 		}
530 		
531 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
532 	}
533 
534 	/**
535 	 * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y in
536 	 * double precision. Returns %NULL if the window tree under @device is not known to GDK (for example,
537 	 * belongs to another application).
538 	 *
539 	 * As a slave device coordinates are those of its master pointer, This
540 	 * function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
541 	 * unless there is an ongoing grab on them, see gdk_device_grab().
542 	 *
543 	 * Params:
544 	 *     winX = return location for the X coordinate of the device location,
545 	 *         relative to the window origin, or %NULL.
546 	 *     winY = return location for the Y coordinate of the device location,
547 	 *         relative to the window origin, or %NULL.
548 	 *
549 	 * Return: the #GdkWindow under the
550 	 *     device position, or %NULL.
551 	 *
552 	 * Since: 3.0
553 	 */
554 	public Window getWindowAtPositionDouble(out double winX, out double winY)
555 	{
556 		auto p = gdk_device_get_window_at_position_double(gdkDevice, &winX, &winY);
557 		
558 		if(p is null)
559 		{
560 			return null;
561 		}
562 		
563 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
564 	}
565 
566 	/**
567 	 * Grabs the device so that all events coming from this device are passed to
568 	 * this application until the device is ungrabbed with gdk_device_ungrab(),
569 	 * or the window becomes unviewable. This overrides any previous grab on the device
570 	 * by this client.
571 	 *
572 	 * Note that @device and @window need to be on the same display.
573 	 *
574 	 * Device grabs are used for operations which need complete control over the
575 	 * given device events (either pointer or keyboard). For example in GTK+ this
576 	 * is used for Drag and Drop operations, popup menus and such.
577 	 *
578 	 * Note that if the event mask of an X window has selected both button press
579 	 * and button release events, then a button press event will cause an automatic
580 	 * pointer grab until the button is released. X does this automatically since
581 	 * most applications expect to receive button press and release events in pairs.
582 	 * It is equivalent to a pointer grab on the window with @owner_events set to
583 	 * %TRUE.
584 	 *
585 	 * If you set up anything at the time you take the grab that needs to be
586 	 * cleaned up when the grab ends, you should handle the #GdkEventGrabBroken
587 	 * events that are emitted when the grab ends unvoluntarily.
588 	 *
589 	 * Params:
590 	 *     window = the #GdkWindow which will own the grab (the grab window)
591 	 *     grabOwnership = specifies the grab ownership.
592 	 *     ownerEvents = if %FALSE then all device events are reported with respect to
593 	 *         @window and are only reported if selected by @event_mask. If
594 	 *         %TRUE then pointer events for this application are reported
595 	 *         as normal, but pointer events outside this application are
596 	 *         reported with respect to @window and only if selected by
597 	 *         @event_mask. In either mode, unreported events are discarded.
598 	 *     eventMask = specifies the event mask, which is used in accordance with
599 	 *         @owner_events.
600 	 *     cursor = the cursor to display while the grab is active if the device is
601 	 *         a pointer. If this is %NULL then the normal cursors are used for
602 	 *         @window and its descendants, and the cursor for @window is used
603 	 *         elsewhere.
604 	 *     time = the timestamp of the event which led to this pointer grab. This
605 	 *         usually comes from the #GdkEvent struct, though %GDK_CURRENT_TIME
606 	 *         can be used if the time isn’t known.
607 	 *
608 	 * Return: %GDK_GRAB_SUCCESS if the grab was successful.
609 	 *
610 	 * Since: 3.0
611 	 */
612 	public GdkGrabStatus grab(Window window, GdkGrabOwnership grabOwnership, bool ownerEvents, GdkEventMask eventMask, Cursor cursor, uint time)
613 	{
614 		return gdk_device_grab(gdkDevice, (window is null) ? null : window.getWindowStruct(), grabOwnership, ownerEvents, eventMask, (cursor is null) ? null : cursor.getCursorStruct(), time);
615 	}
616 
617 	/**
618 	 * Returns a #GList of #GdkAtoms, containing the labels for
619 	 * the axes that @device currently has.
620 	 *
621 	 * Return: A #GList of #GdkAtoms, free with g_list_free().
622 	 *
623 	 * Since: 3.0
624 	 */
625 	public ListG listAxes()
626 	{
627 		auto p = gdk_device_list_axes(gdkDevice);
628 		
629 		if(p is null)
630 		{
631 			return null;
632 		}
633 		
634 		return new ListG(cast(GList*) p);
635 	}
636 
637 	/**
638 	 * If the device if of type %GDK_DEVICE_TYPE_MASTER, it will return
639 	 * the list of slave devices attached to it, otherwise it will return
640 	 * %NULL
641 	 *
642 	 * Return: the list of slave devices, or %NULL. The list must be
643 	 *     freed with g_list_free(), the contents of the list are
644 	 *     owned by GTK+ and should not be freed.
645 	 */
646 	public ListG listSlaveDevices()
647 	{
648 		auto p = gdk_device_list_slave_devices(gdkDevice);
649 		
650 		if(p is null)
651 		{
652 			return null;
653 		}
654 		
655 		return new ListG(cast(GList*) p);
656 	}
657 
658 	/**
659 	 * Specifies how an axis of a device is used.
660 	 *
661 	 * Params:
662 	 *     index = the index of the axis
663 	 *     use = specifies how the axis is used
664 	 */
665 	public void setAxisUse(uint index, GdkAxisUse use)
666 	{
667 		gdk_device_set_axis_use(gdkDevice, index, use);
668 	}
669 
670 	/**
671 	 * Specifies the X key event to generate when a macro button of a device
672 	 * is pressed.
673 	 *
674 	 * Params:
675 	 *     index = the index of the macro button to set
676 	 *     keyval = the keyval to generate
677 	 *     modifiers = the modifiers to set
678 	 */
679 	public void setKey(uint index, uint keyval, GdkModifierType modifiers)
680 	{
681 		gdk_device_set_key(gdkDevice, index, keyval, modifiers);
682 	}
683 
684 	/**
685 	 * Sets a the mode of an input device. The mode controls if the
686 	 * device is active and whether the device’s range is mapped to the
687 	 * entire screen or to a single window.
688 	 *
689 	 * Note: This is only meaningful for floating devices, master devices (and
690 	 * slaves connected to these) drive the pointer cursor, which is not limited
691 	 * by the input mode.
692 	 *
693 	 * Params:
694 	 *     mode = the input mode.
695 	 *
696 	 * Return: %TRUE if the mode was successfully changed.
697 	 */
698 	public bool setMode(GdkInputMode mode)
699 	{
700 		return gdk_device_set_mode(gdkDevice, mode) != 0;
701 	}
702 
703 	/**
704 	 * Release any grab on @device.
705 	 *
706 	 * Params:
707 	 *     time = a timestap (e.g. %GDK_CURRENT_TIME).
708 	 *
709 	 * Since: 3.0
710 	 */
711 	public void ungrab(uint time)
712 	{
713 		gdk_device_ungrab(gdkDevice, time);
714 	}
715 
716 	/**
717 	 * Warps @device in @display to the point @x,@y on
718 	 * the screen @screen, unless the device is confined
719 	 * to a window by a grab, in which case it will be moved
720 	 * as far as allowed by the grab. Warping the pointer
721 	 * creates events as if the user had moved the mouse
722 	 * instantaneously to the destination.
723 	 *
724 	 * Note that the pointer should normally be under the
725 	 * control of the user. This function was added to cover
726 	 * some rare use cases like keyboard navigation support
727 	 * for the color picker in the #GtkColorSelectionDialog.
728 	 *
729 	 * Params:
730 	 *     screen = the screen to warp @device to.
731 	 *     x = the X coordinate of the destination.
732 	 *     y = the Y coordinate of the destination.
733 	 *
734 	 * Since: 3.0
735 	 */
736 	public void warp(Screen screen, int x, int y)
737 	{
738 		gdk_device_warp(gdkDevice, (screen is null) ? null : screen.getScreenStruct(), x, y);
739 	}
740 
741 	int[string] connectedSignals;
742 
743 	void delegate(Device)[] onChangedListeners;
744 	/**
745 	 * The ::changed signal is emitted either when the #GdkDevice
746 	 * has changed the number of either axes or keys. For example
747 	 * In X this will normally happen when the slave device routing
748 	 * events through the master device changes (for example, user
749 	 * switches from the USB mouse to a tablet), in that case the
750 	 * master device will change to reflect the new slave device
751 	 * axes and keys.
752 	 */
753 	void addOnChanged(void delegate(Device) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
754 	{
755 		if ( "changed" !in connectedSignals )
756 		{
757 			Signals.connectData(
758 				this,
759 				"changed",
760 				cast(GCallback)&callBackChanged,
761 				cast(void*)this,
762 				null,
763 				connectFlags);
764 			connectedSignals["changed"] = 1;
765 		}
766 		onChangedListeners ~= dlg;
767 	}
768 	extern(C) static void callBackChanged(GdkDevice* deviceStruct, Device _device)
769 	{
770 		foreach ( void delegate(Device) dlg; _device.onChangedListeners )
771 		{
772 			dlg(_device);
773 		}
774 	}
775 }