gtkmm 3.24.7
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Gdk::Screen Class Reference

Object representing a physical screen Gdk::Screen objects are the GDK representation of a physical screen. More...

#include <gdkmm/screen.h>

Inherits Glib::Object.

Public Member Functions

 Screen (Screen && src) noexcept
 
Screenoperator= (Screen && src) noexcept
 
 ~Screen () noexcept override
 
GdkScreen * gobj ()
 Provides access to the underlying C GObject. More...
 
const GdkScreen * gobj () const
 Provides access to the underlying C GObject. More...
 
GdkScreen * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Glib::RefPtr< Visualget_system_visual ()
 Get the system’s default visual for screen. More...
 
Glib::RefPtr< const Visualget_system_visual () const
 Get the system’s default visual for screen. More...
 
Glib::RefPtr< Visualget_rgba_visual ()
 Gets a visual to use for creating windows with an alpha channel. More...
 
Glib::RefPtr< const Visualget_rgba_visual () const
 Gets a visual to use for creating windows with an alpha channel. More...
 
bool is_composited () const
 Returns whether windows with an RGBA visual can reasonably be expected to have their alpha channel drawn correctly on the screen. More...
 
Glib::RefPtr< Windowget_root_window ()
 Gets the root window of screen. More...
 
Glib::RefPtr< const Windowget_root_window () const
 Gets the root window of screen. More...
 
Glib::RefPtr< Displayget_display ()
 Gets the display to which the screen belongs. More...
 
Glib::RefPtr< const Displayget_display () const
 Gets the display to which the screen belongs. More...
 
int get_number () const
 Gets the index of screen among the screens in the display to which it belongs. More...
 
int get_width () const
 Gets the width of screen in pixels. More...
 
int get_height () const
 Gets the height of screen in pixels. More...
 
int get_width_mm () const
 Gets the width of screen in millimeters. More...
 
int get_height_mm () const
 Returns the height of screen in millimeters. More...
 
std::vector< Glib::RefPtr< Visual > > list_visuals ()
 Lists the available visuals for the specified screen. More...
 
std::vector< Glib::RefPtr< Window > > get_toplevel_windows ()
 Obtains a list of all toplevel windows known to GDK on the screen screen. More...
 
Glib::ustring make_display_name ()
 Determines the name to pass to Gdk::Display::open() to get a Gdk::Display with this screen as the default screen. More...
 
int get_n_monitors () const
 Returns the number of monitors which screen consists of. More...
 
int get_primary_monitor () const
 Gets the primary monitor for screen. More...
 
void get_monitor_geometry (int monitor_num, Rectangle & dest) const
 Retrieves the Gdk::Rectangle representing the size and position of the individual monitor within the entire screen area. More...
 
Rectangle get_monitor_workarea (int monitor_num=0) const
 Retrieves the Gdk::Rectangle representing the size and position of the "work area" on a monitor within the entire screen area. More...
 
int get_monitor_at_point (int x, int y) const
 Returns the monitor number in which the point ( x, y) is located. More...
 
int get_monitor_at_window (const Glib::RefPtr< Window > & window) const
 Returns the number of the monitor in which the largest area of the bounding rectangle of window resides. More...
 
int get_monitor_width_mm (int monitor_num) const
 Gets the width in millimeters of the specified monitor, if available. More...
 
int get_monitor_height_mm (int monitor_num) const
 Gets the height in millimeters of the specified monitor. More...
 
Glib::ustring get_monitor_plug_name (int monitor_num) const
 Returns the output name of the specified monitor. More...
 
int get_monitor_scale_factor (int monitor_num)
 Returns the internal scale factor that maps from monitor coordinates to the actual device pixels. More...
 
template<class ValueType >
bool get_setting (const Glib::ustring & name, ValueType & value) const
 
void set_font_options (const ::Cairo::FontOptions & options)
 Sets the default font options for the screen. More...
 
::Cairo::FontOptions get_font_options () const
 Gets any options previously set with set_font_options(). More...
 
