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.Event;
26 
27 private import gdk.Device;
28 private import gdk.DeviceTool;
29 private import gdk.Screen;
30 private import gdk.Seat;
31 private import gdk.Window;
32 private import glib.ConstructionException;
33 private import glib.Str;
34 private import gobject.ObjectG;
35 private import gobject.Value;
36 private import gtkc.gdk;
37 public  import gtkc.gdktypes;
38 private import gtkd.Loader;
39 
40 
41 /**
42  * A #GdkEvent contains a union of all of the event types,
43  * and allows access to the data fields in a number of ways.
44  * 
45  * The event type is always the first field in all of the event types, and
46  * can always be accessed with the following code, no matter what type of
47  * event it is:
48  * |[<!-- language="C" -->
49  * GdkEvent *event;
50  * GdkEventType type;
51  * 
52  * type = event->type;
53  * ]|
54  * 
55  * To access other fields of the event, the pointer to the event
56  * can be cast to the appropriate event type, or the union member
57  * name can be used. For example if the event type is %GDK_BUTTON_PRESS
58  * then the x coordinate of the button press can be accessed with:
59  * |[<!-- language="C" -->
60  * GdkEvent *event;
61  * gdouble x;
62  * 
63  * x = ((GdkEventButton*)event)->x;
64  * ]|
65  * or:
66  * |[<!-- language="C" -->
67  * GdkEvent *event;
68  * gdouble x;
69  * 
70  * x = event->button.x;
71  * ]|
72  */
73 public class Event
74 {
75 	/** the main Gtk struct */
76 	protected GdkEvent* gdkEvent;
77 	protected bool ownedRef;
78 
79 	/** Get the main Gtk struct */
80 	public GdkEvent* getEventStruct(bool transferOwnership = false)
81 	{
82 		if (transferOwnership)
83 			ownedRef = false;
84 		return gdkEvent;
85 	}
86 
87 	/** the main Gtk struct as a void* */
88 	protected void* getStruct()
89 	{
90 		return cast(void*)gdkEvent;
91 	}
92 
93 	/**
94 	 * Sets our main struct and passes it to the parent class.
95 	 */
96 	public this (GdkEvent* gdkEvent, bool ownedRef = false)
97 	{
98 		this.gdkEvent = gdkEvent;
99 		this.ownedRef = ownedRef;
100 	}
101 
102 	~this ()
103 	{
104 		if (  Linker.isLoaded(LIBRARY_GDK) && ownedRef )
105 			gdk_event_free(gdkEvent);
106 	}
107 
108 	/**
109 	 * Specifies the type of the event.
110 	 */
111 	public EventType type()
112 	{
113 		return gdkEvent.type;
114 	}
115 	
116 	/** Get a specific event. */
117 	public GdkEventAny* any()
118 	{
119 		return cast(GdkEventAny*)gdkEvent;
120 	}
121 	
122 	/** ditto */
123 	public GdkEventExpose* expose()
124 	{
125 		return cast(GdkEventExpose*)gdkEvent;
126 	}
127 	
128 	/** ditto */
129 	public GdkEventVisibility* visibility()
130 	{
131 		return cast(GdkEventVisibility*)gdkEvent;
132 	}
133 	
134 	/** ditto */
135 	public GdkEventMotion* motion()
136 	{
137 		return cast(GdkEventMotion*)gdkEvent;
138 	}
139 	
140 	/** ditto */
141 	public GdkEventButton* button()
142 	{
143 		return cast(GdkEventButton*)gdkEvent;
144 	}
145 	
146 	/** ditto */
147 	public GdkEventScroll* scroll()
148 	{
149 		return cast(GdkEventScroll*)gdkEvent;
150 	}
151 	
152 	/** ditto */
153 	public GdkEventKey* key()
154 	{
155 		return cast(GdkEventKey*)gdkEvent;
156 	}
157 	
158 	/** ditto */
159 	public GdkEventCrossing* crossing()
160 	{
161 		return cast(GdkEventCrossing*)gdkEvent;
162 	}
163 	
164 	/** ditto */
165 	public GdkEventFocus* focus()
166 	{
167 		return cast(GdkEventFocus*)gdkEvent;
168 	}
169 	
170 	/** ditto */
171 	public GdkEventConfigure* configure()
172 	{
173 		return cast(GdkEventConfigure*)gdkEvent;
174 	}
175 	
176 	/** ditto */
177 	public GdkEventProperty* property()
178 	{
179 		return cast(GdkEventProperty*)gdkEvent;
180 	}
181 	
182 	/** ditto */
183 	public GdkEventSelection* selection()
184 	{
185 		return cast(GdkEventSelection*)gdkEvent;
186 	}
187 	
188 	/** ditto */
189 	public GdkEventOwnerChange* ownerChange()
190 	{
191 		return cast(GdkEventOwnerChange*)gdkEvent;
192 	}
193 	
194 	/** ditto */
195 	public GdkEventProximity* proximity()
196 	{
197 		return cast(GdkEventProximity*)gdkEvent;
198 	}
199 	
200 	/** ditto */
201 	public GdkEventDND* dnd()
202 	{
203 		return cast(GdkEventDND*)gdkEvent;
204 	}
205 	
206 	/** ditto */
207 	public GdkEventWindowState* windowState()
208 	{
209 		return cast(GdkEventWindowState*)gdkEvent;
210 	}
211 	
212 	/** ditto */
213 	public GdkEventSetting* setting()
214 	{
215 		return cast(GdkEventSetting*)gdkEvent;
216 	}
217 	
218 	/** ditto */
219 	public GdkEventGrabBroken* grabBroken()
220 	{
221 		return cast(GdkEventGrabBroken*)gdkEvent;
222 	}
223 	
224 	/** */
225 	public static bool isDoubleClick(GdkEventButton* eventButton, int buttonNumber=1)
226 	{
227 		return eventButton.button==buttonNumber
228 		&& eventButton.type == EventType.DOUBLE_BUTTON_PRESS;
229 	}
230 	
231 	/** */
232 	public static bool isTripleClick(GdkEventButton* eventButton, int buttonNumber=1)
233 	{
234 		return eventButton.button==buttonNumber
235 		&& eventButton.type == EventType.TRIPLE_BUTTON_PRESS;
236 	}
237 
238 	/**
239 	 */
240 
241 	/** */
242 	public static GType getType()
243 	{
244 		return gdk_event_get_type();
245 	}
246 
247 	/**
248 	 * Creates a new event of the given type. All fields are set to 0.
249 	 *
250 	 * Params:
251 	 *     type = a #GdkEventType
252 	 *
253 	 * Returns: a newly-allocated #GdkEvent. The returned #GdkEvent
254 	 *     should be freed with gdk_event_free().
255 	 *
256 	 * Since: 2.2
257 	 *
258 	 * Throws: ConstructionException GTK+ fails to create the object.
259 	 */
260 	public this(GdkEventType type)
261 	{
262 		auto p = gdk_event_new(type);
263 		
264 		if(p is null)
265 		{
266 			throw new ConstructionException("null returned by new");
267 		}
268 		
269 		this(cast(GdkEvent*) p);
270 	}
271 
272 	/**
273 	 * If both events contain X/Y information, this function will return %TRUE
274 	 * and return in @angle the relative angle from @event1 to @event2. The rotation
275 	 * direction for positive angles is from the positive X axis towards the positive
276 	 * Y axis.
277 	 *
278 	 * Params:
279 	 *     event1 = first #GdkEvent
280 	 *     event2 = second #GdkEvent
281 	 *     angle = return location for the relative angle between both events
282 	 *
283 	 * Returns: %TRUE if the angle could be calculated.
284 	 *
285 	 * Since: 3.0
286 	 */
287 	public static bool getAngle(Event event1, Event event2, out double angle)
288 	{
289 		return gdk_events_get_angle((event1 is null) ? null : event1.getEventStruct(), (event2 is null) ? null : event2.getEventStruct(), &angle) != 0;
290 	}
291 
292 	/**
293 	 * If both events contain X/Y information, the center of both coordinates
294 	 * will be returned in @x and @y.
295 	 *
296 	 * Params:
297 	 *     event1 = first #GdkEvent
298 	 *     event2 = second #GdkEvent
299 	 *     x = return location for the X coordinate of the center
300 	 *     y = return location for the Y coordinate of the center
301 	 *
302 	 * Returns: %TRUE if the center could be calculated.
303 	 *
304 	 * Since: 3.0
305 	 */
306 	public static bool getCenter(Event event1, Event event2, out double x, out double y)
307 	{
308 		return gdk_events_get_center((event1 is null) ? null : event1.getEventStruct(), (event2 is null) ? null : event2.getEventStruct(), &x, &y) != 0;
309 	}
310 
311 	/**
312 	 * If both events have X/Y information, the distance between both coordinates
313 	 * (as in a straight line going from @event1 to @event2) will be returned.
314 	 *
315 	 * Params:
316 	 *     event1 = first #GdkEvent
317 	 *     event2 = second #GdkEvent
318 	 *     distance = return location for the distance
319 	 *
320 	 * Returns: %TRUE if the distance could be calculated.
321 	 *
322 	 * Since: 3.0
323 	 */
324 	public static bool getDistance(Event event1, Event event2, out double distance)
325 	{
326 		return gdk_events_get_distance((event1 is null) ? null : event1.getEventStruct(), (event2 is null) ? null : event2.getEventStruct(), &distance) != 0;
327 	}
328 
329 	/**
330 	 * Copies a #GdkEvent, copying or incrementing the reference count of the
331 	 * resources associated with it (e.g. #GdkWindow’s and strings).
332 	 *
333 	 * Returns: a copy of @event. The returned #GdkEvent should be freed with
334 	 *     gdk_event_free().
335 	 */
336 	public Event copy()
337 	{
338 		auto p = gdk_event_copy(gdkEvent);
339 		
340 		if(p is null)
341 		{
342 			return null;
343 		}
344 		
345 		return ObjectG.getDObject!(Event)(cast(GdkEvent*) p, true);
346 	}
347 
348 	/**
349 	 * Frees a #GdkEvent, freeing or decrementing any resources associated with it.
350 	 * Note that this function should only be called with events returned from
351 	 * functions such as gdk_event_peek(), gdk_event_get(), gdk_event_copy()
352 	 * and gdk_event_new().
353 	 */
354 	public void free()
355 	{
356 		gdk_event_free(gdkEvent);
357 		ownedRef = false;
358 	}
359 
360 	/**
361 	 * Extract the axis value for a particular axis use from
362 	 * an event structure.
363 	 *
364 	 * Params:
365 	 *     axisUse = the axis use to look for
366 	 *     value = location to store the value found
367 	 *
368 	 * Returns: %TRUE if the specified axis was found, otherwise %FALSE
369 	 */
370 	public bool getAxis(GdkAxisUse axisUse, out double value)
371 	{
372 		return gdk_event_get_axis(gdkEvent, axisUse, &value) != 0;
373 	}
374 
375 	/**
376 	 * Extract the button number from an event.
377 	 *
378 	 * Params:
379 	 *     button = location to store mouse button number
380 	 *
381 	 * Returns: %TRUE if the event delivered a button number
382 	 *
383 	 * Since: 3.2
384 	 */
385 	public bool getButton(out uint button)
386 	{
387 		return gdk_event_get_button(gdkEvent, &button) != 0;
388 	}
389 
390 	/**
391 	 * Extracts the click count from an event.
392 	 *
393 	 * Params:
394 	 *     clickCount = location to store click count
395 	 *
396 	 * Returns: %TRUE if the event delivered a click count
397 	 *
398 	 * Since: 3.2
399 	 */
400 	public bool getClickCount(out uint clickCount)
401 	{
402 		return gdk_event_get_click_count(gdkEvent, &clickCount) != 0;
403 	}
404 
405 	/**
406 	 * Extract the event window relative x/y coordinates from an event.
407 	 *
408 	 * Params:
409 	 *     xWin = location to put event window x coordinate
410 	 *     yWin = location to put event window y coordinate
411 	 *
412 	 * Returns: %TRUE if the event delivered event window coordinates
413 	 */
414 	public bool getCoords(out double xWin, out double yWin)
415 	{
416 		return gdk_event_get_coords(gdkEvent, &xWin, &yWin) != 0;
417 	}
418 
419 	/**
420 	 * If the event contains a “device” field, this function will return
421 	 * it, else it will return %NULL.
422 	 *
423 	 * Returns: a #GdkDevice, or %NULL.
424 	 *
425 	 * Since: 3.0
426 	 */
427 	public Device getDevice()
428 	{
429 		auto p = gdk_event_get_device(gdkEvent);
430 		
431 		if(p is null)
432 		{
433 			return null;
434 		}
435 		
436 		return ObjectG.getDObject!(Device)(cast(GdkDevice*) p);
437 	}
438 
439 	/**
440 	 * If the event was generated by a device that supports
441 	 * different tools (eg. a tablet), this function will
442 	 * return a #GdkDeviceTool representing the tool that
443 	 * caused the event. Otherwise, %NULL will be returned.
444 	 *
445 	 * Note: the #GdkDeviceTool<!-- -->s will be constant during
446 	 * the application lifetime, if settings must be stored
447 	 * persistently across runs, see gdk_device_tool_get_serial()
448 	 *
449 	 * Returns: The current device tool, or %NULL
450 	 *
451 	 * Since: 3.22
452 	 */
453 	public DeviceTool getDeviceTool()
454 	{
455 		auto p = gdk_event_get_device_tool(gdkEvent);
456 		
457 		if(p is null)
458 		{
459 			return null;
460 		}
461 		
462 		return ObjectG.getDObject!(DeviceTool)(cast(GdkDeviceTool*) p);
463 	}
464 
465 	/**
466 	 * If @event if of type %GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
467 	 * %GDK_TOUCH_END or %GDK_TOUCH_CANCEL, returns the #GdkEventSequence
468 	 * to which the event belongs. Otherwise, return %NULL.
469 	 *
470 	 * Returns: the event sequence that the event belongs to
471 	 *
472 	 * Since: 3.4
473 	 */
474 	public GdkEventSequence* getEventSequence()
475 	{
476 		return gdk_event_get_event_sequence(gdkEvent);
477 	}
478 
479 	/**
480 	 * Retrieves the type of the event.
481 	 *
482 	 * Returns: a #GdkEventType
483 	 *
484 	 * Since: 3.10
485 	 */
486 	public GdkEventType getEventType()
487 	{
488 		return gdk_event_get_event_type(gdkEvent);
489 	}
490 
491 	/**
492 	 * Extracts the hardware keycode from an event.
493 	 *
494 	 * Also see gdk_event_get_scancode().
495 	 *
496 	 * Params:
497 	 *     keycode = location to store the keycode
498 	 *
499 	 * Returns: %TRUE if the event delivered a hardware keycode
500 	 *
501 	 * Since: 3.2
502 	 */
503 	public bool getKeycode(out ushort keycode)
504 	{
505 		return gdk_event_get_keycode(gdkEvent, &keycode) != 0;
506 	}
507 
508 	/**
509 	 * Extracts the keyval from an event.
510 	 *
511 	 * Params:
512 	 *     keyval = location to store the keyval
513 	 *
514 	 * Returns: %TRUE if the event delivered a key symbol
515 	 *
516 	 * Since: 3.2
517 	 */
518 	public bool getKeyval(out uint keyval)
519 	{
520 		return gdk_event_get_keyval(gdkEvent, &keyval) != 0;
521 	}
522 
523 	/**
524 	 * #event: a #GdkEvent
525 	 * Returns whether this event is an 'emulated' pointer event (typically
526 	 * from a touch event), as opposed to a real one.
527 	 *
528 	 * Returns: %TRUE if this event is emulated
529 	 *
530 	 * Since: 3.22
531 	 */
532 	public bool getPointerEmulated()
533 	{
534 		return gdk_event_get_pointer_emulated(gdkEvent) != 0;
535 	}
536 
537 	/**
538 	 * Extract the root window relative x/y coordinates from an event.
539 	 *
540 	 * Params:
541 	 *     xRoot = location to put root window x coordinate
542 	 *     yRoot = location to put root window y coordinate
543 	 *
544 	 * Returns: %TRUE if the event delivered root window coordinates
545 	 */
546 	public bool getRootCoords(out double xRoot, out double yRoot)
547 	{
548 		return gdk_event_get_root_coords(gdkEvent, &xRoot, &yRoot) != 0;
549 	}
550 
551 	/**
552 	 * Gets the keyboard low-level scancode of a key event.
553 	 *
554 	 * This is usually hardware_keycode. On Windows this is the high
555 	 * word of WM_KEY{DOWN,UP} lParam which contains the scancode and
556 	 * some extended flags.
557 	 *
558 	 * Returns: The associated keyboard scancode or 0
559 	 *
560 	 * Since: 3.22
561 	 */
562 	public int getScancode()
563 	{
564 		return gdk_event_get_scancode(gdkEvent);
565 	}
566 
567 	/**
568 	 * Returns the screen for the event. The screen is
569 	 * typically the screen for `event->any.window`, but
570 	 * for events such as mouse events, it is the screen
571 	 * where the pointer was when the event occurs -
572 	 * that is, the screen which has the root window
573 	 * to which `event->motion.x_root` and
574 	 * `event->motion.y_root` are relative.
575 	 *
576 	 * Returns: the screen for the event
577 	 *
578 	 * Since: 2.2
579 	 */
580 	public Screen getScreen()
581 	{
582 		auto p = gdk_event_get_screen(gdkEvent);
583 		
584 		if(p is null)
585 		{
586 			return null;
587 		}
588 		
589 		return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p);
590 	}
591 
592 	/**
593 	 * Retrieves the scroll deltas from a #GdkEvent
594 	 *
595 	 * Params:
596 	 *     deltaX = return location for X delta
597 	 *     deltaY = return location for Y delta
598 	 *
599 	 * Returns: %TRUE if the event contains smooth scroll information
600 	 *
601 	 * Since: 3.4
602 	 */
603 	public bool getScrollDeltas(out double deltaX, out double deltaY)
604 	{
605 		return gdk_event_get_scroll_deltas(gdkEvent, &deltaX, &deltaY) != 0;
606 	}
607 
608 	/**
609 	 * Extracts the scroll direction from an event.
610 	 *
611 	 * Params:
612 	 *     direction = location to store the scroll direction
613 	 *
614 	 * Returns: %TRUE if the event delivered a scroll direction
615 	 *
616 	 * Since: 3.2
617 	 */
618 	public bool getScrollDirection(out GdkScrollDirection direction)
619 	{
620 		return gdk_event_get_scroll_direction(gdkEvent, &direction) != 0;
621 	}
622 
623 	/**
624 	 * Returns the #GdkSeat this event was generated for.
625 	 *
626 	 * Returns: The #GdkSeat of this event
627 	 *
628 	 * Since: 3.20
629 	 */
630 	public Seat getSeat()
631 	{
632 		auto p = gdk_event_get_seat(gdkEvent);
633 		
634 		if(p is null)
635 		{
636 			return null;
637 		}
638 		
639 		return ObjectG.getDObject!(Seat)(cast(GdkSeat*) p);
640 	}
641 
642 	/**
643 	 * This function returns the hardware (slave) #GdkDevice that has
644 	 * triggered the event, falling back to the virtual (master) device
645 	 * (as in gdk_event_get_device()) if the event wasn’t caused by
646 	 * interaction with a hardware device. This may happen for example
647 	 * in synthesized crossing events after a #GdkWindow updates its
648 	 * geometry or a grab is acquired/released.
649 	 *
650 	 * If the event does not contain a device field, this function will
651 	 * return %NULL.
652 	 *
653 	 * Returns: a #GdkDevice, or %NULL.
654 	 *
655 	 * Since: 3.0
656 	 */
657 	public Device getSourceDevice()
658 	{
659 		auto p = gdk_event_get_source_device(gdkEvent);
660 		
661 		if(p is null)
662 		{
663 			return null;
664 		}
665 		
666 		return ObjectG.getDObject!(Device)(cast(GdkDevice*) p);
667 	}
668 
669 	/**
670 	 * If the event contains a “state” field, puts that field in @state. Otherwise
671 	 * stores an empty state (0). Returns %TRUE if there was a state field
672 	 * in the event. @event may be %NULL, in which case it’s treated
673 	 * as if the event had no state field.
674 	 *
675 	 * Params:
676 	 *     state = return location for state
677 	 *
678 	 * Returns: %TRUE if there was a state field in the event
679 	 */
680 	public bool getState(out GdkModifierType state)
681 	{
682 		return gdk_event_get_state(gdkEvent, &state) != 0;
683 	}
684 
685 	/**
686 	 * Returns the time stamp from @event, if there is one; otherwise
687 	 * returns #GDK_CURRENT_TIME. If @event is %NULL, returns #GDK_CURRENT_TIME.
688 	 *
689 	 * Returns: time stamp field from @event
690 	 */
691 	public uint getTime()
692 	{
693 		return gdk_event_get_time(gdkEvent);
694 	}
695 
696 	/**
697 	 * Extracts the #GdkWindow associated with an event.
698 	 *
699 	 * Returns: The #GdkWindow associated with the event
700 	 *
701 	 * Since: 3.10
702 	 */
703 	public Window getWindow()
704 	{
705 		auto p = gdk_event_get_window(gdkEvent);
706 		
707 		if(p is null)
708 		{
709 			return null;
710 		}
711 		
712 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
713 	}
714 
715 	/**
716 	 * Check whether a scroll event is a stop scroll event. Scroll sequences
717 	 * with smooth scroll information may provide a stop scroll event once the
718 	 * interaction with the device finishes, e.g. by lifting a finger. This
719 	 * stop scroll event is the signal that a widget may trigger kinetic
720 	 * scrolling based on the current velocity.
721 	 *
722 	 * Stop scroll events always have a a delta of 0/0.
723 	 *
724 	 * Returns: %TRUE if the event is a scroll stop event
725 	 *
726 	 * Since: 3.20
727 	 */
728 	public bool isScrollStopEvent()
729 	{
730 		return gdk_event_is_scroll_stop_event(gdkEvent) != 0;
731 	}
732 
733 	/**
734 	 * Appends a copy of the given event onto the front of the event
735 	 * queue for event->any.window’s display, or the default event
736 	 * queue if event->any.window is %NULL. See gdk_display_put_event().
737 	 */
738 	public void put()
739 	{
740 		gdk_event_put(gdkEvent);
741 	}
742 
743 	/**
744 	 * Sets the device for @event to @device. The event must
745 	 * have been allocated by GTK+, for instance, by
746 	 * gdk_event_copy().
747 	 *
748 	 * Params:
749 	 *     device = a #GdkDevice
750 	 *
751 	 * Since: 3.0
752 	 */
753 	public void setDevice(Device device)
754 	{
755 		gdk_event_set_device(gdkEvent, (device is null) ? null : device.getDeviceStruct());
756 	}
757 
758 	/**
759 	 * Sets the device tool for this event, should be rarely used.
760 	 *
761 	 * Params:
762 	 *     tool = tool to set on the event, or %NULL
763 	 *
764 	 * Since: 3.22
765 	 */
766 	public void setDeviceTool(DeviceTool tool)
767 	{
768 		gdk_event_set_device_tool(gdkEvent, (tool is null) ? null : tool.getDeviceToolStruct());
769 	}
770 
771 	/**
772 	 * Sets the screen for @event to @screen. The event must
773 	 * have been allocated by GTK+, for instance, by
774 	 * gdk_event_copy().
775 	 *
776 	 * Params:
777 	 *     screen = a #GdkScreen
778 	 *
779 	 * Since: 2.2
780 	 */
781 	public void setScreen(Screen screen)
782 	{
783 		gdk_event_set_screen(gdkEvent, (screen is null) ? null : screen.getScreenStruct());
784 	}
785 
786 	/**
787 	 * Sets the slave device for @event to @device.
788 	 *
789 	 * The event must have been allocated by GTK+,
790 	 * for instance by gdk_event_copy().
791 	 *
792 	 * Params:
793 	 *     device = a #GdkDevice
794 	 *
795 	 * Since: 3.0
796 	 */
797 	public void setSourceDevice(Device device)
798 	{
799 		gdk_event_set_source_device(gdkEvent, (device is null) ? null : device.getDeviceStruct());
800 	}
801 
802 	/**
803 	 * This function returns whether a #GdkEventButton should trigger a
804 	 * context menu, according to platform conventions. The right mouse
805 	 * button always triggers context menus. Additionally, if
806 	 * gdk_keymap_get_modifier_mask() returns a non-0 mask for
807 	 * %GDK_MODIFIER_INTENT_CONTEXT_MENU, then the left mouse button will
808 	 * also trigger a context menu if this modifier is pressed.
809 	 *
810 	 * This function should always be used instead of simply checking for
811 	 * event->button == %GDK_BUTTON_SECONDARY.
812 	 *
813 	 * Returns: %TRUE if the event should trigger a context menu.
814 	 *
815 	 * Since: 3.4
816 	 */
817 	public bool triggersContextMenu()
818 	{
819 		return gdk_event_triggers_context_menu(gdkEvent) != 0;
820 	}
821 
822 	/**
823 	 * Checks all open displays for a #GdkEvent to process,to be processed
824 	 * on, fetching events from the windowing system if necessary.
825 	 * See gdk_display_get_event().
826 	 *
827 	 * Returns: the next #GdkEvent to be processed, or %NULL
828 	 *     if no events are pending. The returned #GdkEvent should be freed
829 	 *     with gdk_event_free().
830 	 */
831 	public static Event get()
832 	{
833 		auto p = gdk_event_get();
834 		
835 		if(p is null)
836 		{
837 			return null;
838 		}
839 		
840 		return ObjectG.getDObject!(Event)(cast(GdkEvent*) p, true);
841 	}
842 
843 	/**
844 	 * Sets the function to call to handle all events from GDK.
845 	 *
846 	 * Note that GTK+ uses this to install its own event handler, so it is
847 	 * usually not useful for GTK+ applications. (Although an application
848 	 * can call this function then call gtk_main_do_event() to pass
849 	 * events to GTK+.)
850 	 *
851 	 * Params:
852 	 *     func = the function to call to handle events from GDK.
853 	 *     data = user data to pass to the function.
854 	 *     notify = the function to call when the handler function is removed, i.e. when
855 	 *         gdk_event_handler_set() is called with another event handler.
856 	 */
857 	public static void handlerSet(GdkEventFunc func, void* data, GDestroyNotify notify)
858 	{
859 		gdk_event_handler_set(func, data, notify);
860 	}
861 
862 	/**
863 	 * If there is an event waiting in the event queue of some open
864 	 * display, returns a copy of it. See gdk_display_peek_event().
865 	 *
866 	 * Returns: a copy of the first #GdkEvent on some event
867 	 *     queue, or %NULL if no events are in any queues. The returned
868 	 *     #GdkEvent should be freed with gdk_event_free().
869 	 */
870 	public static Event peek()
871 	{
872 		auto p = gdk_event_peek();
873 		
874 		if(p is null)
875 		{
876 			return null;
877 		}
878 		
879 		return ObjectG.getDObject!(Event)(cast(GdkEvent*) p, true);
880 	}
881 
882 	/**
883 	 * Request more motion notifies if @event is a motion notify hint event.
884 	 *
885 	 * This function should be used instead of gdk_window_get_pointer() to
886 	 * request further motion notifies, because it also works for extension
887 	 * events where motion notifies are provided for devices other than the
888 	 * core pointer. Coordinate extraction, processing and requesting more
889 	 * motion events from a %GDK_MOTION_NOTIFY event usually works like this:
890 	 *
891 	 * |[<!-- language="C" -->
892 	 * {
893 	 * // motion_event handler
894 	 * x = motion_event->x;
895 	 * y = motion_event->y;
896 	 * // handle (x,y) motion
897 	 * gdk_event_request_motions (motion_event); // handles is_hint events
898 	 * }
899 	 * ]|
900 	 *
901 	 * Params:
902 	 *     event = a valid #GdkEvent
903 	 *
904 	 * Since: 2.12
905 	 */
906 	public static void requestMotions(GdkEventMotion* event)
907 	{
908 		gdk_event_request_motions(event);
909 	}
910 
911 	/**
912 	 * Checks if any events are ready to be processed for any display.
913 	 *
914 	 * Returns: %TRUE if any events are pending.
915 	 */
916 	public static bool pending()
917 	{
918 		return gdk_events_pending() != 0;
919 	}
920 
921 	/**
922 	 * Gets whether event debugging output is enabled.
923 	 *
924 	 * Returns: %TRUE if event debugging output is enabled.
925 	 */
926 	public static bool getShowEvents()
927 	{
928 		return gdk_get_show_events() != 0;
929 	}
930 
931 	/**
932 	 * Sets whether a trace of received events is output.
933 	 * Note that GTK+ must be compiled with debugging (that is,
934 	 * configured using the `--enable-debug` option)
935 	 * to use this option.
936 	 *
937 	 * Params:
938 	 *     showEvents = %TRUE to output event debugging information.
939 	 */
940 	public static void setShowEvents(bool showEvents)
941 	{
942 		gdk_set_show_events(showEvents);
943 	}
944 
945 	/**
946 	 * Obtains a desktop-wide setting, such as the double-click time,
947 	 * for the default screen. See gdk_screen_get_setting().
948 	 *
949 	 * Params:
950 	 *     name = the name of the setting.
951 	 *     value = location to store the value of the setting.
952 	 *
953 	 * Returns: %TRUE if the setting existed and a value was stored
954 	 *     in @value, %FALSE otherwise.
955 	 */
956 	public static bool settingGet(string name, Value value)
957 	{
958 		return gdk_setting_get(Str.toStringz(name), (value is null) ? null : value.getValueStruct()) != 0;
959 	}
960 }