Gdk.Display

g GObject.Object GObject.Object Gdk.Display Gdk.Display GObject.Object->Gdk.Display

Subclasses:None

Virtual Methods

Inherited:GObject.Object (7)

Properties

None

Signals

Inherited:GObject.Object (1)
Name Short Description
closed The ::closed signal is emitted when the connection to the windowing system for display is closed.
monitor-added The ::monitor-added signal is emitted whenever a monitor is added.
monitor-removed The ::monitor-removed signal is emitted whenever a monitor is removed.
opened The ::opened signal is emitted when the connection to the windowing system for display is opened.
seat-added The ::seat-added signal is emitted whenever a new seat is made known to the windowing system.
seat-removed The ::seat-removed signal is emitted whenever a seat is removed by the windowing system.

Fields

Inherited:GObject.Object (1)

Class Details

class Gdk.Display(**kwargs)
Bases:GObject.Object
Abstract:No

Gdk.Display objects purpose are two fold:

  • To manage and provide information about input devices (pointers and keyboards)
  • To manage and provide information about the available Gdk.Screens

Gdk.Display objects are the GDK representation of an X Display, which can be described as a workstation consisting of a keyboard, a pointing device (such as a mouse) and one or more screens. It is used to open and keep track of various Gdk.Screen objects currently instantiated by the application. It is also used to access the keyboard(s) and mouse pointer(s) of the display.

Most of the input device handling has been factored out into the separate Gdk.DeviceManager object. Every display has a device manager, which you can obtain using Gdk.Display.get_device_manager().

classmethod get_default()[source]
Returns:a Gdk.Display, or None if there is no default display.
Return type:Gdk.Display or None

Gets the default Gdk.Display. This is a convenience function for: gdk_display_manager_get_default_display (gdk_display_manager_get ()).

New in version 2.2.

classmethod open(display_name)[source]
Parameters:display_name (str) – the name of the display to open
Returns:a Gdk.Display, or None if the display could not be opened
Return type:Gdk.Display or None

Opens a display.

New in version 2.2.

classmethod open_default_libgtk_only()[source]
Returns:the default display, if it could be opened, otherwise None.
Return type:Gdk.Display or None

Opens the default display specified by command line arguments or environment variables, sets it as the default display, and returns it. Gdk.parse_args() must have been called first. If the default display has previously been set, simply returns that. An internal function that should not be used by applications.

Deprecated since version 3.16: This symbol was never meant to be used outside of GTK+

beep()[source]

Emits a short beep on self

New in version 2.2.

close()[source]

Closes the connection to the windowing system for the given display, and cleans up associated resources.

New in version 2.2.

device_is_grabbed(device)[source]
Parameters:device (Gdk.Device) – a Gdk.Device
Returns:True if there is a grab in effect for device.
Return type:bool

Returns True if there is an ongoing grab on device for self.

flush()[source]

Flushes any requests queued for the windowing system; this happens automatically when the main loop blocks waiting for new events, but if your application is drawing without returning control to the main loop, you may need to call this function explicitly. A common case where this function needs to be called is when an application is executing drawing commands from a thread other than the thread where the main loop is running.

This is most useful for X11. On windowing systems where requests are handled synchronously, this function will do nothing.

New in version 2.4.

get_app_launch_context()[source]
Returns:a new Gdk.AppLaunchContext for self. Free with GObject.Object.unref() when done
Return type:Gdk.AppLaunchContext

Returns a Gdk.AppLaunchContext suitable for launching applications on the given display.

New in version 3.0.

get_default_cursor_size()[source]
Returns:the default cursor size.
Return type:int

Returns the default size to use for cursors on self.

New in version 2.4.

get_default_group()[source]
Returns:The default group leader window for self
Return type:Gdk.Window

Returns the default group leader window for all toplevel windows on self. This window is implicitly created by GDK. See Gdk.Window.set_group().

New in version 2.4.

get_default_screen()[source]
Returns:the default Gdk.Screen object for self
Return type:Gdk.Screen

Get the default Gdk.Screen for self.

New in version 2.2.

get_default_seat()[source]
Returns:the default seat.
Return type:Gdk.Seat

Returns the default Gdk.Seat for this display.

New in version 3.20.

