Gdk.Screen

g GObject.Object GObject.Object Gdk.Screen Gdk.Screen GObject.Object->Gdk.Screen

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_default ()

class

height ()

class

height_mm ()

class

width ()

class

width_mm ()

get_active_window ()

get_display ()

get_font_options ()

get_height ()

get_height_mm ()

get_monitor_at_point (x, y)

get_monitor_at_window (window)

get_monitor_geometry (monitor_num)

get_monitor_height_mm (monitor_num)

get_monitor_plug_name (monitor_num)

get_monitor_scale_factor (monitor_num)

get_monitor_width_mm (monitor_num)

get_monitor_workarea (monitor_num)

get_n_monitors ()

get_number ()

get_primary_monitor ()

get_resolution ()

get_rgba_visual ()

get_root_window ()

get_setting (name, value)

get_system_visual ()

get_toplevel_windows ()

get_width ()

get_width_mm ()

get_window_stack ()

is_composited ()

list_visuals ()

make_display_name ()

set_font_options (options)

set_resolution (dpi)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

font-options

int

r/w

The default font options for the screen

resolution

float

r/w

The resolution for fonts on the screen

Signals

Inherited:

GObject.Object (1)

Name

Short Description

composited-changed

The ::composited-changed signal is emitted when the composited status of the screen changes

monitors-changed

The ::monitors-changed signal is emitted when the number, size or position of the monitors attached to the screen change.

size-changed

The ::size-changed signal is emitted when the pixel width or height of a screen changes.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gdk.Screen(**kwargs)
Bases:

GObject.Object

Abstract:

No

Gdk.Screen objects are the GDK representation of the screen on which windows can be displayed and on which the pointer moves. X originally identified screens with physical screens, but nowadays it is more common to have a single Gdk.Screen which combines several physical monitors (see Gdk.Screen.get_n_monitors()).

Gdk.Screen 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 default visual (Gdk.Screen.get_system_visual()), the dimensions of the physical monitors (Gdk.Screen.get_monitor_geometry()), etc.

classmethod get_default()[source]
Returns:

a Gdk.Screen, or None if there is no default display.

Return type:

Gdk.Screen or None

Gets the default screen for the default display. (See Gdk.Display.get_default ()).

New in version 2.2.

classmethod height()[source]
Returns:

the height of the default screen in pixels.

Return type:

int

Gets the height of the default screen in pixels. The returned size is in ”application pixels”, not in ”device pixels” (see Gdk.Screen.get_monitor_scale_factor()).

Deprecated since version 3.22: Use per-monitor information

classmethod height_mm()[source]
Returns:

the height of the default screen in millimeters, though it is not always correct.

Return type:

int

Returns the height of the default screen in millimeters. Note that on many X servers this value will not be correct.

Deprecated since version 3.22: Use per-monitor information

classmethod width()[source]
Returns:

the width of the default screen in pixels.

Return type:

int

Gets the width of the default screen in pixels. The returned size is in ”application pixels”, not in ”device pixels” (see Gdk.Screen.get_monitor_scale_factor()).

Deprecated since version 3.22: Use per-monitor information

classmethod width_mm()[source]
Returns:

the width of the default screen in millimeters, though it is not always correct.

Return type:

int

Returns the width of the default screen in millimeters. Note that on many X servers this value will not be correct.

Deprecated since version 3.22: Use per-monitor information

get_active_window()[source]
Returns:

the currently active window, or None.

Return type:

Gdk.Window or None

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 None.

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

The returned window should be unrefed using GObject.Object.unref() when no longer needed.

New in version 2.10.

Deprecated since version 3.22.

get_display()[source]
Returns:

the display to which self belongs

Return type:

Gdk.Display

Gets the display to which the self belongs.

New in version 2.2.

get_font_options()[source]
Returns:

the current font options, or None if no default font options have been set.

Return type:

cairo.FontOptions or None

Gets any options previously set with Gdk.Screen.set_font_options().

New in version 2.10.

get_height()[source]
Returns:

the height of self in pixels.

Return type:

int

Gets the height of self in pixels. The returned size is in ”application pixels”, not in ”device pixels” (see Gdk.Screen.get_monitor_scale_factor()).

