1.15 <GdkDisplay>

Class: <GdkDisplay>

It derives from <GObject>.

A representation of a workstation.

Their purpose are two-fold:

  • To manage and provide information about input devices (pointers, keyboards, etc)
  • To manage and provide information about output devices (monitors, projectors, etc)

Most of the input device handling has been factored out into separate <GdkSeat> objects. Every display has a one or more seats, which can be accessed with display:get-default-seat and display:list-seats.

Output devices are represented by <GdkMonitor> objects, which can be accessed with display:get-monitor-at-surface and similar APIs.

Properties

Property: display:composited self

#t if the display properly composites the alpha channel.

Its value is a boolean.

It is read only.

Property: display:dmabuf-formats self

The dma-buf formats that are supported on this display

Its value is a <GdkDmabufFormats>, or #f.

It is read only.

Property: display:input-shapes self

#t if the display supports input shapes.

Its value is a boolean.

It is read only.

Property: display:rgba self

#t if the display supports an alpha channel.

Its value is a boolean.

It is read only.

Property: display:shadow-width self

#t if the display supports extensible frames.

Its value is a boolean.

It is read only.

Procedures

Method: display:beep self
Method: beep self

Emits a short beep on self

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

Method: display:close self
Method: close self

Closes the connection to the windowing system for the given display.

This cleans up associated resources.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

Method: display:create-gl-context self ⇒ %return
Method: create-gl-context self ⇒ %return

Creates a new <GdkGLContext> for the <GdkDisplay>.

The context is disconnected from any particular surface or surface and cannot be used to draw to any surface. It can only be used to draw to non-surface framebuffers like textures.

If the creation of the <GdkGLContext> failed, error will be set. Before using the returned <GdkGLContext>, you will need to call glcontext:make-current or glcontext:realize?.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a <GdkGLContext>.

the newly created <GdkGLContext>

Method: display:device-is-grabbed? self device ⇒ %return
Method: device-is-grabbed? self device ⇒ %return

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

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

device

Passed: a <GdkDevice>.

a <GdkDevice>

%return

Returned: a boolean.

#t if there is a grab in effect for device.

Method: display:flush self
Method: flush self

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.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

Method: display:get-app-launch-context self ⇒ %return
Method: get-app-launch-context self ⇒ %return

Returns a <GdkAppLaunchContext> suitable for launching applications on the given display.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a <GdkAppLaunchContext>.

a new <GdkAppLaunchContext> for self

Method: display:get-clipboard self ⇒ %return
Method: get-clipboard self ⇒ %return

Gets the clipboard used for copy/paste operations.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a <GdkClipboard>.

the display’s clipboard

Procedure: display:get-default ⇒ %return

Gets the default <GdkDisplay>.

This is a convenience function for:

gdk_display_manager_get_default_display (gdk_display_manager_get ())

%return

Returned: a <GdkDisplay>, or #f.

a <GdkDisplay>, or #f if there is no default display

Method: display:get-default-seat self ⇒ %return
Method: get-default-seat self ⇒ %return

Returns the default <GdkSeat> for this display.

Note that a display may not have a seat. In this case, this function will return #f.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a <GdkSeat>, or #f.

the default seat.

Method: display:get-dmabuf-formats self ⇒ %return
Method: get-dmabuf-formats self ⇒ %return

Returns the dma-buf formats that are supported on this display.

GTK may use OpenGL or Vulkan to support some formats. Calling this function will then initialize them if they aren’t yet.

The formats returned by this function can be used for negotiating buffer formats with producers such as v4l, pipewire or GStreamer.

To learn more about dma-bufs, see <GdkDmabufTextureBuilder>.

This function is threadsafe. It can be called from any thread.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a <GdkDmabufFormats>.

a <GdkDmabufFormats> object

Method: display:get-monitor-at-surface self surface ⇒ %return
Method: get-monitor-at-surface self surface ⇒ %return

Gets the monitor in which the largest area of surface resides.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

surface

Passed: a <GdkSurface>.

a <GdkSurface>

%return

Returned: a <GdkMonitor>, or #f.

the monitor with the largest overlap with surface

Method: display:get-monitors self ⇒ %return
Method: get-monitors self ⇒ %return

Gets the list of monitors associated with this display.

Subsequent calls to this function will always return the same list for the same display.

You can listen to the GListModel::items-changed signal on this list to monitor changes to the monitor of this display.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a <GListModel>.

