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