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