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.Display; 26 27 private import gdk.AppLaunchContext; 28 private import gdk.Device; 29 private import gdk.DeviceManager; 30 private import gdk.Event; 31 private import gdk.MonitorG; 32 private import gdk.Screen; 33 private import gdk.Seat; 34 private import gdk.Window; 35 private import glib.ListG; 36 private import glib.Str; 37 private import gobject.ObjectG; 38 private import gobject.Signals; 39 private import gtkc.gdk; 40 public import gtkc.gdktypes; 41 private import std.algorithm; 42 43 44 /** 45 * #GdkDisplay objects purpose are two fold: 46 * 47 * - To manage and provide information about input devices (pointers and keyboards) 48 * 49 * - To manage and provide information about the available #GdkScreens 50 * 51 * GdkDisplay objects are the GDK representation of an X Display, 52 * which can be described as a workstation consisting of 53 * a keyboard, a pointing device (such as a mouse) and one or more 54 * screens. 55 * It is used to open and keep track of various GdkScreen objects 56 * currently instantiated by the application. It is also used to 57 * access the keyboard(s) and mouse pointer(s) of the display. 58 * 59 * Most of the input device handling has been factored out into 60 * the separate #GdkDeviceManager object. Every display has a 61 * device manager, which you can obtain using 62 * gdk_display_get_device_manager(). 63 */ 64 public class Display : ObjectG 65 { 66 /** the main Gtk struct */ 67 protected GdkDisplay* gdkDisplay; 68 69 /** Get the main Gtk struct */ 70 public GdkDisplay* getDisplayStruct() 71 { 72 return gdkDisplay; 73 } 74 75 /** the main Gtk struct as a void* */ 76 protected override void* getStruct() 77 { 78 return cast(void*)gdkDisplay; 79 } 80 81 protected override void setStruct(GObject* obj) 82 { 83 gdkDisplay = cast(GdkDisplay*)obj; 84 super.setStruct(obj); 85 } 86 87 /** 88 * Sets our main struct and passes it to the parent class. 89 */ 90 public this (GdkDisplay* gdkDisplay, bool ownedRef = false) 91 { 92 this.gdkDisplay = gdkDisplay; 93 super(cast(GObject*)gdkDisplay, ownedRef); 94 } 95 96 97 /** */ 98 public static GType getType() 99 { 100 return gdk_display_get_type(); 101 } 102 103 /** 104 * Gets the default #GdkDisplay. This is a convenience 105 * function for: 106 * `gdk_display_manager_get_default_display (gdk_display_manager_get ())`. 107 * 108 * Returns: a #GdkDisplay, or %NULL if 109 * there is no default display. 110 * 111 * Since: 2.2 112 */ 113 public static Display getDefault() 114 { 115 auto p = gdk_display_get_default(); 116 117 if(p is null) 118 { 119 return null; 120 } 121 122 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 123 } 124 125 /** 126 * Opens a display. 127 * 128 * Params: 129 * displayName = the name of the display to open 130 * 131 * Returns: a #GdkDisplay, or %NULL if the 132 * display could not be opened 133 * 134 * Since: 2.2 135 */ 136 public static Display open(string displayName) 137 { 138 auto p = gdk_display_open(Str.toStringz(displayName)); 139 140 if(p is null) 141 { 142 return null; 143 } 144 145 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 146 } 147 148 /** 149 * Opens the default display specified by command line arguments or 150 * environment variables, sets it as the default display, and returns 151 * it. gdk_parse_args() must have been called first. If the default 152 * display has previously been set, simply returns that. An internal 153 * function that should not be used by applications. 154 * 155 * Deprecated: This symbol was never meant to be used outside 156 * of GTK+ 157 * 158 * Returns: the default display, if it 159 * could be opened, otherwise %NULL. 160 */ 161 public static Display openDefaultLibgtkOnly() 162 { 163 auto p = gdk_display_open_default_libgtk_only(); 164 165 if(p is null) 166 { 167 return null; 168 } 169 170 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 171 } 172 173 /** 174 * Emits a short beep on @display 175 * 176 * Since: 2.2 177 */ 178 public void beep() 179 { 180 gdk_display_beep(gdkDisplay); 181 } 182 183 /** 184 * Closes the connection to the windowing system for the given display, 185 * and cleans up associated resources. 186 * 187 * Since: 2.2 188 */ 189 public void close() 190 { 191 gdk_display_close(gdkDisplay); 192 } 193 194 /** 195 * Returns %TRUE if there is an ongoing grab on @device for @display. 196 * 197 * Params: 198 * device = a #GdkDevice 199 * 200 * Returns: %TRUE if there is a grab in effect for @device. 201 */ 202 public bool deviceIsGrabbed(Device device) 203 { 204 return gdk_display_device_is_grabbed(gdkDisplay, (device is null) ? null : device.getDeviceStruct()) != 0; 205 } 206 207 /** 208 * Flushes any requests queued for the windowing system; this happens automatically 209 * when the main loop blocks waiting for new events, but if your application 210 * is drawing without returning control to the main loop, you may need 211 * to call this function explicitly. A common case where this function 212 * needs to be called is when an application is executing drawing commands 213 * from a thread other than the thread where the main loop is running. 214 * 215 * This is most useful for X11. On windowing systems where requests are 216 * handled synchronously, this function will do nothing. 217 * 218 * Since: 2.4 219 */ 220 public void flush() 221 { 222 gdk_display_flush(gdkDisplay); 223 } 224 225 /** 226 * Returns a #GdkAppLaunchContext suitable for launching 227 * applications on the given display. 228 * 229 * Returns: a new #GdkAppLaunchContext for @display. 230 * Free with g_object_unref() when done 231 * 232 * Since: 3.0 233 */ 234 public AppLaunchContext getAppLaunchContext() 235 { 236 auto p = gdk_display_get_app_launch_context(gdkDisplay); 237 238 if(p is null) 239 { 240 return null; 241 } 242 243 return ObjectG.getDObject!(AppLaunchContext)(cast(GdkAppLaunchContext*) p, true); 244 } 245 246 /** 247 * Returns the default size to use for cursors on @display. 248 * 249 * Returns: the default cursor size. 250 * 251 * Since: 2.4 252 */ 253 public uint getDefaultCursorSize() 254 { 255 return gdk_display_get_default_cursor_size(gdkDisplay); 256 } 257 258 /** 259 * Returns the default group leader window for all toplevel windows 260 * on @display. This window is implicitly created by GDK. 261 * See gdk_window_set_group(). 262 * 263 * Returns: The default group leader window 264 * for @display 265 * 266 * Since: 2.4 267 */ 268 public Window getDefaultGroup() 269 { 270 auto p = gdk_display_get_default_group(gdkDisplay); 271 272 if(p is null) 273 { 274 return null; 275 } 276 277 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 278 } 279 280 /** 281 * Get the default #GdkScreen for @display. 282 * 283 * Returns: the default #GdkScreen object for @display 284 * 285 * Since: 2.2 286 */ 287 public Screen getDefaultScreen() 288 { 289 auto p = gdk_display_get_default_screen(gdkDisplay); 290 291 if(p is null) 292 { 293 return null; 294 } 295 296 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 297 } 298 299 /** 300 * Returns the default #GdkSeat for this display. 301 * 302 * Returns: the default seat. 303 * 304 * Since: 3.20 305 */ 306 public Seat getDefaultSeat() 307 { 308 auto p = gdk_display_get_default_seat(gdkDisplay); 309 310 if(p is null) 311 { 312 return null; 313 } 314 315 return ObjectG.getDObject!(Seat)(cast(GdkSeat*) p); 316 } 317 318 /** 319 * Returns the #GdkDeviceManager associated to @display. 320 * 321 * Deprecated: Use gdk_display_get_default_seat() and #GdkSeat operations. 322 * 323 * Returns: A #GdkDeviceManager, or 324 * %NULL. This memory is owned by GDK and must not be freed 325 * or unreferenced. 326 * 327 * Since: 3.0 328 */ 329 public DeviceManager getDeviceManager() 330 { 331 auto p = gdk_display_get_device_manager(gdkDisplay); 332 333 if(p is null) 334 { 335 return null; 336 } 337 338 return ObjectG.getDObject!(DeviceManager)(cast(GdkDeviceManager*) p); 339 } 340 341 /** 342 * Gets the next #GdkEvent to be processed for @display, fetching events from the 343 * windowing system if necessary. 344 * 345 * Returns: the next #GdkEvent to be processed, or %NULL 346 * if no events are pending. The returned #GdkEvent should be freed 347 * with gdk_event_free(). 348 * 349 * Since: 2.2 350 */ 351 public Event getEvent() 352 { 353 auto p = gdk_display_get_event(gdkDisplay); 354 355 if(p is null) 356 { 357 return null; 358 } 359 360 return ObjectG.getDObject!(Event)(cast(GdkEvent*) p, true); 361 } 362 363 /** 364 * Gets the maximal size to use for cursors on @display. 365 * 366 * Params: 367 * width = the return location for the maximal cursor width 368 * height = the return location for the maximal cursor height 369 * 370 * Since: 2.4 371 */ 372 public void getMaximalCursorSize(out uint width, out uint height) 373 { 374 gdk_display_get_maximal_cursor_size(gdkDisplay, &width, &height); 375 } 376 377 /** 378 * Gets a monitor associated with this display. 379 * 380 * Params: 381 * monitorNum = number of the monitor 382 * 383 * Returns: the #GdkMonitor, or %NULL if 384 * @monitor_num is not a valid monitor number 385 * 386 * Since: 3.22 387 */ 388 public MonitorG getMonitor(int monitorNum) 389 { 390 auto p = gdk_display_get_monitor(gdkDisplay, monitorNum); 391 392 if(p is null) 393 { 394 return null; 395 } 396 397 return ObjectG.getDObject!(MonitorG)(cast(GdkMonitor*) p); 398 } 399 400 /** 401 * Gets the monitor in which the point (@x, @y) is located, 402 * or a nearby monitor if the point is not in any monitor. 403 * 404 * Params: 405 * x = the x coordinate of the point 406 * y = the y coordinate of the point 407 * 408 * Returns: the monitor containing the point 409 * 410 * Since: 3.22 411 */ 412 public MonitorG getMonitorAtPoint(int x, int y) 413 { 414 auto p = gdk_display_get_monitor_at_point(gdkDisplay, x, y); 415 416 if(p is null) 417 { 418 return null; 419 } 420 421 return ObjectG.getDObject!(MonitorG)(cast(GdkMonitor*) p); 422 } 423 424 /** 425 * Gets the monitor in which the largest area of @window 426 * resides, or a monitor close to @window if it is outside 427 * of all monitors. 428 * 429 * Params: 430 * window = a #GdkWindow 431 * 432 * Returns: the monitor with the largest overlap with @window 433 * 434 * Since: 3.22 435 */ 436 public MonitorG getMonitorAtWindow(Window window) 437 { 438 auto p = gdk_display_get_monitor_at_window(gdkDisplay, (window is null) ? null : window.getWindowStruct()); 439 440 if(p is null) 441 { 442 return null; 443 } 444 445 return ObjectG.getDObject!(MonitorG)(cast(GdkMonitor*) p); 446 } 447 448 /** 449 * Gets the number of monitors that belong to @display. 450 * 451 * The returned number is valid until the next emission of the 452 * #GdkDisplay::monitor-added or #GdkDisplay::monitor-removed signal. 453 * 454 * Returns: the number of monitors 455 * 456 * Since: 3.22 457 */ 458 public int getNMonitors() 459 { 460 return gdk_display_get_n_monitors(gdkDisplay); 461 } 462 463 /** 464 * Gets the number of screen managed by the @display. 465 * 466 * Deprecated: The number of screens is always 1. 467 * 468 * Returns: number of screens. 469 * 470 * Since: 2.2 471 */ 472 public int getNScreens() 473 { 474 return gdk_display_get_n_screens(gdkDisplay); 475 } 476 477 /** 478 * Gets the name of the display. 479 * 480 * Returns: a string representing the display name. This string is owned 481 * by GDK and should not be modified or freed. 482 * 483 * Since: 2.2 484 */ 485 public string getName() 486 { 487 return Str.toString(gdk_display_get_name(gdkDisplay)); 488 } 489 490 /** 491 * Gets the current location of the pointer and the current modifier 492 * mask for a given display. 493 * 494 * Deprecated: Use gdk_device_get_position() instead. 495 * 496 * Params: 497 * screen = location to store the screen that the 498 * cursor is on, or %NULL. 499 * x = location to store root window X coordinate of pointer, or %NULL. 500 * y = location to store root window Y coordinate of pointer, or %NULL. 501 * mask = location to store current modifier mask, or %NULL 502 * 503 * Since: 2.2 504 */ 505 public void getPointer(out Screen screen, out int x, out int y, out GdkModifierType mask) 506 { 507 GdkScreen* outscreen = null; 508 509 gdk_display_get_pointer(gdkDisplay, &outscreen, &x, &y, &mask); 510 511 screen = ObjectG.getDObject!(Screen)(outscreen); 512 } 513 514 /** 515 * Gets the primary monitor for the display. 516 * 517 * The primary monitor is considered the monitor where the “main desktop” 518 * lives. While normal application windows typically allow the window 519 * manager to place the windows, specialized desktop applications 520 * such as panels should place themselves on the primary monitor. 521 * 522 * Returns: the primary monitor, or %NULL if no primary 523 * monitor is configured by the user 524 * 525 * Since: 3.22 526 */ 527 public MonitorG getPrimaryMonitor() 528 { 529 auto p = gdk_display_get_primary_monitor(gdkDisplay); 530 531 if(p is null) 532 { 533 return null; 534 } 535 536 return ObjectG.getDObject!(MonitorG)(cast(GdkMonitor*) p); 537 } 538 539 /** 540 * Returns a screen object for one of the screens of the display. 541 * 542 * Deprecated: There is only one screen; use gdk_display_get_default_screen() to get it. 543 * 544 * Params: 545 * screenNum = the screen number 546 * 547 * Returns: the #GdkScreen object 548 * 549 * Since: 2.2 550 */ 551 public Screen getScreen(int screenNum) 552 { 553 auto p = gdk_display_get_screen(gdkDisplay, screenNum); 554 555 if(p is null) 556 { 557 return null; 558 } 559 560 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 561 } 562 563 /** 564 * Obtains the window underneath the mouse pointer, returning the location 565 * of the pointer in that window in @win_x, @win_y for @screen. Returns %NULL 566 * if the window under the mouse pointer is not known to GDK (for example, 567 * belongs to another application). 568 * 569 * Deprecated: Use gdk_device_get_window_at_position() instead. 570 * 571 * Params: 572 * winX = return location for x coordinate of the pointer location relative 573 * to the window origin, or %NULL 574 * winY = return location for y coordinate of the pointer location relative 575 * & to the window origin, or %NULL 576 * 577 * Returns: the window under the mouse 578 * pointer, or %NULL 579 * 580 * Since: 2.2 581 */ 582 public Window getWindowAtPointer(out int winX, out int winY) 583 { 584 auto p = gdk_display_get_window_at_pointer(gdkDisplay, &winX, &winY); 585 586 if(p is null) 587 { 588 return null; 589 } 590 591 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 592 } 593 594 /** 595 * Returns whether the display has events that are waiting 596 * to be processed. 597 * 598 * Returns: %TRUE if there are events ready to be processed. 599 * 600 * Since: 3.0 601 */ 602 public bool hasPending() 603 { 604 return gdk_display_has_pending(gdkDisplay) != 0; 605 } 606 607 /** 608 * Finds out if the display has been closed. 609 * 610 * Returns: %TRUE if the display is closed. 611 * 612 * Since: 2.22 613 */ 614 public bool isClosed() 615 { 616 return gdk_display_is_closed(gdkDisplay) != 0; 617 } 618 619 /** 620 * Release any keyboard grab 621 * 622 * Deprecated: Use gdk_device_ungrab(), together with gdk_device_grab() 623 * instead. 624 * 625 * Params: 626 * time = a timestap (e.g #GDK_CURRENT_TIME). 627 * 628 * Since: 2.2 629 */ 630 public void keyboardUngrab(uint time) 631 { 632 gdk_display_keyboard_ungrab(gdkDisplay, time); 633 } 634 635 /** 636 * Returns the list of available input devices attached to @display. 637 * The list is statically allocated and should not be freed. 638 * 639 * Deprecated: Use gdk_device_manager_list_devices() instead. 640 * 641 * Returns: a list of #GdkDevice 642 * 643 * Since: 2.2 644 */ 645 public ListG listDevices() 646 { 647 auto p = gdk_display_list_devices(gdkDisplay); 648 649 if(p is null) 650 { 651 return null; 652 } 653 654 return new ListG(cast(GList*) p); 655 } 656 657 /** 658 * Returns the list of seats known to @display. 659 * 660 * Returns: the 661 * list of seats known to the #GdkDisplay 662 * 663 * Since: 3.20 664 */ 665 public ListG listSeats() 666 { 667 auto p = gdk_display_list_seats(gdkDisplay); 668 669 if(p is null) 670 { 671 return null; 672 } 673 674 return new ListG(cast(GList*) p); 675 } 676 677 /** 678 * Indicates to the GUI environment that the application has 679 * finished loading, using a given identifier. 680 * 681 * GTK+ will call this function automatically for #GtkWindow 682 * with custom startup-notification identifier unless 683 * gtk_window_set_auto_startup_notification() is called to 684 * disable that feature. 685 * 686 * Params: 687 * startupId = a startup-notification identifier, for which 688 * notification process should be completed 689 * 690 * Since: 3.0 691 */ 692 public void notifyStartupComplete(string startupId) 693 { 694 gdk_display_notify_startup_complete(gdkDisplay, Str.toStringz(startupId)); 695 } 696 697 /** 698 * Gets a copy of the first #GdkEvent in the @display’s event queue, without 699 * removing the event from the queue. (Note that this function will 700 * not get more events from the windowing system. It only checks the events 701 * that have already been moved to the GDK event queue.) 702 * 703 * Returns: a copy of the first #GdkEvent on the event 704 * queue, or %NULL if no events are in the queue. The returned 705 * #GdkEvent should be freed with gdk_event_free(). 706 * 707 * Since: 2.2 708 */ 709 public Event peekEvent() 710 { 711 auto p = gdk_display_peek_event(gdkDisplay); 712 713 if(p is null) 714 { 715 return null; 716 } 717 718 return ObjectG.getDObject!(Event)(cast(GdkEvent*) p, true); 719 } 720 721 /** 722 * Test if the pointer is grabbed. 723 * 724 * Deprecated: Use gdk_display_device_is_grabbed() instead. 725 * 726 * Returns: %TRUE if an active X pointer grab is in effect 727 * 728 * Since: 2.2 729 */ 730 public bool pointerIsGrabbed() 731 { 732 return gdk_display_pointer_is_grabbed(gdkDisplay) != 0; 733 } 734 735 /** 736 * Release any pointer grab. 737 * 738 * Deprecated: Use gdk_device_ungrab(), together with gdk_device_grab() 739 * instead. 740 * 741 * Params: 742 * time = a timestap (e.g. %GDK_CURRENT_TIME). 743 * 744 * Since: 2.2 745 */ 746 public void pointerUngrab(uint time) 747 { 748 gdk_display_pointer_ungrab(gdkDisplay, time); 749 } 750 751 /** 752 * Appends a copy of the given event onto the front of the event 753 * queue for @display. 754 * 755 * Params: 756 * event = a #GdkEvent. 757 * 758 * Since: 2.2 759 */ 760 public void putEvent(Event event) 761 { 762 gdk_display_put_event(gdkDisplay, (event is null) ? null : event.getEventStruct()); 763 } 764 765 /** 766 * Request #GdkEventOwnerChange events for ownership changes 767 * of the selection named by the given atom. 768 * 769 * Params: 770 * selection = the #GdkAtom naming the selection for which 771 * ownership change notification is requested 772 * 773 * Returns: whether #GdkEventOwnerChange events will 774 * be sent. 775 * 776 * Since: 2.6 777 */ 778 public bool requestSelectionNotification(GdkAtom selection) 779 { 780 return gdk_display_request_selection_notification(gdkDisplay, selection) != 0; 781 } 782 783 /** 784 * Sets the double click distance (two clicks within this distance 785 * count as a double click and result in a #GDK_2BUTTON_PRESS event). 786 * See also gdk_display_set_double_click_time(). 787 * Applications should not set this, it is a global 788 * user-configured setting. 789 * 790 * Params: 791 * distance = distance in pixels 792 * 793 * Since: 2.4 794 */ 795 public void setDoubleClickDistance(uint distance) 796 { 797 gdk_display_set_double_click_distance(gdkDisplay, distance); 798 } 799 800 /** 801 * Sets the double click time (two clicks within this time interval 802 * count as a double click and result in a #GDK_2BUTTON_PRESS event). 803 * Applications should not set this, it is a global 804 * user-configured setting. 805 * 806 * Params: 807 * msec = double click time in milliseconds (thousandths of a second) 808 * 809 * Since: 2.2 810 */ 811 public void setDoubleClickTime(uint msec) 812 { 813 gdk_display_set_double_click_time(gdkDisplay, msec); 814 } 815 816 /** 817 * Issues a request to the clipboard manager to store the 818 * clipboard data. On X11, this is a special program that works 819 * according to the 820 * [FreeDesktop Clipboard Specification](http://www.freedesktop.org/Standards/clipboard-manager-spec). 821 * 822 * Params: 823 * clipboardWindow = a #GdkWindow belonging to the clipboard owner 824 * time = a timestamp 825 * targets = an array of targets 826 * that should be saved, or %NULL 827 * if all available targets should be saved. 828 * nTargets = length of the @targets array 829 * 830 * Since: 2.6 831 */ 832 public void storeClipboard(Window clipboardWindow, uint time, GdkAtom[] targets) 833 { 834 gdk_display_store_clipboard(gdkDisplay, (clipboardWindow is null) ? null : clipboardWindow.getWindowStruct(), time, targets.ptr, cast(int)targets.length); 835 } 836 837 /** 838 * Returns whether the speicifed display supports clipboard 839 * persistance; i.e. if it’s possible to store the clipboard data after an 840 * application has quit. On X11 this checks if a clipboard daemon is 841 * running. 842 * 843 * Returns: %TRUE if the display supports clipboard persistance. 844 * 845 * Since: 2.6 846 */ 847 public bool supportsClipboardPersistence() 848 { 849 return gdk_display_supports_clipboard_persistence(gdkDisplay) != 0; 850 } 851 852 /** 853 * Returns %TRUE if gdk_window_set_composited() can be used 854 * to redirect drawing on the window using compositing. 855 * 856 * Currently this only works on X11 with XComposite and 857 * XDamage extensions available. 858 * 859 * Deprecated: Compositing is an outdated technology that 860 * only ever worked on X11. 861 * 862 * Returns: %TRUE if windows may be composited. 863 * 864 * Since: 2.12 865 */ 866 public bool supportsComposite() 867 { 868 return gdk_display_supports_composite(gdkDisplay) != 0; 869 } 870 871 /** 872 * Returns %TRUE if cursors can use an 8bit alpha channel 873 * on @display. Otherwise, cursors are restricted to bilevel 874 * alpha (i.e. a mask). 875 * 876 * Returns: whether cursors can have alpha channels. 877 * 878 * Since: 2.4 879 */ 880 public bool supportsCursorAlpha() 881 { 882 return gdk_display_supports_cursor_alpha(gdkDisplay) != 0; 883 } 884 885 /** 886 * Returns %TRUE if multicolored cursors are supported 887 * on @display. Otherwise, cursors have only a forground 888 * and a background color. 889 * 890 * Returns: whether cursors can have multiple colors. 891 * 892 * Since: 2.4 893 */ 894 public bool supportsCursorColor() 895 { 896 return gdk_display_supports_cursor_color(gdkDisplay) != 0; 897 } 898 899 /** 900 * Returns %TRUE if gdk_window_input_shape_combine_mask() can 901 * be used to modify the input shape of windows on @display. 902 * 903 * Returns: %TRUE if windows with modified input shape are supported 904 * 905 * Since: 2.10 906 */ 907 public bool supportsInputShapes() 908 { 909 return gdk_display_supports_input_shapes(gdkDisplay) != 0; 910 } 911 912 /** 913 * Returns whether #GdkEventOwnerChange events will be 914 * sent when the owner of a selection changes. 915 * 916 * Returns: whether #GdkEventOwnerChange events will 917 * be sent. 918 * 919 * Since: 2.6 920 */ 921 public bool supportsSelectionNotification() 922 { 923 return gdk_display_supports_selection_notification(gdkDisplay) != 0; 924 } 925 926 /** 927 * Returns %TRUE if gdk_window_shape_combine_mask() can 928 * be used to create shaped windows on @display. 929 * 930 * Returns: %TRUE if shaped windows are supported 931 * 932 * Since: 2.10 933 */ 934 public bool supportsShapes() 935 { 936 return gdk_display_supports_shapes(gdkDisplay) != 0; 937 } 938 939 /** 940 * Flushes any requests queued for the windowing system and waits until all 941 * requests have been handled. This is often used for making sure that the 942 * display is synchronized with the current state of the program. Calling 943 * gdk_display_sync() before gdk_error_trap_pop() makes sure that any errors 944 * generated from earlier requests are handled before the error trap is 945 * removed. 946 * 947 * This is most useful for X11. On windowing systems where requests are 948 * handled synchronously, this function will do nothing. 949 * 950 * Since: 2.2 951 */ 952 public void sync() 953 { 954 gdk_display_sync(gdkDisplay); 955 } 956 957 /** 958 * Warps the pointer of @display to the point @x,@y on 959 * the screen @screen, unless the pointer is confined 960 * to a window by a grab, in which case it will be moved 961 * as far as allowed by the grab. Warping the pointer 962 * creates events as if the user had moved the mouse 963 * instantaneously to the destination. 964 * 965 * Note that the pointer should normally be under the 966 * control of the user. This function was added to cover 967 * some rare use cases like keyboard navigation support 968 * for the color picker in the #GtkColorSelectionDialog. 969 * 970 * Deprecated: Use gdk_device_warp() instead. 971 * 972 * Params: 973 * screen = the screen of @display to warp the pointer to 974 * x = the x coordinate of the destination 975 * y = the y coordinate of the destination 976 * 977 * Since: 2.8 978 */ 979 public void warpPointer(Screen screen, int x, int y) 980 { 981 gdk_display_warp_pointer(gdkDisplay, (screen is null) ? null : screen.getScreenStruct(), x, y); 982 } 983 984 protected class OnClosedDelegateWrapper 985 { 986 static OnClosedDelegateWrapper[] listeners; 987 void delegate(bool, Display) dlg; 988 gulong handlerId; 989 990 this(void delegate(bool, Display) dlg) 991 { 992 this.dlg = dlg; 993 this.listeners ~= this; 994 } 995 996 void remove(OnClosedDelegateWrapper source) 997 { 998 foreach(index, wrapper; listeners) 999 { 1000 if (wrapper.handlerId == source.handlerId) 1001 { 1002 listeners[index] = null; 1003 listeners = std.algorithm.remove(listeners, index); 1004 break; 1005 } 1006 } 1007 } 1008 } 1009 1010 /** 1011 * The ::closed signal is emitted when the connection to the windowing 1012 * system for @display is closed. 1013 * 1014 * Params: 1015 * isError = %TRUE if the display was closed due to an error 1016 * 1017 * Since: 2.2 1018 */ 1019 gulong addOnClosed(void delegate(bool, Display) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1020 { 1021 auto wrapper = new OnClosedDelegateWrapper(dlg); 1022 wrapper.handlerId = Signals.connectData( 1023 this, 1024 "closed", 1025 cast(GCallback)&callBackClosed, 1026 cast(void*)wrapper, 1027 cast(GClosureNotify)&callBackClosedDestroy, 1028 connectFlags); 1029 return wrapper.handlerId; 1030 } 1031 1032 extern(C) static void callBackClosed(GdkDisplay* displayStruct, bool isError, OnClosedDelegateWrapper wrapper) 1033 { 1034 wrapper.dlg(isError, wrapper.outer); 1035 } 1036 1037 extern(C) static void callBackClosedDestroy(OnClosedDelegateWrapper wrapper, GClosure* closure) 1038 { 1039 wrapper.remove(wrapper); 1040 } 1041 1042 protected class OnMonitorAddedDelegateWrapper 1043 { 1044 static OnMonitorAddedDelegateWrapper[] listeners; 1045 void delegate(MonitorG, Display) dlg; 1046 gulong handlerId; 1047 1048 this(void delegate(MonitorG, Display) dlg) 1049 { 1050 this.dlg = dlg; 1051 this.listeners ~= this; 1052 } 1053 1054 void remove(OnMonitorAddedDelegateWrapper source) 1055 { 1056 foreach(index, wrapper; listeners) 1057 { 1058 if (wrapper.handlerId == source.handlerId) 1059 { 1060 listeners[index] = null; 1061 listeners = std.algorithm.remove(listeners, index); 1062 break; 1063 } 1064 } 1065 } 1066 } 1067 1068 /** 1069 * The ::monitor-added signal is emitted whenever a monitor is 1070 * added. 1071 * 1072 * Params: 1073 * monitor = the monitor that was just added 1074 * 1075 * Since: 3.22 1076 */ 1077 gulong addOnMonitorAdded(void delegate(MonitorG, Display) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1078 { 1079 auto wrapper = new OnMonitorAddedDelegateWrapper(dlg); 1080 wrapper.handlerId = Signals.connectData( 1081 this, 1082 "monitor-added", 1083 cast(GCallback)&callBackMonitorAdded, 1084 cast(void*)wrapper, 1085 cast(GClosureNotify)&callBackMonitorAddedDestroy, 1086 connectFlags); 1087 return wrapper.handlerId; 1088 } 1089 1090 extern(C) static void callBackMonitorAdded(GdkDisplay* displayStruct, GdkMonitor* monitor, OnMonitorAddedDelegateWrapper wrapper) 1091 { 1092 wrapper.dlg(ObjectG.getDObject!(MonitorG)(monitor), wrapper.outer); 1093 } 1094 1095 extern(C) static void callBackMonitorAddedDestroy(OnMonitorAddedDelegateWrapper wrapper, GClosure* closure) 1096 { 1097 wrapper.remove(wrapper); 1098 } 1099 1100 protected class OnMonitorRemovedDelegateWrapper 1101 { 1102 static OnMonitorRemovedDelegateWrapper[] listeners; 1103 void delegate(MonitorG, Display) dlg; 1104 gulong handlerId; 1105 1106 this(void delegate(MonitorG, Display) dlg) 1107 { 1108 this.dlg = dlg; 1109 this.listeners ~= this; 1110 } 1111 1112 void remove(OnMonitorRemovedDelegateWrapper source) 1113 { 1114 foreach(index, wrapper; listeners) 1115 { 1116 if (wrapper.handlerId == source.handlerId) 1117 { 1118 listeners[index] = null; 1119 listeners = std.algorithm.remove(listeners, index); 1120 break; 1121 } 1122 } 1123 } 1124 } 1125 1126 /** 1127 * The ::monitor-removed signal is emitted whenever a monitor is 1128 * removed. 1129 * 1130 * Params: 1131 * monitor = the monitor that was just removed 1132 * 1133 * Since: 3.22 1134 */ 1135 gulong addOnMonitorRemoved(void delegate(MonitorG, Display) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1136 { 1137 auto wrapper = new OnMonitorRemovedDelegateWrapper(dlg); 1138 wrapper.handlerId = Signals.connectData( 1139 this, 1140 "monitor-removed", 1141 cast(GCallback)&callBackMonitorRemoved, 1142 cast(void*)wrapper, 1143 cast(GClosureNotify)&callBackMonitorRemovedDestroy, 1144 connectFlags); 1145 return wrapper.handlerId; 1146 } 1147 1148 extern(C) static void callBackMonitorRemoved(GdkDisplay* displayStruct, GdkMonitor* monitor, OnMonitorRemovedDelegateWrapper wrapper) 1149 { 1150 wrapper.dlg(ObjectG.getDObject!(MonitorG)(monitor), wrapper.outer); 1151 } 1152 1153 extern(C) static void callBackMonitorRemovedDestroy(OnMonitorRemovedDelegateWrapper wrapper, GClosure* closure) 1154 { 1155 wrapper.remove(wrapper); 1156 } 1157 1158 protected class OnOpenedDelegateWrapper 1159 { 1160 static OnOpenedDelegateWrapper[] listeners; 1161 void delegate(Display) dlg; 1162 gulong handlerId; 1163 1164 this(void delegate(Display) dlg) 1165 { 1166 this.dlg = dlg; 1167 this.listeners ~= this; 1168 } 1169 1170 void remove(OnOpenedDelegateWrapper source) 1171 { 1172 foreach(index, wrapper; listeners) 1173 { 1174 if (wrapper.handlerId == source.handlerId) 1175 { 1176 listeners[index] = null; 1177 listeners = std.algorithm.remove(listeners, index); 1178 break; 1179 } 1180 } 1181 } 1182 } 1183 1184 /** 1185 * The ::opened signal is emitted when the connection to the windowing 1186 * system for @display is opened. 1187 */ 1188 gulong addOnOpened(void delegate(Display) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1189 { 1190 auto wrapper = new OnOpenedDelegateWrapper(dlg); 1191 wrapper.handlerId = Signals.connectData( 1192 this, 1193 "opened", 1194 cast(GCallback)&callBackOpened, 1195 cast(void*)wrapper, 1196 cast(GClosureNotify)&callBackOpenedDestroy, 1197 connectFlags); 1198 return wrapper.handlerId; 1199 } 1200 1201 extern(C) static void callBackOpened(GdkDisplay* displayStruct, OnOpenedDelegateWrapper wrapper) 1202 { 1203 wrapper.dlg(wrapper.outer); 1204 } 1205 1206 extern(C) static void callBackOpenedDestroy(OnOpenedDelegateWrapper wrapper, GClosure* closure) 1207 { 1208 wrapper.remove(wrapper); 1209 } 1210 1211 protected class OnSeatAddedDelegateWrapper 1212 { 1213 static OnSeatAddedDelegateWrapper[] listeners; 1214 void delegate(Seat, Display) dlg; 1215 gulong handlerId; 1216 1217 this(void delegate(Seat, Display) dlg) 1218 { 1219 this.dlg = dlg; 1220 this.listeners ~= this; 1221 } 1222 1223 void remove(OnSeatAddedDelegateWrapper source) 1224 { 1225 foreach(index, wrapper; listeners) 1226 { 1227 if (wrapper.handlerId == source.handlerId) 1228 { 1229 listeners[index] = null; 1230 listeners = std.algorithm.remove(listeners, index); 1231 break; 1232 } 1233 } 1234 } 1235 } 1236 1237 /** 1238 * The ::seat-added signal is emitted whenever a new seat is made 1239 * known to the windowing system. 1240 * 1241 * Params: 1242 * seat = the seat that was just added 1243 * 1244 * Since: 3.20 1245 */ 1246 gulong addOnSeatAdded(void delegate(Seat, Display) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1247 { 1248 auto wrapper = new OnSeatAddedDelegateWrapper(dlg); 1249 wrapper.handlerId = Signals.connectData( 1250 this, 1251 "seat-added", 1252 cast(GCallback)&callBackSeatAdded, 1253 cast(void*)wrapper, 1254 cast(GClosureNotify)&callBackSeatAddedDestroy, 1255 connectFlags); 1256 return wrapper.handlerId; 1257 } 1258 1259 extern(C) static void callBackSeatAdded(GdkDisplay* displayStruct, GdkSeat* seat, OnSeatAddedDelegateWrapper wrapper) 1260 { 1261 wrapper.dlg(ObjectG.getDObject!(Seat)(seat), wrapper.outer); 1262 } 1263 1264 extern(C) static void callBackSeatAddedDestroy(OnSeatAddedDelegateWrapper wrapper, GClosure* closure) 1265 { 1266 wrapper.remove(wrapper); 1267 } 1268 1269 protected class OnSeatRemovedDelegateWrapper 1270 { 1271 static OnSeatRemovedDelegateWrapper[] listeners; 1272 void delegate(Seat, Display) dlg; 1273 gulong handlerId; 1274 1275 this(void delegate(Seat, Display) dlg) 1276 { 1277 this.dlg = dlg; 1278 this.listeners ~= this; 1279 } 1280 1281 void remove(OnSeatRemovedDelegateWrapper source) 1282 { 1283 foreach(index, wrapper; listeners) 1284 { 1285 if (wrapper.handlerId == source.handlerId) 1286 { 1287 listeners[index] = null; 1288 listeners = std.algorithm.remove(listeners, index); 1289 break; 1290 } 1291 } 1292 } 1293 } 1294 1295 /** 1296 * The ::seat-removed signal is emitted whenever a seat is removed 1297 * by the windowing system. 1298 * 1299 * Params: 1300 * seat = the seat that was just removed 1301 * 1302 * Since: 3.20 1303 */ 1304 gulong addOnSeatRemoved(void delegate(Seat, Display) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1305 { 1306 auto wrapper = new OnSeatRemovedDelegateWrapper(dlg); 1307 wrapper.handlerId = Signals.connectData( 1308 this, 1309 "seat-removed", 1310 cast(GCallback)&callBackSeatRemoved, 1311 cast(void*)wrapper, 1312 cast(GClosureNotify)&callBackSeatRemovedDestroy, 1313 connectFlags); 1314 return wrapper.handlerId; 1315 } 1316 1317 extern(C) static void callBackSeatRemoved(GdkDisplay* displayStruct, GdkSeat* seat, OnSeatRemovedDelegateWrapper wrapper) 1318 { 1319 wrapper.dlg(ObjectG.getDObject!(Seat)(seat), wrapper.outer); 1320 } 1321 1322 extern(C) static void callBackSeatRemovedDestroy(OnSeatRemovedDelegateWrapper wrapper, GClosure* closure) 1323 { 1324 wrapper.remove(wrapper); 1325 } 1326 }