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.Screen; 26 27 private import cairo.FontOption; 28 private import gdk.Display; 29 private import gdk.Visual; 30 private import gdk.Window; 31 private import gdk.c.functions; 32 public import gdk.c.types; 33 private import glib.ListG; 34 private import glib.Str; 35 private import gobject.ObjectG; 36 private import gobject.Signals; 37 private import gobject.Value; 38 public import gtkc.gdktypes; 39 private import std.algorithm; 40 41 42 /** 43 * #GdkScreen objects are the GDK representation of the screen on 44 * which windows can be displayed and on which the pointer moves. 45 * X originally identified screens with physical screens, but 46 * nowadays it is more common to have a single #GdkScreen which 47 * combines several physical monitors (see gdk_screen_get_n_monitors()). 48 * 49 * GdkScreen is used throughout GDK and GTK+ to specify which screen 50 * the top level windows are to be displayed on. it is also used to 51 * query the screen specification and default settings such as 52 * the default visual (gdk_screen_get_system_visual()), the dimensions 53 * of the physical monitors (gdk_screen_get_monitor_geometry()), etc. 54 */ 55 public class Screen : ObjectG 56 { 57 /** the main Gtk struct */ 58 protected GdkScreen* gdkScreen; 59 60 /** Get the main Gtk struct */ 61 public GdkScreen* getScreenStruct(bool transferOwnership = false) 62 { 63 if (transferOwnership) 64 ownedRef = false; 65 return gdkScreen; 66 } 67 68 /** the main Gtk struct as a void* */ 69 protected override void* getStruct() 70 { 71 return cast(void*)gdkScreen; 72 } 73 74 protected override void setStruct(GObject* obj) 75 { 76 gdkScreen = cast(GdkScreen*)obj; 77 super.setStruct(obj); 78 } 79 80 /** 81 * Sets our main struct and passes it to the parent class. 82 */ 83 public this (GdkScreen* gdkScreen, bool ownedRef = false) 84 { 85 this.gdkScreen = gdkScreen; 86 super(cast(GObject*)gdkScreen, ownedRef); 87 } 88 89 90 /** */ 91 public static GType getType() 92 { 93 return gdk_screen_get_type(); 94 } 95 96 /** 97 * Gets the default screen for the default display. (See 98 * gdk_display_get_default ()). 99 * 100 * Returns: a #GdkScreen, or %NULL if 101 * there is no default display. 102 * 103 * Since: 2.2 104 */ 105 public static Screen getDefault() 106 { 107 auto p = gdk_screen_get_default(); 108 109 if(p is null) 110 { 111 return null; 112 } 113 114 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 115 } 116 117 /** 118 * Gets the height of the default screen in pixels. The returned 119 * size is in ”application pixels”, not in ”device pixels” (see 120 * gdk_screen_get_monitor_scale_factor()). 121 * 122 * Deprecated: Use per-monitor information 123 * 124 * Returns: the height of the default screen in pixels. 125 */ 126 public static int height() 127 { 128 return gdk_screen_height(); 129 } 130 131 /** 132 * Returns the height of the default screen in millimeters. 133 * Note that on many X servers this value will not be correct. 134 * 135 * Deprecated: Use per-monitor information 136 * 137 * Returns: the height of the default screen in millimeters, 138 * though it is not always correct. 139 */ 140 public static int heightMm() 141 { 142 return gdk_screen_height_mm(); 143 } 144 145 /** 146 * Gets the width of the default screen in pixels. The returned 147 * size is in ”application pixels”, not in ”device pixels” (see 148 * gdk_screen_get_monitor_scale_factor()). 149 * 150 * Deprecated: Use per-monitor information 151 * 152 * Returns: the width of the default screen in pixels. 153 */ 154 public static int width() 155 { 156 return gdk_screen_width(); 157 } 158 159 /** 160 * Returns the width of the default screen in millimeters. 161 * Note that on many X servers this value will not be correct. 162 * 163 * Deprecated: Use per-monitor information 164 * 165 * Returns: the width of the default screen in millimeters, 166 * though it is not always correct. 167 */ 168 public static int widthMm() 169 { 170 return gdk_screen_width_mm(); 171 } 172 173 /** 174 * Returns the screen’s currently active window. 175 * 176 * On X11, this is done by inspecting the _NET_ACTIVE_WINDOW property 177 * on the root window, as described in the 178 * [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec). 179 * If there is no currently currently active 180 * window, or the window manager does not support the 181 * _NET_ACTIVE_WINDOW hint, this function returns %NULL. 182 * 183 * On other platforms, this function may return %NULL, depending on whether 184 * it is implementable on that platform. 185 * 186 * The returned window should be unrefed using g_object_unref() when 187 * no longer needed. 188 * 189 * Returns: the currently active window, 190 * or %NULL. 191 * 192 * Since: 2.10 193 */ 194 public Window getActiveWindow() 195 { 196 auto p = gdk_screen_get_active_window(gdkScreen); 197 198 if(p is null) 199 { 200 return null; 201 } 202 203 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p, true); 204 } 205 206 /** 207 * Gets the display to which the @screen belongs. 208 * 209 * Returns: the display to which @screen belongs 210 * 211 * Since: 2.2 212 */ 213 public Display getDisplay() 214 { 215 auto p = gdk_screen_get_display(gdkScreen); 216 217 if(p is null) 218 { 219 return null; 220 } 221 222 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 223 } 224 225 /** 226 * Gets any options previously set with gdk_screen_set_font_options(). 227 * 228 * Returns: the current font options, or %NULL if no 229 * default font options have been set. 230 * 231 * Since: 2.10 232 */ 233 public FontOption getFontOptions() 234 { 235 auto p = gdk_screen_get_font_options(gdkScreen); 236 237 if(p is null) 238 { 239 return null; 240 } 241 242 return new FontOption(cast(cairo_font_options_t*) p); 243 } 244 245 /** 246 * Gets the height of @screen in pixels. The returned size is in 247 * ”application pixels”, not in ”device pixels” (see 248 * gdk_screen_get_monitor_scale_factor()). 249 * 250 * Deprecated: Use per-monitor information instead 251 * 252 * Returns: the height of @screen in pixels. 253 * 254 * Since: 2.2 255 */ 256 public int getHeight() 257 { 258 return gdk_screen_get_height(gdkScreen); 259 } 260 261 /** 262 * Returns the height of @screen in millimeters. 263 * 264 * Note that this value is somewhat ill-defined when the screen 265 * has multiple monitors of different resolution. It is recommended 266 * to use the monitor dimensions instead. 267 * 268 * Deprecated: Use per-monitor information instead 269 * 270 * Returns: the heigth of @screen in millimeters. 271 * 272 * Since: 2.2 273 */ 274 public int getHeightMm() 275 { 276 return gdk_screen_get_height_mm(gdkScreen); 277 } 278 279 /** 280 * Returns the monitor number in which the point (@x,@y) is located. 281 * 282 * Deprecated: Use gdk_display_get_monitor_at_point() instead 283 * 284 * Params: 285 * x = the x coordinate in the virtual screen. 286 * y = the y coordinate in the virtual screen. 287 * 288 * Returns: the monitor number in which the point (@x,@y) lies, or 289 * a monitor close to (@x,@y) if the point is not in any monitor. 290 * 291 * Since: 2.2 292 */ 293 public int getMonitorAtPoint(int x, int y) 294 { 295 return gdk_screen_get_monitor_at_point(gdkScreen, x, y); 296 } 297 298 /** 299 * Returns the number of the monitor in which the largest area of the 300 * bounding rectangle of @window resides. 301 * 302 * Deprecated: Use gdk_display_get_monitor_at_window() instead 303 * 304 * Params: 305 * window = a #GdkWindow 306 * 307 * Returns: the monitor number in which most of @window is located, 308 * or if @window does not intersect any monitors, a monitor, 309 * close to @window. 310 * 311 * Since: 2.2 312 */ 313 public int getMonitorAtWindow(Window window) 314 { 315 return gdk_screen_get_monitor_at_window(gdkScreen, (window is null) ? null : window.getWindowStruct()); 316 } 317 318 /** 319 * Retrieves the #GdkRectangle representing the size and position of 320 * the individual monitor within the entire screen area. The returned 321 * geometry is in ”application pixels”, not in ”device pixels” (see 322 * gdk_screen_get_monitor_scale_factor()). 323 * 324 * Monitor numbers start at 0. To obtain the number of monitors of 325 * @screen, use gdk_screen_get_n_monitors(). 326 * 327 * Note that the size of the entire screen area can be retrieved via 328 * gdk_screen_get_width() and gdk_screen_get_height(). 329 * 330 * Deprecated: Use gdk_monitor_get_geometry() instead 331 * 332 * Params: 333 * monitorNum = the monitor number 334 * dest = a #GdkRectangle to be filled with 335 * the monitor geometry 336 * 337 * Since: 2.2 338 */ 339 public void getMonitorGeometry(int monitorNum, out GdkRectangle dest) 340 { 341 gdk_screen_get_monitor_geometry(gdkScreen, monitorNum, &dest); 342 } 343 344 /** 345 * Gets the height in millimeters of the specified monitor. 346 * 347 * Deprecated: Use gdk_monitor_get_height_mm() instead 348 * 349 * Params: 350 * monitorNum = number of the monitor, between 0 and gdk_screen_get_n_monitors (screen) 351 * 352 * Returns: the height of the monitor, or -1 if not available 353 * 354 * Since: 2.14 355 */ 356 public int getMonitorHeightMm(int monitorNum) 357 { 358 return gdk_screen_get_monitor_height_mm(gdkScreen, monitorNum); 359 } 360 361 /** 362 * Returns the output name of the specified monitor. 363 * Usually something like VGA, DVI, or TV, not the actual 364 * product name of the display device. 365 * 366 * Deprecated: Use gdk_monitor_get_model() instead 367 * 368 * Params: 369 * monitorNum = number of the monitor, between 0 and gdk_screen_get_n_monitors (screen) 370 * 371 * Returns: a newly-allocated string containing the name 372 * of the monitor, or %NULL if the name cannot be determined 373 * 374 * Since: 2.14 375 */ 376 public string getMonitorPlugName(int monitorNum) 377 { 378 auto retStr = gdk_screen_get_monitor_plug_name(gdkScreen, monitorNum); 379 380 scope(exit) Str.freeString(retStr); 381 return Str.toString(retStr); 382 } 383 384 /** 385 * Returns the internal scale factor that maps from monitor coordinates 386 * to the actual device pixels. On traditional systems this is 1, but 387 * on very high density outputs this can be a higher value (often 2). 388 * 389 * This can be used if you want to create pixel based data for a 390 * particular monitor, but most of the time you’re drawing to a window 391 * where it is better to use gdk_window_get_scale_factor() instead. 392 * 393 * Deprecated: Use gdk_monitor_get_scale_factor() instead 394 * 395 * Params: 396 * monitorNum = number of the monitor, between 0 and gdk_screen_get_n_monitors (screen) 397 * 398 * Returns: the scale factor 399 * 400 * Since: 3.10 401 */ 402 public int getMonitorScaleFactor(int monitorNum) 403 { 404 return gdk_screen_get_monitor_scale_factor(gdkScreen, monitorNum); 405 } 406 407 /** 408 * Gets the width in millimeters of the specified monitor, if available. 409 * 410 * Deprecated: Use gdk_monitor_get_width_mm() instead 411 * 412 * Params: 413 * monitorNum = number of the monitor, between 0 and gdk_screen_get_n_monitors (screen) 414 * 415 * Returns: the width of the monitor, or -1 if not available 416 * 417 * Since: 2.14 418 */ 419 public int getMonitorWidthMm(int monitorNum) 420 { 421 return gdk_screen_get_monitor_width_mm(gdkScreen, monitorNum); 422 } 423 424 /** 425 * Retrieves the #GdkRectangle representing the size and position of 426 * the “work area” on a monitor within the entire screen area. The returned 427 * geometry is in ”application pixels”, not in ”device pixels” (see 428 * gdk_screen_get_monitor_scale_factor()). 429 * 430 * The work area should be considered when positioning menus and 431 * similar popups, to avoid placing them below panels, docks or other 432 * desktop components. 433 * 434 * Note that not all backends may have a concept of workarea. This 435 * function will return the monitor geometry if a workarea is not 436 * available, or does not apply. 437 * 438 * Monitor numbers start at 0. To obtain the number of monitors of 439 * @screen, use gdk_screen_get_n_monitors(). 440 * 441 * Deprecated: Use gdk_monitor_get_workarea() instead 442 * 443 * Params: 444 * monitorNum = the monitor number 445 * dest = a #GdkRectangle to be filled with 446 * the monitor workarea 447 * 448 * Since: 3.4 449 */ 450 public void getMonitorWorkarea(int monitorNum, out GdkRectangle dest) 451 { 452 gdk_screen_get_monitor_workarea(gdkScreen, monitorNum, &dest); 453 } 454 455 /** 456 * Returns the number of monitors which @screen consists of. 457 * 458 * Deprecated: Use gdk_display_get_n_monitors() instead 459 * 460 * Returns: number of monitors which @screen consists of 461 * 462 * Since: 2.2 463 */ 464 public int getNMonitors() 465 { 466 return gdk_screen_get_n_monitors(gdkScreen); 467 } 468 469 /** 470 * Gets the index of @screen among the screens in the display 471 * to which it belongs. (See gdk_screen_get_display()) 472 * 473 * Returns: the index 474 * 475 * Since: 2.2 476 */ 477 public int getNumber() 478 { 479 return gdk_screen_get_number(gdkScreen); 480 } 481 482 /** 483 * Gets the primary monitor for @screen. The primary monitor 484 * is considered the monitor where the “main desktop” lives. 485 * While normal application windows typically allow the window 486 * manager to place the windows, specialized desktop applications 487 * such as panels should place themselves on the primary monitor. 488 * 489 * If no primary monitor is configured by the user, the return value 490 * will be 0, defaulting to the first monitor. 491 * 492 * Deprecated: Use gdk_display_get_primary_monitor() instead 493 * 494 * Returns: An integer index for the primary monitor, or 0 if none is configured. 495 * 496 * Since: 2.20 497 */ 498 public int getPrimaryMonitor() 499 { 500 return gdk_screen_get_primary_monitor(gdkScreen); 501 } 502 503 /** 504 * Gets the resolution for font handling on the screen; see 505 * gdk_screen_set_resolution() for full details. 506 * 507 * Returns: the current resolution, or -1 if no resolution 508 * has been set. 509 * 510 * Since: 2.10 511 */ 512 public double getResolution() 513 { 514 return gdk_screen_get_resolution(gdkScreen); 515 } 516 517 /** 518 * Gets a visual to use for creating windows with an alpha channel. 519 * The windowing system on which GTK+ is running 520 * may not support this capability, in which case %NULL will 521 * be returned. Even if a non-%NULL value is returned, its 522 * possible that the window’s alpha channel won’t be honored 523 * when displaying the window on the screen: in particular, for 524 * X an appropriate windowing manager and compositing manager 525 * must be running to provide appropriate display. 526 * 527 * This functionality is not implemented in the Windows backend. 528 * 529 * For setting an overall opacity for a top-level window, see 530 * gdk_window_set_opacity(). 531 * 532 * Returns: a visual to use for windows 533 * with an alpha channel or %NULL if the capability is not 534 * available. 535 * 536 * Since: 2.8 537 */ 538 public Visual getRgbaVisual() 539 { 540 auto p = gdk_screen_get_rgba_visual(gdkScreen); 541 542 if(p is null) 543 { 544 return null; 545 } 546 547 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 548 } 549 550 /** 551 * Gets the root window of @screen. 552 * 553 * Returns: the root window 554 * 555 * Since: 2.2 556 */ 557 public Window getRootWindow() 558 { 559 auto p = gdk_screen_get_root_window(gdkScreen); 560 561 if(p is null) 562 { 563 return null; 564 } 565 566 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 567 } 568 569 /** 570 * Retrieves a desktop-wide setting such as double-click time 571 * for the #GdkScreen @screen. 572 * 573 * FIXME needs a list of valid settings here, or a link to 574 * more information. 575 * 576 * Params: 577 * name = the name of the setting 578 * value = location to store the value of the setting 579 * 580 * Returns: %TRUE if the setting existed and a value was stored 581 * in @value, %FALSE otherwise. 582 * 583 * Since: 2.2 584 */ 585 public bool getSetting(string name, Value value) 586 { 587 return gdk_screen_get_setting(gdkScreen, Str.toStringz(name), (value is null) ? null : value.getValueStruct()) != 0; 588 } 589 590 /** 591 * Get the system’s default visual for @screen. 592 * This is the visual for the root window of the display. 593 * The return value should not be freed. 594 * 595 * Returns: the system visual 596 * 597 * Since: 2.2 598 */ 599 public Visual getSystemVisual() 600 { 601 auto p = gdk_screen_get_system_visual(gdkScreen); 602 603 if(p is null) 604 { 605 return null; 606 } 607 608 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 609 } 610 611 /** 612 * Obtains a list of all toplevel windows known to GDK on the screen @screen. 613 * A toplevel window is a child of the root window (see 614 * gdk_get_default_root_window()). 615 * 616 * The returned list should be freed with g_list_free(), but 617 * its elements need not be freed. 618 * 619 * Returns: list of toplevel windows, free with g_list_free() 620 * 621 * Since: 2.2 622 */ 623 public ListG getToplevelWindows() 624 { 625 auto p = gdk_screen_get_toplevel_windows(gdkScreen); 626 627 if(p is null) 628 { 629 return null; 630 } 631 632 return new ListG(cast(GList*) p); 633 } 634 635 /** 636 * Gets the width of @screen in pixels. The returned size is in 637 * ”application pixels”, not in ”device pixels” (see 638 * gdk_screen_get_monitor_scale_factor()). 639 * 640 * Deprecated: Use per-monitor information instead 641 * 642 * Returns: the width of @screen in pixels. 643 * 644 * Since: 2.2 645 */ 646 public int getWidth() 647 { 648 return gdk_screen_get_width(gdkScreen); 649 } 650 651 /** 652 * Gets the width of @screen in millimeters. 653 * 654 * Note that this value is somewhat ill-defined when the screen 655 * has multiple monitors of different resolution. It is recommended 656 * to use the monitor dimensions instead. 657 * 658 * Deprecated: Use per-monitor information instead 659 * 660 * Returns: the width of @screen in millimeters. 661 * 662 * Since: 2.2 663 */ 664 public int getWidthMm() 665 { 666 return gdk_screen_get_width_mm(gdkScreen); 667 } 668 669 /** 670 * Returns a #GList of #GdkWindows representing the current 671 * window stack. 672 * 673 * On X11, this is done by inspecting the _NET_CLIENT_LIST_STACKING 674 * property on the root window, as described in the 675 * [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec). 676 * If the window manager does not support the 677 * _NET_CLIENT_LIST_STACKING hint, this function returns %NULL. 678 * 679 * On other platforms, this function may return %NULL, depending on whether 680 * it is implementable on that platform. 681 * 682 * The returned list is newly allocated and owns references to the 683 * windows it contains, so it should be freed using g_list_free() and 684 * its windows unrefed using g_object_unref() when no longer needed. 685 * 686 * Returns: a 687 * list of #GdkWindows for the current window stack, or %NULL. 688 * 689 * Since: 2.10 690 */ 691 public ListG getWindowStack() 692 { 693 auto p = gdk_screen_get_window_stack(gdkScreen); 694 695 if(p is null) 696 { 697 return null; 698 } 699 700 return new ListG(cast(GList*) p, true); 701 } 702 703 /** 704 * Returns whether windows with an RGBA visual can reasonably 705 * be expected to have their alpha channel drawn correctly on 706 * the screen. 707 * 708 * On X11 this function returns whether a compositing manager is 709 * compositing @screen. 710 * 711 * Returns: Whether windows with RGBA visuals can reasonably be 712 * expected to have their alpha channels drawn correctly on the screen. 713 * 714 * Since: 2.10 715 */ 716 public bool isComposited() 717 { 718 return gdk_screen_is_composited(gdkScreen) != 0; 719 } 720 721 /** 722 * Lists the available visuals for the specified @screen. 723 * A visual describes a hardware image data format. 724 * For example, a visual might support 24-bit color, or 8-bit color, 725 * and might expect pixels to be in a certain format. 726 * 727 * Call g_list_free() on the return value when you’re finished with it. 728 * 729 * Returns: a list of visuals; the list must be freed, but not its contents 730 * 731 * Since: 2.2 732 */ 733 public ListG listVisuals() 734 { 735 auto p = gdk_screen_list_visuals(gdkScreen); 736 737 if(p is null) 738 { 739 return null; 740 } 741 742 return new ListG(cast(GList*) p); 743 } 744 745 /** 746 * Determines the name to pass to gdk_display_open() to get 747 * a #GdkDisplay with this screen as the default screen. 748 * 749 * Returns: a newly allocated string, free with g_free() 750 * 751 * Since: 2.2 752 */ 753 public string makeDisplayName() 754 { 755 auto retStr = gdk_screen_make_display_name(gdkScreen); 756 757 scope(exit) Str.freeString(retStr); 758 return Str.toString(retStr); 759 } 760 761 /** 762 * Sets the default font options for the screen. These 763 * options will be set on any #PangoContext’s newly created 764 * with gdk_pango_context_get_for_screen(). Changing the 765 * default set of font options does not affect contexts that 766 * have already been created. 767 * 768 * Params: 769 * options = a #cairo_font_options_t, or %NULL to unset any 770 * previously set default font options. 771 * 772 * Since: 2.10 773 */ 774 public void setFontOptions(FontOption options) 775 { 776 gdk_screen_set_font_options(gdkScreen, (options is null) ? null : options.getFontOptionStruct()); 777 } 778 779 /** 780 * Sets the resolution for font handling on the screen. This is a 781 * scale factor between points specified in a #PangoFontDescription 782 * and cairo units. The default value is 96, meaning that a 10 point 783 * font will be 13 units high. (10 * 96. / 72. = 13.3). 784 * 785 * Params: 786 * dpi = the resolution in “dots per inch”. (Physical inches aren’t actually 787 * involved; the terminology is conventional.) 788 * 789 * Since: 2.10 790 */ 791 public void setResolution(double dpi) 792 { 793 gdk_screen_set_resolution(gdkScreen, dpi); 794 } 795 796 protected class OnCompositedChangedDelegateWrapper 797 { 798 void delegate(Screen) dlg; 799 gulong handlerId; 800 801 this(void delegate(Screen) dlg) 802 { 803 this.dlg = dlg; 804 onCompositedChangedListeners ~= this; 805 } 806 807 void remove(OnCompositedChangedDelegateWrapper source) 808 { 809 foreach(index, wrapper; onCompositedChangedListeners) 810 { 811 if (wrapper.handlerId == source.handlerId) 812 { 813 onCompositedChangedListeners[index] = null; 814 onCompositedChangedListeners = std.algorithm.remove(onCompositedChangedListeners, index); 815 break; 816 } 817 } 818 } 819 } 820 OnCompositedChangedDelegateWrapper[] onCompositedChangedListeners; 821 822 /** 823 * The ::composited-changed signal is emitted when the composited 824 * status of the screen changes 825 * 826 * Since: 2.10 827 */ 828 gulong addOnCompositedChanged(void delegate(Screen) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 829 { 830 auto wrapper = new OnCompositedChangedDelegateWrapper(dlg); 831 wrapper.handlerId = Signals.connectData( 832 this, 833 "composited-changed", 834 cast(GCallback)&callBackCompositedChanged, 835 cast(void*)wrapper, 836 cast(GClosureNotify)&callBackCompositedChangedDestroy, 837 connectFlags); 838 return wrapper.handlerId; 839 } 840 841 extern(C) static void callBackCompositedChanged(GdkScreen* screenStruct, OnCompositedChangedDelegateWrapper wrapper) 842 { 843 wrapper.dlg(wrapper.outer); 844 } 845 846 extern(C) static void callBackCompositedChangedDestroy(OnCompositedChangedDelegateWrapper wrapper, GClosure* closure) 847 { 848 wrapper.remove(wrapper); 849 } 850 851 protected class OnMonitorsChangedDelegateWrapper 852 { 853 void delegate(Screen) dlg; 854 gulong handlerId; 855 856 this(void delegate(Screen) dlg) 857 { 858 this.dlg = dlg; 859 onMonitorsChangedListeners ~= this; 860 } 861 862 void remove(OnMonitorsChangedDelegateWrapper source) 863 { 864 foreach(index, wrapper; onMonitorsChangedListeners) 865 { 866 if (wrapper.handlerId == source.handlerId) 867 { 868 onMonitorsChangedListeners[index] = null; 869 onMonitorsChangedListeners = std.algorithm.remove(onMonitorsChangedListeners, index); 870 break; 871 } 872 } 873 } 874 } 875 OnMonitorsChangedDelegateWrapper[] onMonitorsChangedListeners; 876 877 /** 878 * The ::monitors-changed signal is emitted when the number, size 879 * or position of the monitors attached to the screen change. 880 * 881 * Only for X11 and OS X for now. A future implementation for Win32 882 * may be a possibility. 883 * 884 * Since: 2.14 885 */ 886 gulong addOnMonitorsChanged(void delegate(Screen) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 887 { 888 auto wrapper = new OnMonitorsChangedDelegateWrapper(dlg); 889 wrapper.handlerId = Signals.connectData( 890 this, 891 "monitors-changed", 892 cast(GCallback)&callBackMonitorsChanged, 893 cast(void*)wrapper, 894 cast(GClosureNotify)&callBackMonitorsChangedDestroy, 895 connectFlags); 896 return wrapper.handlerId; 897 } 898 899 extern(C) static void callBackMonitorsChanged(GdkScreen* screenStruct, OnMonitorsChangedDelegateWrapper wrapper) 900 { 901 wrapper.dlg(wrapper.outer); 902 } 903 904 extern(C) static void callBackMonitorsChangedDestroy(OnMonitorsChangedDelegateWrapper wrapper, GClosure* closure) 905 { 906 wrapper.remove(wrapper); 907 } 908 909 protected class OnSizeChangedDelegateWrapper 910 { 911 void delegate(Screen) dlg; 912 gulong handlerId; 913 914 this(void delegate(Screen) dlg) 915 { 916 this.dlg = dlg; 917 onSizeChangedListeners ~= this; 918 } 919 920 void remove(OnSizeChangedDelegateWrapper source) 921 { 922 foreach(index, wrapper; onSizeChangedListeners) 923 { 924 if (wrapper.handlerId == source.handlerId) 925 { 926 onSizeChangedListeners[index] = null; 927 onSizeChangedListeners = std.algorithm.remove(onSizeChangedListeners, index); 928 break; 929 } 930 } 931 } 932 } 933 OnSizeChangedDelegateWrapper[] onSizeChangedListeners; 934 935 /** 936 * The ::size-changed signal is emitted when the pixel width or 937 * height of a screen changes. 938 * 939 * Since: 2.2 940 */ 941 gulong addOnSizeChanged(void delegate(Screen) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 942 { 943 auto wrapper = new OnSizeChangedDelegateWrapper(dlg); 944 wrapper.handlerId = Signals.connectData( 945 this, 946 "size-changed", 947 cast(GCallback)&callBackSizeChanged, 948 cast(void*)wrapper, 949 cast(GClosureNotify)&callBackSizeChangedDestroy, 950 connectFlags); 951 return wrapper.handlerId; 952 } 953 954 extern(C) static void callBackSizeChanged(GdkScreen* screenStruct, OnSizeChangedDelegateWrapper wrapper) 955 { 956 wrapper.dlg(wrapper.outer); 957 } 958 959 extern(C) static void callBackSizeChangedDestroy(OnSizeChangedDelegateWrapper wrapper, GClosure* closure) 960 { 961 wrapper.remove(wrapper); 962 } 963 }