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