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