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