Class: Gdk::Display

Inherits:
Object
  • Object
show all
Extended by:
GLib::Deprecatable
Defined in:
lib/gdk4/deprecated.rb

Overview

GdkDisplay objects are the GDK 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 [classGdk.Seat] objects. Every display has a one or more seats, which can be accessed with [methodGdk.Display.get_default_seat] and [methodGdk.Display.list_seats].

Output devices are represented by [classGdk.Monitor] objects, which can be accessed with [methodGdk.Display.get_monitor_at_surface] and similar APIs.

Direct Known Subclasses

GdkX11::X11Display

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultGdk::Display

Gets the default GdkDisplay.

This is a convenience function for:

gdk_display_manager_get_default_display (gdk_display_manager_get ())

Returns:

  • (Gdk::Display)

    a GdkDisplay, or nil if there is no default display

.open(display_name) ⇒ Gdk::Display

Opens a display.

If opening the display fails, NULL is returned.

Parameters:

  • display_name (String)

    the name of the display to open

Returns:

Instance Method Details

#app_launch_contextGdk::AppLaunchContext

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

Returns:

#beepnil

Emits a short beep on display

Returns:

  • (nil)

#clipboardGdk::Clipboard

Gets the clipboard used for copy/paste operations.

Returns:

#closenil

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

This cleans up associated resources.

Returns:

  • (nil)

#composited=(composited) ⇒ Boolean

true if the display properly composites the alpha channel.

Parameters:

  • composited (Boolean)

Returns:

  • (Boolean)

    composited

  • (Boolean)

    composited

#composited?Boolean

true if the display properly composites the alpha channel.

Returns:

  • (Boolean)

    composited

#create_gl_contextGdk::GLContext

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 [methodGdk.GLContext.make_current] or [methodGdk.GLContext.realize].

Returns:

#default_seatGdk::Seat

Returns the default GdkSeat for this display.

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

Returns:

#device_is_grabbed(device) ⇒ Boolean

Returns true if there is an ongoing grab on device for display.

Parameters:

Returns:

  • (Boolean)

    true if there is a grab in effect for device.

#dmabuf_formatsGdk::DmabufFormats

The dma-buf formats that are supported on this display

Returns:

  • (Gdk::DmabufFormats)

    dmabuf-formats

#dmabuf_formats=(dmabuf_formats) ⇒ Gdk::DmabufFormats

The dma-buf formats that are supported on this display

Parameters:

  • dmabuf_formats (Gdk::DmabufFormats)

Returns:

  • (Gdk::DmabufFormats)

    dmabuf-formats

  • (Gdk::DmabufFormats)

    dmabuf-formats

#flushnil

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.

Returns:

  • (nil)

#get_monitor_at_surface(surface) ⇒ Gdk::Monitor

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

Parameters:

Returns:

  • (Gdk::Monitor)

    the monitor with the largest overlap with surface

#get_setting(name, value) ⇒ Boolean

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

Parameters:

  • name (String)

    the name of the setting

  • value (GObject::Value)

    location to store the value of the setting

Returns:

  • (Boolean)

    true if the setting existed and a value was stored in value, false otherwise

#input_shapes=(input_shapes) ⇒ Boolean

true if the display supports input shapes.

Parameters:

  • input_shapes (Boolean)

Returns:

  • (Boolean)

    input-shapes

  • (Boolean)

    input-shapes

#input_shapes?Boolean

true if the display supports input shapes.

Returns:

  • (Boolean)

    input-shapes

#is_closedBoolean

Finds out if the display has been closed.

Returns:

  • (Boolean)

    true if the display is closed.

#is_compositedBoolean

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

Check [methodGdk.Display.is_rgba] for whether the display supports an alpha channel.

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

On modern displays, this value is always true.

Returns:

  • (Boolean)

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

#is_rgbaBoolean

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

Even if a true 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 [methodGdk.Display.is_composited] to check if that is the case.

On modern displays, this value is always true.

Returns:

  • (Boolean)

    true if surfaces are created with an alpha channel or false if the display does not support this functionality.

#list_seatsGLib::List<Gdk::Seat>

Returns the list of seats known to display.

Returns:

  • (GLib::List<Gdk::Seat>)

    the list of seats known to the GdkDisplay

#map_keycode(keycode, keys, keyvals, n_entries) ⇒ Boolean

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

Parameters:

  • keycode (Integer)

    a keycode

  • keys (Array<Gdk::KeymapKey>)

    return location for array of GdkKeymapKey

  • keyvals (Array<Integer>)

    return location for array of keyvals

  • n_entries (Integer)

    length of keys and keyvals

Returns:

  • (Boolean)

    true if there were any entries

#map_keyval(keyval, keys, n_keys) ⇒ Boolean

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

Parameters:

  • keyval (Integer)

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

  • keys (Array<Gdk::KeymapKey>)

    return location for an array of GdkKeymapKey

  • n_keys (Integer)

    return location for number of elements in returned array

Returns:

  • (Boolean)

    true if keys were found and returned

#monitorsGio::ListModel

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.

Returns:

  • (Gio::ListModel)

    a GListModel of GdkMonitor

#nameString

Gets the name of the display.

Returns:

  • (String)

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

#notify_startup_complete(startup_id) ⇒ nil

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.

Parameters:

  • startup_id (String)

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

Returns:

  • (nil)

#prepare_glBoolean

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

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.

Returns:

  • (Boolean)

    true if the display supports OpenGL

#primary_clipboardGdk::Clipboard

Gets the clipboard used for the primary selection.

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

Returns:

#put_event(event) ⇒ nil

Adds the given event to the event queue for display.

Parameters:

Returns:

  • (nil)

#rgba=(rgba) ⇒ Boolean

true if the display supports an alpha channel.

Parameters:

  • rgba (Boolean)

Returns:

  • (Boolean)

    rgba

  • (Boolean)

    rgba

#rgba?Boolean

true if the display supports an alpha channel.

Returns:

  • (Boolean)

    rgba

#shadow_width=(shadow_width) ⇒ Boolean

true if the display supports extensible frames.

Parameters:

  • shadow_width (Boolean)

Returns:

  • (Boolean)

    shadow-width

  • (Boolean)

    shadow-width

#shadow_width?Boolean

true if the display supports extensible frames.

Returns:

  • (Boolean)

    shadow-width

#startup_notification_idString

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

Returns:

  • (String)

    the startup notification ID for display

#supports_input_shapesBoolean

Returns true if the display supports input shapes.

This means that [methodGdk.Surface.set_input_region] can be used to modify the input shape of surfaces on display.

On modern displays, this value is always true.

Returns:

  • (Boolean)

    true if surfaces with modified input shape are supported

#supports_shadow_widthBoolean

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

If true is returned the application decides if it wants to draw shadows. If false is returned, the compositor decides if it wants to draw shadows.

Returns:

  • (Boolean)

    true if surfaces can draw shadows or false if the display does not support this functionality.

#syncnil

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 [methodGdk.Display.sync] before [methodGdkX11.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.

Returns:

  • (nil)

#translate_key(keycode, state, group, keyval, effective_group, level, consumed) ⇒ Boolean

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.

Parameters:

  • keycode (Integer)

    a keycode

  • state (Gdk::ModifierType)

    a modifier state

  • group (Integer)

    active keyboard group

  • keyval (Integer)

    return location for keyval

  • effective_group (Integer)

    return location for effective group

  • level (Integer)

    return location for level

  • consumed (Gdk::ModifierType)

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

Returns:

  • (Boolean)

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