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