New in version 2.2.

Deprecated since version 3.22: Use per-monitor information instead

get_height_mm()[source]
Returns:

the heigth of self in millimeters.

Return type:

int

Returns the height of self 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.

New in version 2.2.

Deprecated since version 3.22: Use per-monitor information instead

get_monitor_at_point(x, y)[source]
Parameters:
  • x (int) – the x coordinate in the virtual screen.

  • y (int) – the 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.

Return type:

int

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

New in version 2.2.

Deprecated since version 3.22: Use Gdk.Display.get_monitor_at_point() instead

get_monitor_at_window(window)[source]
Parameters:

window (Gdk.Window) – a 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.

Return type:

int

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

New in version 2.2.

Deprecated since version 3.22: Use Gdk.Display.get_monitor_at_window() instead

get_monitor_geometry(monitor_num)[source]
Parameters:

monitor_num (int) – the monitor number

Returns:

a Gdk.Rectangle to be filled with the monitor geometry

Return type:

dest: Gdk.Rectangle

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 Gdk.Screen.get_monitor_scale_factor()).

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

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

New in version 2.2.

Deprecated since version 3.22: Use Gdk.Monitor.get_geometry() instead

get_monitor_height_mm(monitor_num)[source]
Parameters:

monitor_num (int) – number of the monitor, between 0 and Gdk.Screen.get_n_monitors (screen)

Returns:

the height of the monitor, or -1 if not available

Return type:

int

Gets the height in millimeters of the specified monitor.

New in version 2.14.

Deprecated since version 3.22: Use Gdk.Monitor.get_height_mm() instead

get_monitor_plug_name(monitor_num)[source]
Parameters:

monitor_num (int) – number of the monitor, between 0 and Gdk.Screen.get_n_monitors (screen)

Returns:

a newly-allocated string containing the name of the monitor, or None if the name cannot be determined

Return type:

str or None

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

New in version 2.14.

Deprecated since version 3.22: Use Gdk.Monitor.get_model() instead

get_monitor_scale_factor(monitor_num)[source]
Parameters:

monitor_num (int) – number of the monitor, between 0 and Gdk.Screen.get_n_monitors (screen)

Returns:

the scale factor

Return type:

int

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.

New in version 3.10.

Deprecated since version 3.22: Use Gdk.Monitor.get_scale_factor() instead

get_monitor_width_mm(monitor_num)[source]
Parameters:

monitor_num (int) – number of the monitor, between 0 and Gdk.Screen.get_n_monitors (screen)

Returns:

the width of the monitor, or -1 if not available

Return type:

int

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

New in version 2.14.

Deprecated since version 3.22: Use Gdk.Monitor.get_width_mm() instead

get_monitor_workarea(monitor_num)[source]
Parameters:

monitor_num (int) – the monitor number

Returns:

a Gdk.Rectangle to be filled with the monitor workarea

Return type:

dest: Gdk.Rectangle

Retrieves the Gdk.Rectangle representing the size and position of the “work area” on a monitor within the entire screen area. The returned geometry is in ”application pixels”, not in ”device pixels” (see Gdk.Screen.get_monitor_scale_factor()).

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

Note that not all backends may have a concept of workarea. This function will return the monitor geometry if a workarea is not available, or does not apply.

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

New in version 3.4.

Deprecated since version 3.22: Use Gdk.Monitor.get_workarea() instead

get_n_monitors()[source]
Returns:

number of monitors which self consists of

Return type:

int

Returns the number of monitors which self consists of.

New in version 2.2.

Deprecated since version 3.22: Use Gdk.Display.get_n_monitors() instead

get_number()[source]
Returns:

the index

Return type:

int

Gets the index of self among the screens in the display to which it belongs. (See Gdk.Screen.get_display())

New in version 2.2.

Deprecated since version 3.22.

get_primary_monitor()[source]
Returns:

An integer index for the primary monitor, or 0 if none is configured.

Return type:

int

Gets the primary monitor for self. 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.

New in version 2.20.

Deprecated since version 3.22: Use Gdk.Display.get_primary_monitor() instead

get_resolution()[source]
Returns:

the current resolution, or -1 if no resolution has been set.

