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