get_device_manager()[source]
Returns:A Gdk.DeviceManager, or None. This memory is owned by GDK and must not be freed or unreferenced.
Return type:Gdk.DeviceManager or None

Returns the Gdk.DeviceManager associated to self.

New in version 3.0.

Deprecated since version 3.20.: Use Gdk.Display.get_default_seat() and Gdk.Seat operations.

get_event()[source]
Returns:the next Gdk.Event to be processed, or None if no events are pending. The returned Gdk.Event should be freed with Gdk.Event.free().
Return type:Gdk.Event or None

Gets the next Gdk.Event to be processed for self, fetching events from the windowing system if necessary.

New in version 2.2.

get_maximal_cursor_size()[source]
Returns:
width:the return location for the maximal cursor width
height:the return location for the maximal cursor height
Return type:(width: int, height: int)

Gets the maximal size to use for cursors on self.

New in version 2.4.

get_monitor(monitor_num)[source]
Parameters:monitor_num (int) – number of the monitor
Returns:the Gdk.Monitor, or None if monitor_num is not a valid monitor number
Return type:Gdk.Monitor or None

Gets a monitor associated with this display.

New in version 3.22.

get_monitor_at_point(x, y)[source]
Parameters:
  • x (int) – the x coordinate of the point
  • y (int) – the y coordinate of the point
Returns:

the monitor containing the point

Return type:

Gdk.Monitor

Gets the monitor in which the point (x, y) is located, or a nearby monitor if the point is not in any monitor.

New in version 3.22.

get_monitor_at_window(window)[source]
Parameters:window (Gdk.Window) – a Gdk.Window
Returns:the monitor with the largest overlap with window
Return type:Gdk.Monitor

Gets the monitor in which the largest area of window resides, or a monitor close to window if it is outside of all monitors.

New in version 3.22.

get_n_monitors()[source]
Returns:the number of monitors
Return type:int

Gets the number of monitors that belong to self.

The returned number is valid until the next emission of the Gdk.Display ::monitor-added or Gdk.Display ::monitor-removed signal.

New in version 3.22.

get_n_screens()[source]
Returns:number of screens.
Return type:int

Gets the number of screen managed by the self.

New in version 2.2.

Deprecated since version 3.10: The number of screens is always 1.

get_name()[source]
Returns:a string representing the display name. This string is owned by GDK and should not be modified or freed.
Return type:str

Gets the name of the display.

New in version 2.2.

get_pointer()[source]
Returns:
screen:location to store the screen that the cursor is on, or None.
x:location to store root window X coordinate of pointer, or None.
y:location to store root window Y coordinate of pointer, or None.
mask:location to store current modifier mask, or None
Return type:(screen: Gdk.Screen, x: int, y: int, mask: Gdk.ModifierType)

Gets the current location of the pointer and the current modifier mask for a given display.

New in version 2.2.

Deprecated since version 3.0: Use Gdk.Device.get_position() instead.

get_primary_monitor()[source]
Returns:the primary monitor, or None if no primary monitor is configured by the user
Return type:Gdk.Monitor or None

Gets the primary monitor for the display.

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.

New in version 3.22.

get_screen(screen_num)[source]
Parameters:screen_num (int) – the screen number
Returns:the Gdk.Screen object
Return type:Gdk.Screen

Returns a screen object for one of the screens of the display.

New in version 2.2.

Deprecated since version 3.20: There is only one screen; use Gdk.Display.get_default_screen() to get it.

get_window_at_pointer()[source]
Returns:the window under the mouse pointer, or None
win_x:return location for x coordinate of the pointer location relative to the window origin, or None
win_y:return location for y coordinate of the pointer location relative & to the window origin, or None
Return type:(Gdk.Window or None, win_x: int, win_y: int)

Obtains the window underneath the mouse pointer, returning the location of the pointer in that window in win_x, win_y for screen. Returns None if the window under the mouse pointer is not known to GDK (for example, belongs to another application).

New in version 2.2.

Deprecated since version 3.0: Use Gdk.Device.get_window_at_position() instead.

has_pending()[source]
Returns:True if there are events ready to be processed.
Return type:bool

Returns whether the display has events that are waiting to be processed.

New in version 3.0.

is_closed()[source]
Returns:True if the display is closed.
Return type:bool

Finds out if the display has been closed.