Return type:

float

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

New in version 2.10.

get_rgba_visual()[source]
Returns:

a visual to use for windows with an alpha channel or None if the capability is not available.

Return type:

Gdk.Visual or None

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 None will be returned. Even if a non-None 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().

New in version 2.8.

get_root_window()[source]
Returns:

the root window

Return type:

Gdk.Window

Gets the root window of self.

New in version 2.2.

get_setting(name, value)[source]
Parameters:
  • name (str) – the name of the setting

  • value (GObject.Value) – location to store the value of the setting

Returns:

True if the setting existed and a value was stored in value, False otherwise.

Return type:

bool

Retrieves a desktop-wide setting such as double-click time for the Gdk.Screen self.

FIXME needs a list of valid settings here, or a link to more information.

New in version 2.2.

get_system_visual()[source]
Returns:

the system visual

Return type:

Gdk.Visual

Get the system’s default visual for self. This is the visual for the root window of the display. The return value should not be freed.

New in version 2.2.

get_toplevel_windows()[source]
Returns:

list of toplevel windows, free with g_list_free()

Return type:

[Gdk.Window]

Obtains a list of all toplevel windows known to GDK on the screen self. A toplevel window is a child of the root window (see Gdk.get_default_root_window()).

The returned list should be freed with g_list_free(), but its elements need not be freed.

New in version 2.2.

get_width()[source]
Returns:

the width of self in pixels.

Return type:

int

Gets the width of self in pixels. The returned size is in ”application pixels”, not in ”device pixels” (see Gdk.Screen.get_monitor_scale_factor()).

New in version 2.2.

Deprecated since version 3.22: Use per-monitor information instead

get_width_mm()[source]
Returns:

the width of self in millimeters.

Return type:

int

Gets the width of self 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.

New in version 2.2.

Deprecated since version 3.22: Use per-monitor information instead

get_window_stack()[source]
Returns:

a list of Gdk.Windows for the current window stack, or None.

Return type:

[Gdk.Window] or None

Returns a GLib.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 None.

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

The returned list is newly allocated and owns references to the windows it contains, so it should be freed using g_list_free() and its windows unrefed using GObject.Object.unref() when no longer needed.

New in version 2.10.

is_composited()[source]
Returns:

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

Return type:

bool

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 self.

New in version 2.10.

list_visuals()[source]
Returns:

a list of visuals; the list must be freed, but not its contents

Return type:

[Gdk.Visual]

Lists the available visuals for the specified self. 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.

Call g_list_free() on the return value when you’re finished with it.

New in version 2.2.

make_display_name()[source]
Returns:

a newly allocated string, free with GLib.free()

Return type:

str

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

New in version 2.2.

Deprecated since version 3.22.

set_font_options(options)[source]
Parameters:

options (cairo.FontOptions or None) – a cairo.FontOptions, or None to unset any previously set default font 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.

New in version 2.10.

set_resolution(dpi)[source]
Parameters:

dpi (float) – the resolution in “dots per inch”. (Physical inches aren’t actually involved; the terminology is conventional.)

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).

New in version 2.10.

Signal Details

Gdk.Screen.signals.composited_changed(screen)
Signal Name:

composited-changed

Flags:

RUN_LAST

Parameters:

screen (Gdk.Screen) – The object which received the signal

The ::composited-changed signal is emitted when the composited status of the screen changes

New in version 2.10.

Gdk.Screen.signals.monitors_changed(screen)
Signal Name:

monitors-changed

Flags:

RUN_LAST

Parameters:

screen (Gdk.Screen) – The object which received the signal

The ::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.

New in version 2.14.

Gdk.Screen.signals.size_changed(screen)
Signal Name:

size-changed

Flags:

RUN_LAST

Parameters:

screen (Gdk.Screen) – The object which received the signal

The ::size-changed signal is emitted when the pixel width or height of a screen changes.

New in version 2.2.

Property Details

Gdk.Screen.props.font_options
Name:

font-options

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE

The default font options for the screen

Gdk.Screen.props.resolution
Name:

resolution

Type:

float

Default Value:

-1.0

Flags:

READABLE, WRITABLE

The resolution for fonts on the screen