void set_resolution (double dpi)
 Sets the resolution for font handling on the screen. More...
 
double get_resolution () const
 Gets the resolution for font handling on the screen; see set_resolution() for full details. More...
 
Glib::RefPtr< Gdk::Windowget_active_window ()
 Returns the screen’s currently active window. More...
 
Glib::RefPtr< const Gdk::Windowget_active_window () const
 Returns the screen’s currently active window. More...
 
std::vector< Glib::RefPtr< Window > > get_window_stack ()
 Returns a List of Gdk::Windows representing the current window stack. More...
 
Glib::SignalProxy< void > signal_size_changed ()
 
Glib::SignalProxy< void > signal_composited_changed ()
 
Glib::SignalProxy< void > signal_monitors_changed ()
 
Glib::PropertyProxy< ::Cairo::FontOptions > property_font_options ()
 The default font options for the screen. More...
 
Glib::PropertyProxy_ReadOnly< ::Cairo::FontOptions > property_font_options () const
 The default font options for the screen. More...
 
Glib::PropertyProxy< double > property_resolution ()
 The resolution for fonts on the screen. More...
 
Glib::PropertyProxy_ReadOnly< double > property_resolution () const
 The resolution for fonts on the screen. More...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< Screenget_default ()
 Gets the default screen for the default display. More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gdk::Screenwrap (GdkScreen * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

Object representing a physical screen Gdk::Screen objects are the GDK representation of a physical screen.

It is used throughout GDK and GTK+ to specify which screen the top level windows are to be displayed on. It is also used to query the screen specification and default settings such as the screen width (get_width()), etc. Note that a screen may consist of multiple monitors which are merged to form a large screen area.

Constructor & Destructor Documentation

◆ Screen()

Gdk::Screen::Screen ( Screen &&  src)
noexcept

◆ ~Screen()

Gdk::Screen::~Screen ( )
overridenoexcept

Member Function Documentation

◆ get_active_window() [1/2]

Glib::RefPtr< Gdk::Window > Gdk::Screen::get_active_window ( )

Returns the screen’s currently active window.

On X11, this is done by inspecting the _NET_ACTIVE_WINDOW property on the root window, as described in the Extended Window Manager Hints. If there is no currently currently active window, or the window manager does not support the _NET_ACTIVE_WINDOW hint, this function returns nullptr.

On other platforms, this function may return nullptr, depending on whether it is implementable on that platform.

The returned window should be unrefed using Glib::object_unref() when no longer needed.

Since gtkmm 2.10:

Deprecated: 3.22

Deprecated:
No replacement available.
Returns
The currently active window, or nullptr.

◆ get_active_window() [2/2]

Glib::RefPtr< const Gdk::Window > Gdk::Screen::get_active_window ( ) const

Returns the screen’s currently active window.

On X11, this is done by inspecting the _NET_ACTIVE_WINDOW property on the root window, as described in the Extended Window Manager Hints. If there is no currently currently active window, or the window manager does not support the _NET_ACTIVE_WINDOW hint, this function returns nullptr.

On other platforms, this function may return nullptr, depending on whether it is implementable on that platform.

The returned window should be unrefed using Glib::object_unref() when no longer needed.

Since gtkmm 2.10:

Deprecated: 3.22

Deprecated:
No replacement available.
Returns
The currently active window, or nullptr.

◆ get_default()

static Glib::RefPtr< Screen > Gdk::Screen::get_default ( )
static

Gets the default screen for the default display.

(See Gdk::Display::get_default()).

Since gtkmm 2.2:
Returns
A Gdk::Screen, or nullptr if there is no default display.

◆ get_display() [1/2]

Glib::RefPtr< Display > Gdk::Screen::get_display ( )

Gets the display to which the screen belongs.

Since gtkmm 2.2:
Returns
The display to which screen belongs.

◆ get_display() [2/2]

Glib::RefPtr< const Display > Gdk::Screen::get_display ( ) const

Gets the display to which the screen belongs.

Since gtkmm 2.2:
Returns
The display to which screen belongs.

◆ get_font_options()

::Cairo::FontOptions Gdk::Screen::get_font_options ( ) const

Gets any options previously set with set_font_options().

Since gtkmm 2.10:
Returns
The current font options, or nullptr if no default font options have been set.

◆ get_height()

int Gdk::Screen::get_height ( ) const

Gets the height of screen in pixels.

The returned size is in ”application pixels”, not in ”device pixels” (see get_monitor_scale_factor()).

Since gtkmm 2.2:

Deprecated: 3.22: Use per-monitor information instead

Deprecated:
Use per-monitor information instead.
Returns
The height of screen in pixels.

◆ get_height_mm()

int Gdk::Screen::get_height_mm ( ) const

Returns the height of screen in millimeters.

Note that this value is somewhat ill-defined when the screen has multiple monitors of different resolution. It is recommended to use the monitor dimensions instead.

Deprecated: 3.22: Use per-monitor information instead

Since gtkmm 2.2:
Deprecated:
Use per-monitor information instead.
Returns
The heigth of screen in millimeters.

◆ get_monitor_at_point()

int Gdk::Screen::get_monitor_at_point ( int  x,
int  y 
) const

Returns the monitor number in which the point ( x, y) is located.

Since gtkmm 2.2:

Deprecated: 3.22: Use Gdk::Display::get_monitor_at_point() instead

Deprecated:
Use Gdk::Display::get_monitor_at_point() instead.
Parameters
xThe x coordinate in the virtual screen.
yThe y coordinate in the virtual screen.
Returns
The monitor number in which the point ( x, y) lies, or a monitor close to ( x, y) if the point is not in any monitor.

◆ get_monitor_at_window()

int Gdk::Screen::get_monitor_at_window ( const Glib::RefPtr< Window > &  window) const

Returns the number of the monitor in which the largest area of the bounding rectangle of window resides.

Since gtkmm 2.2:

Deprecated: 3.22: Use Gdk::Display::get_monitor_at_window() instead

Deprecated:
Use Gdk::Display::get_monitor_at_window() instead.
Parameters
windowA Gdk::Window.
Returns
The monitor number in which most of window is located, or if window does not intersect any monitors, a monitor, close to window.

◆ get_monitor_geometry()

void Gdk::Screen::get_monitor_geometry ( int  monitor_num,
Rectangle dest 
) const

Retrieves the Gdk::Rectangle representing the size and position of the individual monitor within the entire screen area.

The returned geometry is in ”application pixels”, not in ”device pixels” (see get_monitor_scale_factor()).

Monitor numbers start at 0. To obtain the number of monitors of screen, use get_n_monitors().

Note that the size of the entire screen area can be retrieved via get_width() and get_height().

Since gtkmm 2.2:

Deprecated: 3.22: Use Gdk::Monitor::get_geometry() instead

Deprecated:
Use Gdk::Monitor::get_geometry() instead.
Parameters
monitor_numThe monitor number.
destA Gdk::Rectangle to be filled with the monitor geometry.

◆ get_monitor_height_mm()

int Gdk::Screen::get_monitor_height_mm ( int  monitor_num) const

Gets the height in millimeters of the specified monitor.

Since gtkmm 2.14:

Deprecated: 3.22: Use Gdk::Monitor::get_height_mm() instead

Deprecated:
Use Gdk::Monitor::get_height_mm() instead.
Parameters
monitor_numNumber of the monitor, between 0 and gdk_screen_get_n_monitors (screen).
Returns
The height of the monitor, or -1 if not available.

◆ get_monitor_plug_name()

Glib::ustring Gdk::Screen::get_monitor_plug_name ( int  monitor_num) const

Returns the output name of the specified monitor.

Usually something like VGA, DVI, or TV, not the actual product name of the display device.

Since gtkmm 2.14:

Deprecated: 3.22: Use Gdk::Monitor::get_model() instead

Deprecated:
Use Gdk::Monitor::get_model() instead.
Parameters
monitor_numNumber of the monitor, between 0 and gdk_screen_get_n_monitors (screen).
Returns
A newly-allocated string containing the name of the monitor, or nullptr if the name cannot be determined.

◆ get_monitor_scale_factor()

int Gdk::Screen::get_monitor_scale_factor ( int  monitor_num)

Returns the internal scale factor that maps from monitor coordinates to the actual device pixels.

On traditional systems this is 1, but on very high density outputs this can be a higher value (often 2).

This can be used if you want to create pixel based data for a particular monitor, but most of the time you’re drawing to a window where it is better to use Gdk::Window::get_scale_factor() instead.

Since gtkmm 3.10:

Deprecated: 3.22: Use Gdk::Monitor::get_scale_factor() instead

Deprecated:
Use Gdk::Monitor::get_scale_factor() instead.
Parameters
monitor_numNumber of the monitor, between 0 and gdk_screen_get_n_monitors (screen).
Returns
The scale factor.

◆ get_monitor_width_mm()

int Gdk::Screen::get_monitor_width_mm ( int  monitor_num) const

Gets the width in millimeters of the specified monitor, if available.

Since gtkmm 2.14:

Deprecated: 3.22: Use Gdk::Monitor::get_width_mm() instead

Deprecated:
Use Gdk::Monitor::get_width_mm() instead.
Parameters
monitor_numNumber of the monitor, between 0 and gdk_screen_get_n_monitors (screen).
Returns
The width of the monitor, or -1 if not available.

◆ get_monitor_workarea()

Rectangle Gdk::Screen::get_monitor_workarea ( int  monitor_num = 0) const

Retrieves the Gdk::Rectangle representing the size and position of the "work area" on a monitor within the entire screen area.

The work area should be considered when positioning menus and similar popups, to avoid placing them below panels, docks or other desktop components.

Monitor numbers start at 0. To obtain the number of monitors of screen, use get_n_monitors().

Since gtkmm 3.6:
Deprecated:
Use Gdk::Monitor::get_workarea() instead.
Parameters
monitor_numThe monitor number.
Returns
The monitor workarea.

◆ get_n_monitors()

int Gdk::Screen::get_n_monitors ( ) const

Returns the number of monitors which screen consists of.

Since gtkmm 2.2:

Deprecated: 3.22: Use Gdk::Display::get_n_monitors() instead

Deprecated:
Use Gdk::Display::get_n_monitors() instead.
Returns
Number of monitors which screen consists of.

◆ get_number()

int Gdk::Screen::get_number ( ) const

Gets the index of screen among the screens in the display to which it belongs.

(See get_display())

Since gtkmm 2.2:

Deprecated: 3.22

Deprecated:
No replacement available.
Returns
The index.

◆ get_primary_monitor()

int Gdk::Screen::get_primary_monitor ( ) const

Gets the primary monitor for screen.

The primary monitor is considered the monitor where the “main desktop” lives. While normal application windows typically allow the window manager to place the windows, specialized desktop applications such as panels should place themselves on the primary monitor.

If no primary monitor is configured by the user, the return value will be 0, defaulting to the first monitor.

Since gtkmm 2.20:

Deprecated: 3.22: Use Gdk::Display::get_primary_monitor() instead

Deprecated:
Use Gdk::Display::get_primary_monitor() instead.
Returns
An integer index for the primary monitor, or 0 if none is configured.

◆ get_resolution()

double Gdk::Screen::get_resolution ( ) const

Gets the resolution for font handling on the screen; see set_resolution() for full details.

Since gtkmm 2.10:
Returns
The current resolution, or -1 if no resolution has been set.

◆ get_rgba_visual() [1/2]

Glib::RefPtr< Visual > Gdk::Screen::get_rgba_visual ( )

Gets a visual to use for creating windows with an alpha channel.

The windowing system on which GTK+ is running may not support this capability, in which case nullptr will be returned. Even if a non-nullptr value is returned, its possible that the window’s alpha channel won’t be honored when displaying the window on the screen: in particular, for X an appropriate windowing manager and compositing manager must be running to provide appropriate display.

This functionality is not implemented in the Windows backend.

For setting an overall opacity for a top-level window, see Gdk::Window::set_opacity().

Since gtkmm 2.8:
Returns
A visual to use for windows with an alpha channel or nullptr if the capability is not available.

◆ get_rgba_visual() [2/2]

Glib::RefPtr< const Visual > Gdk::Screen::get_rgba_visual ( ) const

Gets a visual to use for creating windows with an alpha channel.

The windowing system on which GTK+ is running may not support this capability, in which case nullptr will be returned. Even if a non-nullptr value is returned, its possible that the window’s alpha channel won’t be honored when displaying the window on the screen: in particular, for X an appropriate windowing manager and compositing manager must be running to provide appropriate display.

This functionality is not implemented in the Windows backend.

For setting an overall opacity for a top-level window, see Gdk::Window::set_opacity().

Since gtkmm 2.8:
Returns
A visual to use for windows with an alpha channel or nullptr if the capability is not available.

◆ get_root_window() [1/2]

Glib::RefPtr< Window > Gdk::Screen::get_root_window ( )

Gets the root window of screen.

Since gtkmm 2.2:
Returns
The root window.

◆ get_root_window() [2/2]

Glib::RefPtr< const Window > Gdk::Screen::get_root_window ( ) const

Gets the root window of screen.

Since gtkmm 2.2:
Returns
The root window.

◆ get_setting()

template <class ValueType >
bool Gdk::Screen::get_setting ( const Glib::ustring &  name,
ValueType &  value 
) const

◆ get_system_visual() [1/2]

Glib::RefPtr< Visual > Gdk::Screen::get_system_visual ( )

Get the system’s default visual for screen.

This is the visual for the root window of the display. The return value should not be freed.

Since gtkmm 2.2:
Returns
The system visual.

◆ get_system_visual() [2/2]

Glib::RefPtr< const Visual > Gdk::Screen::get_system_visual ( ) const

Get the system’s default visual for screen.

This is the visual for the root window of the display. The return value should not be freed.

Since gtkmm 2.2:
Returns
The system visual.

◆ get_toplevel_windows()

std::vector< Glib::RefPtr< Window > > Gdk::Screen::get_toplevel_windows ( )

Obtains a list of all toplevel windows known to GDK on the screen screen.

A toplevel window is a child of the root window (see gdk_get_default_root_window()).

Since gtkmm 2.2:
Returns
List of toplevel windows.

◆ get_type()

static GType Gdk::Screen::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_width()

int Gdk::Screen::get_width ( ) const

Gets the width of screen in pixels.

The returned size is in ”application pixels”, not in ”device pixels” (see get_monitor_scale_factor()).

Since gtkmm 2.2:

Deprecated: 3.22: Use per-monitor information instead

Deprecated:
Use per-monitor information instead.
Returns
The width of screen in pixels.

◆ get_width_mm()

int Gdk::Screen::get_width_mm ( ) const

Gets the width of screen in millimeters.

Note that this value is somewhat ill-defined when the screen has multiple monitors of different resolution. It is recommended to use the monitor dimensions instead.

Since gtkmm 2.2:

Deprecated: 3.22: Use per-monitor information instead

Deprecated:
Use per-monitor information instead.
Returns
The width of screen in millimeters.

◆ get_window_stack()

std::vector< Glib::RefPtr< Window > > Gdk::Screen::get_window_stack ( )

Returns a List of Gdk::Windows representing the current window stack.

On X11, this is done by inspecting the _NET_CLIENT_LIST_STACKING property on the root window, as described in the Extended Window Manager Hints. If the window manager does not support the _NET_CLIENT_LIST_STACKING hint, this function returns nullptr.

On other platforms, this function may return nullptr, depending on whether it is implementable on that platform.

Since gtkmm 2.10:
Returns
A list of Gdk::Windows for the current window stack, or nullptr.

◆ gobj() [1/2]

GdkScreen * Gdk::Screen::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GdkScreen * Gdk::Screen::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GdkScreen * Gdk::Screen::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ is_composited()

bool Gdk::Screen::is_composited ( ) const

Returns whether windows with an RGBA visual can reasonably be expected to have their alpha channel drawn correctly on the screen.

On X11 this function returns whether a compositing manager is compositing screen.

Since gtkmm 2.10:
Returns
Whether windows with RGBA visuals can reasonably be expected to have their alpha channels drawn correctly on the screen.

◆ list_visuals()

std::vector< Glib::RefPtr< Visual > > Gdk::Screen::list_visuals ( )

Lists the available visuals for the specified screen.

A visual describes a hardware image data format. For example, a visual might support 24-bit color, or 8-bit color, and might expect pixels to be in a certain format.

Since gtkmm 2.2:
Returns
A list of visuals.

◆ make_display_name()

Glib::ustring Gdk::Screen::make_display_name ( )

Determines the name to pass to Gdk::Display::open() to get a Gdk::Display with this screen as the default screen.

Since gtkmm 2.2:

Deprecated: 3.22

Deprecated:
No replacement available.
Returns
The name.

◆ operator=()

Screen & Gdk::Screen::operator= ( Screen &&  src)
noexcept

◆ property_font_options() [1/2]

Glib::PropertyProxy< ::Cairo::FontOptions > Gdk::Screen::property_font_options ( )

The default font options for the screen.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_font_options() [2/2]

Glib::PropertyProxy_ReadOnly< ::Cairo::FontOptions > Gdk::Screen::property_font_options ( ) const

The default font options for the screen.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_resolution() [1/2]

Glib::PropertyProxy< double > Gdk::Screen::property_resolution ( )

The resolution for fonts on the screen.

Default value: -1

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_resolution() [2/2]

Glib::PropertyProxy_ReadOnly< double > Gdk::Screen::property_resolution ( ) const

The resolution for fonts on the screen.

Default value: -1

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ set_font_options()

void Gdk::Screen::set_font_options ( const ::Cairo::FontOptions &  options)

Sets the default font options for the screen.

These options will be set on any Pango::Context’s newly created with gdk_pango_context_get_for_screen(). Changing the default set of font options does not affect contexts that have already been created.

Since gtkmm 2.10:
Parameters
optionsA #cairo_font_options_t, or nullptr to unset any previously set default font options.

◆ set_resolution()

void Gdk::Screen::set_resolution ( double  dpi)

Sets the resolution for font handling on the screen.

This is a scale factor between points specified in a Pango::FontDescription and cairo units. The default value is 96, meaning that a 10 point font will be 13 units high. (10 * 96. / 72. = 13.3).

Since gtkmm 2.10:
Parameters
dpiThe resolution in “dots per inch”. (Physical inches aren’t actually involved; the terminology is conventional.).

◆ signal_composited_changed()

Glib::SignalProxy< void > Gdk::Screen::signal_composited_changed ( )
Slot Prototype:
void on_my_composited_changed()

Flags: Run Last

The signal_composited_changed() signal is emitted when the composited status of the screen changes

Since gtkmm 2.10:

◆ signal_monitors_changed()

Glib::SignalProxy< void > Gdk::Screen::signal_monitors_changed ( )
Slot Prototype:
void on_my_monitors_changed()

Flags: Run Last

The signal_monitors_changed() signal is emitted when the number, size or position of the monitors attached to the screen change.

Only for X11 and OS X for now. A future implementation for Win32 may be a possibility.

Since gtkmm 2.14:

◆ signal_size_changed()

Glib::SignalProxy< void > Gdk::Screen::signal_size_changed ( )
Slot Prototype:
void on_my_size_changed()

Flags: Run Last

The signal_size_changed() signal is emitted when the pixel width or height of a screen changes.

Since gtkmm 2.2:

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gdk::Screen > wrap ( GdkScreen *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.