New in version 2.22.

keyboard_ungrab(time_)[source]
Parameters:time (int) – a timestap (e.g Gdk.CURRENT_TIME).

Release any keyboard grab

New in version 2.2.

Deprecated since version 3.0: Use Gdk.Device.ungrab(), together with Gdk.Device.grab() instead.

list_devices()[source]
Returns:a list of Gdk.Device
Return type:[Gdk.Device]

Returns the list of available input devices attached to self. The list is statically allocated and should not be freed.

New in version 2.2.

Deprecated since version 3.0: Use Gdk.DeviceManager.list_devices() instead.

list_seats()[source]
Returns:the list of seats known to the Gdk.Display
Return type:[Gdk.Seat]

Returns the list of seats known to self.

New in version 3.20.

notify_startup_complete(startup_id)[source]
Parameters:startup_id (str) – a startup-notification identifier, for which notification process should be completed

Indicates to the GUI environment that the application has finished loading, using a given identifier.

GTK+ will call this function automatically for #GtkWindow with custom startup-notification identifier unless gtk_window_set_auto_startup_notification() is called to disable that feature.

New in version 3.0.

peek_event()[source]
Returns:a copy of the first Gdk.Event on the event queue, or None if no events are in the queue. The returned Gdk.Event should be freed with Gdk.Event.free().
Return type:Gdk.Event or None

Gets a copy of the first Gdk.Event in the self’s event queue, without removing the event from the queue. (Note that this function will not get more events from the windowing system. It only checks the events that have already been moved to the GDK event queue.)

New in version 2.2.

pointer_is_grabbed()[source]
Returns:True if an active X pointer grab is in effect
Return type:bool

Test if the pointer is grabbed.

New in version 2.2.

Deprecated since version 3.0: Use Gdk.Display.device_is_grabbed() instead.

pointer_ungrab(time_)[source]
Parameters:time (int) – a timestap (e.g. Gdk.CURRENT_TIME).

Release any pointer grab.

New in version 2.2.

Deprecated since version 3.0: Use Gdk.Device.ungrab(), together with Gdk.Device.grab() instead.

put_event(event)[source]
Parameters:event (Gdk.Event) – a Gdk.Event.

Appends a copy of the given event onto the front of the event queue for self.

New in version 2.2.

request_selection_notification(selection)[source]
Parameters:selection (Gdk.Atom) – the Gdk.Atom naming the selection for which ownership change notification is requested
Returns:whether Gdk.EventOwnerChange events will be sent.
Return type:bool

Request Gdk.EventOwnerChange events for ownership changes of the selection named by the given atom.

New in version 2.6.

set_double_click_distance(distance)[source]
Parameters:distance (int) – distance in pixels

Sets the double click distance (two clicks within this distance count as a double click and result in a Gdk.EventType._2BUTTON_PRESS event). See also Gdk.Display.set_double_click_time(). Applications should not set this, it is a global user-configured setting.

New in version 2.4.

set_double_click_time(msec)[source]
Parameters:msec (int) – double click time in milliseconds (thousandths of a second)

Sets the double click time (two clicks within this time interval count as a double click and result in a Gdk.EventType._2BUTTON_PRESS event). Applications should not set this, it is a global user-configured setting.

New in version 2.2.

store_clipboard(clipboard_window, time_, targets)[source]
Parameters:
  • clipboard_window (Gdk.Window) – a Gdk.Window belonging to the clipboard owner
  • time (int) – a timestamp
  • targets ([Gdk.Atom] or None) – an array of targets that should be saved, or None if all available targets should be saved.

Issues a request to the clipboard manager to store the clipboard data. On X11, this is a special program that works according to the FreeDesktop Clipboard Specification.

New in version 2.6.

supports_clipboard_persistence()[source]
Returns:True if the display supports clipboard persistance.
Return type:bool

Returns whether the speicifed display supports clipboard persistance; i.e. if it’s possible to store the clipboard data after an application has quit. On X11 this checks if a clipboard daemon is running.

New in version 2.6.

supports_composite()[source]
Returns:True if windows may be composited.
Return type:bool

Returns True if Gdk.Window.set_composited() can be used to redirect drawing on the window using compositing.

Currently this only works on X11 with XComposite and XDamage extensions available.

New in version 2.12.

