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