a <GListModel> of <GdkMonitor>

Method: display:get-name self ⇒ %return
Method: get-name self ⇒ %return

Gets the name of the display.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a string.

a string representing the display name. This string is owned by GDK and should not be modified or freed.

Method: display:get-primary-clipboard self ⇒ %return
Method: get-primary-clipboard self ⇒ %return

Gets the clipboard used for the primary selection.

On backends where the primary clipboard is not supported natively, GDK emulates this clipboard locally.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a <GdkClipboard>.

the primary clipboard

Method: display:get-setting? self name value ⇒ %return
Method: get-setting? self name value ⇒ %return

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

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

name

Passed: a string.

the name of the setting

value

Passed: a <GValue>.

location to store the value of the setting

%return

Returned: a boolean.

#t if the setting existed and a value was stored in value, #f otherwise

Method: display:get-startup-notification-id self ⇒ %return
Method: get-startup-notification-id self ⇒ %return

Gets the startup notification ID for a Wayland display, or #f if no ID has been defined.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a string, or #f.

the startup notification ID for self

Method: display:is-closed? self ⇒ %return
Method: is-closed? self ⇒ %return

Finds out if the display has been closed.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a boolean.

#t if the display is closed.

Method: display:is-composited? self ⇒ %return
Method: is-composited? self ⇒ %return

Returns whether surfaces can reasonably be expected to have their alpha channel drawn correctly on the screen.

Check display:is-rgba? for whether the display supports an alpha channel.

On X11 this function returns whether a compositing manager is compositing on self.

On modern displays, this value is always #t.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a boolean.

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

Method: display:is-rgba? self ⇒ %return
Method: is-rgba? self ⇒ %return

Returns whether surfaces on this self are created with an alpha channel.

Even if a #t is returned, it is possible that the surface’s alpha channel won’t be honored when displaying the surface on the screen: in particular, for X an appropriate windowing manager and compositing manager must be running to provide appropriate display. Use display:is-composited? to check if that is the case.

On modern displays, this value is always #t.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a boolean.

#t if surfaces are created with an alpha channel or #f if the display does not support this functionality.

Method: display:list-seats self ⇒ %return
Method: list-seats self ⇒ %return

Returns the list of seats known to self.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a list, each a <GdkSeat>.

the list of seats known to the <GdkDisplay>

Method: display:map-keycode self keycode ⇒ %return keys keyvals
Method: map-keycode self keycode ⇒ %return keys keyvals

Returns the keyvals bound to keycode.

The Nth <GdkKeymapKey> in keys is bound to the Nth keyval in keyvals.

When a keycode is pressed by the user, the keyval from this list of entries is selected by considering the effective keyboard group and level.

Free the returned arrays with byte-array:free.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

keycode

Passed: an unsigned 32-bit integer.

a keycode

%return

Returned: a boolean.

#t if there were any entries

keys

Returned: a vector, each a <GdkKeymapKey>.

return location for array of <GdkKeymapKey>

keyvals

Returned: an u32vector.

return location for array of keyvals

n-entries

Not returned: it is the length of keyvals.

length of keys and keyvals

Method: display:map-keyval self keyval ⇒ %return keys
Method: map-keyval self keyval ⇒ %return keys

Obtains a list of keycode/group/level combinations that will generate keyval.

Groups and levels are two kinds of keyboard mode; in general, the level determines whether the top or bottom symbol on a key is used, and the group determines whether the left or right symbol is used.

On US keyboards, the shift key changes the keyboard level, and there are no groups. A group switch key might convert a keyboard between Hebrew to English modes, for example.

GdkEventKey contains a group field that indicates the active keyboard group. The level is computed from the modifier mask.

The returned array should be freed with byte-array:free.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

keyval

Passed: an unsigned 32-bit integer.

a keyval, such as GDK_KEY_a, GDK_KEY_Up, GDK_KEY_Return, etc.

%return

Returned: a boolean.

#t if keys were found and returned

keys

Returned: a vector, each a <GdkKeymapKey>.

return location for an array of <GdkKeymapKey>

n-keys

Not returned: it is the length of keys.

return location for number of elements in returned array

Method: display:notify-startup-complete self startup-id
Method: notify-startup-complete self startup-id

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.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

startup-id

Passed: a string.

a startup-notification identifier, for which notification process should be completed

Procedure: display:open [display-name] ⇒ %return

Opens a display.

If opening the display fails, NULL is returned.

