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