Deprecated since version 3.16: Compositing is an outdated technology that only ever worked on X11.

supports_cursor_alpha()[source]
Returns:whether cursors can have alpha channels.
Return type:bool

Returns True if cursors can use an 8bit alpha channel on self. Otherwise, cursors are restricted to bilevel alpha (i.e. a mask).

New in version 2.4.

supports_cursor_color()[source]
Returns:whether cursors can have multiple colors.
Return type:bool

Returns True if multicolored cursors are supported on self. Otherwise, cursors have only a forground and a background color.

New in version 2.4.

supports_input_shapes()[source]
Returns:True if windows with modified input shape are supported
Return type:bool

Returns True if gdk_window_input_shape_combine_mask() can be used to modify the input shape of windows on self.

New in version 2.10.

supports_selection_notification()[source]
Returns:whether Gdk.EventOwnerChange events will be sent.
Return type:bool

Returns whether Gdk.EventOwnerChange events will be sent when the owner of a selection changes.

New in version 2.6.

supports_shapes()[source]
Returns:True if shaped windows are supported
Return type:bool

Returns True if gdk_window_shape_combine_mask() can be used to create shaped windows on self.

New in version 2.10.

sync()[source]

Flushes any requests queued for the windowing system and waits until all requests have been handled. This is often used for making sure that the display is synchronized with the current state of the program. Calling Gdk.Display.sync() before Gdk.error_trap_pop() makes sure that any errors generated from earlier requests are handled before the error trap is removed.

This is most useful for X11. On windowing systems where requests are handled synchronously, this function will do nothing.

New in version 2.2.

warp_pointer(screen, x, y)[source]
Parameters:
  • screen (Gdk.Screen) – the screen of self to warp the pointer to
  • x (int) – the x coordinate of the destination
  • y (int) – the y coordinate of the destination

Warps the pointer of self to the point x,`y` on the screen screen, unless the pointer is confined to a window by a grab, in which case it will be moved as far as allowed by the grab. Warping the pointer creates events as if the user had moved the mouse instantaneously to the destination.

Note that the pointer should normally be under the control of the user. This function was added to cover some rare use cases like keyboard navigation support for the color picker in the #GtkColorSelectionDialog.

New in version 2.8.

Deprecated since version 3.0: Use Gdk.Device.warp() instead.

Signal Details

Gdk.Display.signals.closed(display, is_error)
Signal Name:

closed

Flags:

RUN_LAST

Parameters:
  • display (Gdk.Display) – The object which received the signal
  • is_error (bool) – True if the display was closed due to an error

The ::closed signal is emitted when the connection to the windowing system for display is closed.

New in version 2.2.

Gdk.Display.signals.monitor_added(display, monitor)
Signal Name:

monitor-added

Flags:

RUN_LAST

Parameters:
  • display (Gdk.Display) – The object which received the signal
  • monitor (Gdk.Monitor) – the monitor that was just added

The ::monitor-added signal is emitted whenever a monitor is added.

New in version 3.22.

Gdk.Display.signals.monitor_removed(display, monitor)
Signal Name:

monitor-removed

Flags:

RUN_LAST

Parameters:
  • display (Gdk.Display) – The object which received the signal
  • monitor (Gdk.Monitor) – the monitor that was just removed

The ::monitor-removed signal is emitted whenever a monitor is removed.

New in version 3.22.

Gdk.Display.signals.opened(display)
Signal Name:opened
Flags:RUN_LAST
Parameters:display (Gdk.Display) – The object which received the signal

The ::opened signal is emitted when the connection to the windowing system for display is opened.

Gdk.Display.signals.seat_added(display, seat)
Signal Name:

seat-added

Flags:

RUN_LAST

Parameters:
  • display (Gdk.Display) – The object which received the signal
  • seat (Gdk.Seat) – the seat that was just added

The ::seat-added signal is emitted whenever a new seat is made known to the windowing system.

New in version 3.20.

Gdk.Display.signals.seat_removed(display, seat)
Signal Name:

seat-removed

Flags:

RUN_LAST

Parameters:
  • display (Gdk.Display) – The object which received the signal
  • seat (Gdk.Seat) – the seat that was just removed

The ::seat-removed signal is emitted whenever a seat is removed by the windowing system.

New in version 3.20.