1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  Gdk.Screen.Gdk_Screen objects are the GDK representation of the screen on 
  26. --  which windows can be displayed and on which the pointer moves. X originally 
  27. --  identified screens with physical screens, but nowadays it is more common to 
  28. --  have a single Gdk.Screen.Gdk_Screen which combines several physical 
  29. --  monitors (see Gdk.Screen.Get_N_Monitors). 
  30. -- 
  31. --  GdkScreen is used throughout GDK and GTK+ to specify which screen the top 
  32. --  level windows are to be displayed on. it is also used to query the screen 
  33. --  specification and default settings such as the default visual 
  34. --  (gdk_screen_get_system_visual), the dimensions of the physical monitors 
  35. --  (gdk_screen_get_monitor_geometry), etc. 
  36. -- 
  37. --  </description> 
  38. --  <group>Gdk, the low-level API</group> 
  39. pragma Ada_2005; 
  40.  
  41. pragma Warnings (Off, "*is already use-visible*"); 
  42. with Cairo;           use Cairo; 
  43. with Gdk;             use Gdk; 
  44. with Gdk.Display;     use Gdk.Display; 
  45. with Gdk.Rectangle;   use Gdk.Rectangle; 
  46. with Gdk.Types;       use Gdk.Types; 
  47. with Gdk.Visual;      use Gdk.Visual; 
  48. with Glib;            use Glib; 
  49. with Glib.Object;     use Glib.Object; 
  50. with Glib.Properties; use Glib.Properties; 
  51.  
  52. package Gdk.Screen is 
  53.  
  54.    type Gdk_Screen_Record is new GObject_Record with null record; 
  55.    type Gdk_Screen is access all Gdk_Screen_Record'Class; 
  56.  
  57.    ------------------ 
  58.    -- Constructors -- 
  59.    ------------------ 
  60.  
  61.    function Get_Type return Glib.GType; 
  62.    pragma Import (C, Get_Type, "gdk_screen_get_type"); 
  63.  
  64.    ------------- 
  65.    -- Methods -- 
  66.    ------------- 
  67.  
  68.    function Get_Active_Window 
  69.       (Screen : not null access Gdk_Screen_Record) return Gdk.Gdk_Window; 
  70.    --  Returns the screen's currently active window. 
  71.    --  On X11, this is done by inspecting the _NET_ACTIVE_WINDOW property on 
  72.    --  the root window, as described in the <ulink 
  73.    --  url="http://www.freedesktop.org/Standards/wm-spec">Extended Window 
  74.    --  Manager Hints</ulink>. If there is no currently currently active window, 
  75.    --  or the window manager does not support the _NET_ACTIVE_WINDOW hint, this 
  76.    --  function returns null. 
  77.    --  On other platforms, this function may return null, depending on whether 
  78.    --  it is implementable on that platform. 
  79.    --  The returned window should be unrefed using g_object_unref when no 
  80.    --  longer needed. 
  81.    --  Since: gtk+ 2.10 
  82.  
  83.    function Get_Display 
  84.       (Screen : not null access Gdk_Screen_Record) 
  85.        return Gdk.Display.Gdk_Display; 
  86.    --  Gets the display to which the Screen belongs. 
  87.    --  Since: gtk+ 2.2 
  88.  
  89.    function Get_Font_Options 
  90.       (Screen : not null access Gdk_Screen_Record) 
  91.        return Cairo.Cairo_Font_Options; 
  92.    --  Gets any options previously set with Gdk.Screen.Set_Font_Options. 
  93.    --  Since: gtk+ 2.10 
  94.  
  95.    procedure Set_Font_Options 
  96.       (Screen  : not null access Gdk_Screen_Record; 
  97.        Options : in out Cairo.Cairo_Font_Options); 
  98.    --  Sets the default font options for the screen. These options will be set 
  99.    --  on any Pango.Context.Pango_Context's newly created with 
  100.    --  gdk_pango_context_get_for_screen. Changing the default set of font 
  101.    --  options does not affect contexts that have already been created. 
  102.    --  Since: gtk+ 2.10 
  103.    --  "options": a Cairo.Cairo_Font_Options, or null to unset any previously 
  104.    --  set default font options. 
  105.  
  106.    function Get_Height 
  107.       (Screen : not null access Gdk_Screen_Record) return Gint; 
  108.    --  Gets the height of Screen in pixels 
  109.    --  Since: gtk+ 2.2 
  110.  
  111.    function Get_Height_Mm 
  112.       (Screen : not null access Gdk_Screen_Record) return Gint; 
  113.    --  Returns the height of Screen in millimeters. Note that on some X 
  114.    --  servers this value will not be correct. 
  115.    --  Since: gtk+ 2.2 
  116.  
  117.    function Get_Monitor_At_Point 
  118.       (Screen : not null access Gdk_Screen_Record; 
  119.        X      : Gint; 
  120.        Y      : Gint) return Gint; 
  121.    --  Returns the monitor number in which the point (X,Y) is located. 
  122.    --  Since: gtk+ 2.2 
  123.    --  "x": the x coordinate in the virtual screen. 
  124.    --  "y": the y coordinate in the virtual screen. 
  125.  
  126.    function Get_Monitor_At_Window 
  127.       (Screen : not null access Gdk_Screen_Record; 
  128.        Window : Gdk.Gdk_Window) return Gint; 
  129.    --  Returns the number of the monitor in which the largest area of the 
  130.    --  bounding rectangle of Window resides. 
  131.    --  Since: gtk+ 2.2 
  132.    --  "window": a Gdk.Gdk_Window 
  133.  
  134.    procedure Get_Monitor_Geometry 
  135.       (Screen      : not null access Gdk_Screen_Record; 
  136.        Monitor_Num : Gint; 
  137.        Dest        : out Gdk.Rectangle.Gdk_Rectangle); 
  138.    --  Retrieves the Gdk.Rectangle.Gdk_Rectangle representing the size and 
  139.    --  position of the individual monitor within the entire screen area. 
  140.    --  Monitor numbers start at 0. To obtain the number of monitors of Screen, 
  141.    --  use Gdk.Screen.Get_N_Monitors. 
  142.    --  Note that the size of the entire screen area can be retrieved via 
  143.    --  Gdk.Screen.Get_Width and Gdk.Screen.Get_Height. 
  144.    --  Since: gtk+ 2.2 
  145.    --  "monitor_num": the monitor number 
  146.    --  "dest": a Gdk.Rectangle.Gdk_Rectangle to be filled with the monitor 
  147.    --  geometry 
  148.  
  149.    function Get_Monitor_Height_Mm 
  150.       (Screen      : not null access Gdk_Screen_Record; 
  151.        Monitor_Num : Gint) return Gint; 
  152.    --  Gets the height in millimeters of the specified monitor. 
  153.    --  Since: gtk+ 2.14 
  154.    --  "monitor_num": number of the monitor, between 0 and 
  155.    --  gdk_screen_get_n_monitors (screen) 
  156.  
  157.    function Get_Monitor_Plug_Name 
  158.       (Screen      : not null access Gdk_Screen_Record; 
  159.        Monitor_Num : Gint) return UTF8_String; 
  160.    --  Returns the output name of the specified monitor. Usually something 
  161.    --  like VGA, DVI, or TV, not the actual product name of the display device. 
  162.    --  Since: gtk+ 2.14 
  163.    --  "monitor_num": number of the monitor, between 0 and 
  164.    --  gdk_screen_get_n_monitors (screen) 
  165.  
  166.    function Get_Monitor_Width_Mm 
  167.       (Screen      : not null access Gdk_Screen_Record; 
  168.        Monitor_Num : Gint) return Gint; 
  169.    --  Gets the width in millimeters of the specified monitor, if available. 
  170.    --  Since: gtk+ 2.14 
  171.    --  "monitor_num": number of the monitor, between 0 and 
  172.    --  gdk_screen_get_n_monitors (screen) 
  173.  
  174.    procedure Get_Monitor_Workarea 
  175.       (Screen      : not null access Gdk_Screen_Record; 
  176.        Monitor_Num : Gint; 
  177.        Dest        : out Gdk.Rectangle.Gdk_Rectangle); 
  178.    --  Retrieves the Gdk.Rectangle.Gdk_Rectangle representing the size and 
  179.    --  position of the "work area" on a monitor within the entire screen area. 
  180.    --  The work area should be considered when positioning menus and similar 
  181.    --  popups, to avoid placing them below panels, docks or other desktop 
  182.    --  components. 
  183.    --  Monitor numbers start at 0. To obtain the number of monitors of Screen, 
  184.    --  use Gdk.Screen.Get_N_Monitors. 
  185.    --  Since: gtk+ 3.4 
  186.    --  "monitor_num": the monitor number 
  187.    --  "dest": a Gdk.Rectangle.Gdk_Rectangle to be filled with the monitor 
  188.    --  workarea 
  189.  
  190.    function Get_N_Monitors 
  191.       (Screen : not null access Gdk_Screen_Record) return Gint; 
  192.    --  Returns the number of monitors which Screen consists of. 
  193.    --  Since: gtk+ 2.2 
  194.  
  195.    function Get_Number 
  196.       (Screen : not null access Gdk_Screen_Record) return Gint; 
  197.    --  Gets the index of Screen among the screens in the display to which it 
  198.    --  belongs. (See Gdk.Screen.Get_Display) 
  199.    --  Since: gtk+ 2.2 
  200.  
  201.    function Get_Primary_Monitor 
  202.       (Screen : not null access Gdk_Screen_Record) return Gint; 
  203.    --  Gets the primary monitor for Screen. The primary monitor is considered 
  204.    --  the monitor where the 'main desktop' lives. While normal application 
  205.    --  windows typically allow the window manager to place the windows, 
  206.    --  specialized desktop applications such as panels should place themselves 
  207.    --  on the primary monitor. 
  208.    --  If no primary monitor is configured by the user, the return value will 
  209.    --  be 0, defaulting to the first monitor. 
  210.    --  Since: gtk+ 2.20 
  211.  
  212.    function Get_Resolution 
  213.       (Screen : not null access Gdk_Screen_Record) return Gdouble; 
  214.    --  Gets the resolution for font handling on the screen; see 
  215.    --  Gdk.Screen.Set_Resolution for full details. 
  216.    --  Since: gtk+ 2.10 
  217.  
  218.    procedure Set_Resolution 
  219.       (Screen : not null access Gdk_Screen_Record; 
  220.        Dpi    : Gdouble); 
  221.    --  Sets the resolution for font handling on the screen. This is a scale 
  222.    --  factor between points specified in a Pango.Font.Pango_Font_Description 
  223.    --  and cairo units. The default value is 96, meaning that a 10 point font 
  224.    --  will be 13 units high. (10 * 96. / 72. = 13.3). 
  225.    --  Since: gtk+ 2.10 
  226.    --  "dpi": the resolution in "dots per inch". (Physical inches aren't 
  227.    --  actually involved; the terminology is conventional.) 
  228.  
  229.    function Get_Rgba_Visual 
  230.       (Screen : not null access Gdk_Screen_Record) 
  231.        return Gdk.Visual.Gdk_Visual; 
  232.    --  Gets a visual to use for creating windows with an alpha channel. The 
  233.    --  windowing system on which GTK+ is running may not support this 
  234.    --  capability, in which case null will be returned. Even if a non-null 
  235.    --  value is returned, its possible that the window's alpha channel won't be 
  236.    --  honored when displaying the window on the screen: in particular, for X 
  237.    --  an appropriate windowing manager and compositing manager must be running 
  238.    --  to provide appropriate display. 
  239.    --  This functionality is not implemented in the Windows backend. 
  240.    --  For setting an overall opacity for a top-level window, see 
  241.    --  Gdk.Window.Set_Opacity. 
  242.    --  Since: gtk+ 2.8 
  243.  
  244.    function Get_Root_Window 
  245.       (Screen : not null access Gdk_Screen_Record) return Gdk.Gdk_Window; 
  246.    --  Gets the root window of Screen. 
  247.    --  Since: gtk+ 2.2 
  248.  
  249.    function Get_System_Visual 
  250.       (Screen : not null access Gdk_Screen_Record) 
  251.        return Gdk.Visual.Gdk_Visual; 
  252.    --  Get the system's default visual for Screen. This is the visual for the 
  253.    --  root window of the display. The return value should not be freed. 
  254.    --  Since: gtk+ 2.2 
  255.  
  256.    function Get_Width 
  257.       (Screen : not null access Gdk_Screen_Record) return Gint; 
  258.    --  Gets the width of Screen in pixels 
  259.    --  Since: gtk+ 2.2 
  260.  
  261.    function Get_Width_Mm 
  262.       (Screen : not null access Gdk_Screen_Record) return Gint; 
  263.    --  Gets the width of Screen in millimeters. Note that on some X servers 
  264.    --  this value will not be correct. 
  265.    --  Since: gtk+ 2.2 
  266.  
  267.    function Is_Composited 
  268.       (Screen : not null access Gdk_Screen_Record) return Boolean; 
  269.    --  Returns whether windows with an RGBA visual can reasonably be expected 
  270.    --  to have their alpha channel drawn correctly on the screen. 
  271.    --  On X11 this function returns whether a compositing manager is 
  272.    --  compositing Screen. 
  273.    --  Since: gtk+ 2.10 
  274.  
  275.    function Make_Display_Name 
  276.       (Screen : not null access Gdk_Screen_Record) return UTF8_String; 
  277.    --  Determines the name to pass to Gdk.Display.Open to get a 
  278.    --  Gdk.Display.Gdk_Display with this screen as the default screen. 
  279.    --  Since: gtk+ 2.2 
  280.  
  281.    ---------------------- 
  282.    -- GtkAda additions -- 
  283.    ---------------------- 
  284.  
  285.    ------------- 
  286.    -- Display -- 
  287.    ------------- 
  288.    --  These subprograms should really be in gdk-display.ads to match what is 
  289.    --  done for gtk+ itself, but that would create dependency circularities. 
  290.    --  Ada 2005 has support for these, but we want GtkAda to build with Ada95 
  291.    --  compilers. 
  292.  
  293.    function Get_Screen 
  294.      (Display    : access Gdk.Display.Gdk_Display_Record'Class; 
  295.       Screen_Num : Glib.Gint) 
  296.    return Gdk_Screen; 
  297.    --  Returns a screen object for one of the screens of the display. 
  298.  
  299.    function Get_Default_Screen 
  300.      (Display : access Gdk.Display.Gdk_Display_Record'Class) return Gdk_Screen; 
  301.    --  Get the default Gdk_Screen for display. 
  302.  
  303.    procedure Get_Pointer 
  304.      (Display : access Gdk.Display.Gdk_Display_Record'Class; 
  305.       Screen  : out Gdk_Screen; 
  306.       X       : out Glib.Gint; 
  307.       Y       : out Glib.Gint; 
  308.       Mask    : out Gdk.Types.Gdk_Modifier_Type); 
  309.    --  Gets the current location of the pointer and the current modifier 
  310.    --  mask for a given display. 
  311.    --  (X, Y) are coordinates relative to the root window on the display 
  312.  
  313.    procedure Warp_Pointer 
  314.      (Display : access Gdk.Display.Gdk_Display_Record'Class; 
  315.       Screen  : access Gdk_Screen_Record; 
  316.       X       : Glib.Gint; 
  317.       Y       : Glib.Gint); 
  318.    --  Warps the pointer of display to the point x,y on the screen screen, 
  319.    --  unless the pointer is confined to a window by a grab, in which case it 
  320.    --  will be moved as far as allowed by the grab. Warping the pointer creates 
  321.    --  events as if the user had moved the mouse instantaneously to the 
  322.    --  destination. 
  323.    -- 
  324.    --  Note that the pointer should normally be under the control of the user. 
  325.    --  This function was added to cover some rare use cases like keyboard 
  326.    --  navigation support for the color picker in the GtkColorSelectionDialog. 
  327.  
  328.    --------------- 
  329.    -- Functions -- 
  330.    --------------- 
  331.  
  332.    function Get_Default return Gdk_Screen; 
  333.    --  Gets the default screen for the default display. (See 
  334.    --  gdk_display_get_default ()). 
  335.    --  Since: gtk+ 2.2 
  336.  
  337.    function Height return Gint; 
  338.    --  Returns the height of the default screen in pixels. 
  339.  
  340.    function Height_Mm return Gint; 
  341.    --  Returns the height of the default screen in millimeters. Note that on 
  342.    --  many X servers this value will not be correct. 
  343.  
  344.    function Width return Gint; 
  345.    --  Returns the width of the default screen in pixels. 
  346.  
  347.    function Width_Mm return Gint; 
  348.    --  Returns the width of the default screen in millimeters. Note that on 
  349.    --  many X servers this value will not be correct. 
  350.  
  351.    ---------------- 
  352.    -- Properties -- 
  353.    ---------------- 
  354.    --  The following properties are defined for this widget. See 
  355.    --  Glib.Properties for more information on properties) 
  356.  
  357.    Font_Options_Property : constant Glib.Properties.Property_String := 
  358.    Glib.Properties.Build ("font-options");--  Unknown type: gpointer 
  359.  
  360.    Resolution_Property : constant Glib.Properties.Property_Double; 
  361.    --  Type: Gdouble 
  362.  
  363.    ------------- 
  364.    -- Signals -- 
  365.    ------------- 
  366.  
  367.    Signal_Composited_Changed : constant Glib.Signal_Name := "composited-changed"; 
  368.    --  The ::composited-changed signal is emitted when the composited status 
  369.    --  of the screen changes 
  370.    --    procedure Handler (Self : access Gdk_Screen_Record'Class) 
  371.  
  372.    Signal_Monitors_Changed : constant Glib.Signal_Name := "monitors-changed"; 
  373.    --  The ::monitors-changed signal is emitted when the number, size or 
  374.    --  position of the monitors attached to the screen change. 
  375.    -- 
  376.    --  Only for X11 and OS X for now. A future implementation for Win32 may be 
  377.    --  a possibility. 
  378.    --    procedure Handler (Self : access Gdk_Screen_Record'Class) 
  379.  
  380.    Signal_Size_Changed : constant Glib.Signal_Name := "size-changed"; 
  381.    --  The ::size-changed signal is emitted when the pixel width or height of 
  382.    --  a screen changes. 
  383.    --    procedure Handler (Self : access Gdk_Screen_Record'Class) 
  384.  
  385. private 
  386.    Resolution_Property : constant Glib.Properties.Property_Double := 
  387.      Glib.Properties.Build ("resolution"); 
  388. end Gdk.Screen;