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