display-name

Passed, or left out: a string, or #f.

the name of the display to open

%return

Returned: a <GdkDisplay>, or #f.

a <GdkDisplay>

Method: display:prepare-gl? self ⇒ %return
Method: prepare-gl? self ⇒ %return

Checks that OpenGL is available for self and ensures that it is properly initialized. When this fails, an error will be set describing the error and this function returns #f.

Note that even if this function succeeds, creating a <GdkGLContext> may still fail.

This function is idempotent. Calling it multiple times will just return the same value or error.

You never need to call this function, GDK will call it automatically as needed. But you can use it as a check when setting up code that might make use of OpenGL.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a boolean.

#t if the display supports OpenGL

Method: display:put-event self event
Method: put-event self event

Adds the given event to the event queue for self.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

event

Passed: a <GdkEvent>.

a <GdkEvent>

Method: display:supports-input-shapes? self ⇒ %return
Method: supports-input-shapes? self ⇒ %return

Returns #t if the display supports input shapes.

This means that surface:set-input-region can be used to modify the input shape of surfaces on self.

On modern displays, this value is always #t.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a boolean.

#t if surfaces with modified input shape are supported

Method: display:supports-shadow-width? self ⇒ %return
Method: supports-shadow-width? self ⇒ %return

Returns whether it’s possible for a surface to draw outside of the window area.

If #t is returned the application decides if it wants to draw shadows. If #f is returned, the compositor decides if it wants to draw shadows.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

%return

Returned: a boolean.

#t if surfaces can draw shadows or #f if the display does not support this functionality.

Method: display:sync self
Method: sync self

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 display:sync before GdkX11.Display.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.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

Method: display:translate-key self keycode state group ⇒ %return keyval effective-group level consumed
Method: translate-key self keycode state group ⇒ %return keyval effective-group level consumed

Translates the contents of a GdkEventKey into a keyval, effective group, and level.

Modifiers that affected the translation and are thus unavailable for application use are returned in consumed-modifiers.

The effective-group is the group that was actually used for the translation; some keys such as Enter are not affected by the active keyboard group. The level is derived from state.

consumed-modifiers gives modifiers that should be masked out from state when comparing this key press to a keyboard shortcut. For instance, on a US keyboard, the plus symbol is shifted, so when comparing a key press to a <Control>plus accelerator <Shift> should be masked out.

This function should rarely be needed, since GdkEventKey already contains the translated keyval. It is exported for the benefit of virtualized test environments.

self

Passed: a <GdkDisplay>.

a <GdkDisplay>

keycode

Passed: an unsigned 32-bit integer.

a keycode

state

Passed: a <GdkModifierType>, or a list of its symbols, or one of them.

a modifier state

group

Passed: a 32-bit integer.

active keyboard group

%return

Returned: a boolean.

#t if there was a keyval bound to keycode/state/group.

keyval

Returned: an unsigned 32-bit integer.

return location for keyval

effective-group

Returned: a 32-bit integer.

return location for effective group

level

Returned: a 32-bit integer.

return location for level

consumed

Returned: a <GdkModifierType>.

return location for modifiers that were used to determine the group or level

Signals

Signal: display:closed

Connect a handler with (connect object display:closed handler). It is called as (handler self is-error).

Emitted when the connection to the windowing system for display is closed.

self

Passed: a <GdkDisplay>.

is-error

Passed: a boolean.

#t if the display was closed due to an error

Signal: display:opened

Connect a handler with (connect object display:opened handler). It is called as (handler self).

Emitted when the connection to the windowing system for display is opened.

self

Passed: a <GdkDisplay>.

Signal: display:seat-added

Connect a handler with (connect object display:seat-added handler). It is called as (handler self seat).

Emitted whenever a new seat is made known to the windowing system.

self

Passed: a <GdkDisplay>.

seat

Passed: a <GdkSeat>.

the seat that was just added

Signal: display:seat-removed

Connect a handler with (connect object display:seat-removed handler). It is called as (handler self seat).

Emitted whenever a seat is removed by the windowing system.

self

Passed: a <GdkDisplay>.

seat

Passed: a <GdkSeat>.

the seat that was just removed

Signal: display:setting-changed

Connect a handler with (connect object display:setting-changed handler). It is called as (handler self setting).

Emitted whenever a setting changes its value.

self

Passed: a <GdkDisplay>.

setting

Passed: a string.

the name of the setting that changed