class Gdk::Display

Overview

Gdk::Display objects are the GDK representation of a workstation.

Their purpose are two-fold:

Most of the input device handling has been factored out into separate Gdk::Seat objects. Every display has a one or more seats, which can be accessed with Gdk::Display#default_seat and Gdk::Display#list_seats.

Output devices are represented by Gdk::Monitor objects, which can be accessed with Gdk::Display#monitor_at_surface and similar APIs.

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/display.cr
bindings/gdk/display.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new #

Initialize a new Display.


[View source]
def self.new(*, composited : Bool | Nil = nil, input_shapes : Bool | Nil = nil, rgba : Bool | Nil = nil) #

[View source]

Class Method Detail

def self.default : Gdk::Display | Nil #

Gets the default Gdk::Display.

This is a convenience function for:

gdk_display_manager_get_default_display (gdk_display_manager_get ())

[View source]
def self.default! : Gdk::Display #

Same as GdkDisplay.default.not_nil!.


[View source]
def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


[View source]
def self.open(display_name : String) : Gdk::Display | Nil #

Opens a display.

If opening the display fails, NULL is returned.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def app_launch_context : Gdk::AppLaunchContext #

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


[View source]
def beep : Nil #

Emits a short beep on display


[View source]
def clipboard : Gdk::Clipboard #

Gets the clipboard used for copy/paste operations.


[View source]
def close : Nil #

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

This cleans up associated resources.


[View source]
def closed_signal #

[View source]
def composited? : Bool #

[View source]
def create_gl_context : Gdk::GLContext #

Creates a new Gdk::GLContext for the Gdk::Display.

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 Gdk::GLContext failed, error will be set. Before using the returned Gdk::GLContext, you will need to call Gdk::GLContext#make_current or Gdk::GLContext#realize.


[View source]
def default_seat : Gdk::Seat | Nil #

Returns the default Gdk::Seat for this display.

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


[View source]
def device_is_grabbed(device : Gdk::Device) : Bool #

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


[View source]
def flush : Nil #

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.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def input_shapes? : Bool #

[View source]
def is_closed : Bool #

Finds out if the display has been closed.


[View source]
def is_composited : Bool #

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

Check Gdk::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.


[View source]
def is_rgba : Bool #

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 Gdk::Display#is_composited? to check if that is the case.

On modern displays, this value is always true.


[View source]
def list_seats : GLib::List #

Returns the list of seats known to display.


[View source]
def map_keycode(keycode : UInt32) : Bool #

Returns the keyvals bound to keycode.

The Nth Gdk::KeymapKey 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().


[View source]
def map_keyval(keyval : UInt32, keys : Enumerable(Gdk::KeymapKey)) : Bool #

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.

Gdk::EventKey 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().


[View source]
def monitor_at_surface(surface : Gdk::Surface) : Gdk::Monitor #

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

Returns a monitor close to surface if it is outside of all monitors.


[View source]
def monitors : Gio::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.


[View source]
def name : String #

Gets the name of the display.


[View source]
def notify_startup_complete(startup_id : String) : Nil #

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

GTK will call this function automatically for Gtk::Window with custom startup-notification identifier unless Gtk::Window#auto_startup_notification= is called to disable that feature.


[View source]
def opened_signal #

[View source]
def prepare_gl : Bool #

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 Gdk::GLContext 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.


[View source]
def primary_clipboard : Gdk::Clipboard #

Gets the clipboard used for the primary selection.

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


[View source]
def put_event(event : Gdk::Event) : Nil #

Appends the given event onto the front of the event queue for display.

This function is only useful in very special situations and should not be used by applications.


[View source]
def rgba? : Bool #

[View source]
def seat_added_signal #

[View source]
def seat_removed_signal #

[View source]
def setting(name : String, value : _) : Bool #

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


[View source]
def setting_changed_signal #

[View source]
def startup_notification_id : String | Nil #

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


[View source]
def supports_input_shapes : Bool #

Returns true if the display supports input shapes.

This means that Gdk::Surface#input_region= can be used to modify the input shape of surfaces on display.

On modern displays, this value is always true.


[View source]
def sync : Nil #

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 [method@Gdk::X11.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.


[View source]
def translate_key(keycode : UInt32, state : Gdk::ModifierType, group : Int32) : Bool #

Translates the contents of a Gdk::EventKey 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 Gdk::EventKey already contains the translated keyval. It is exported for the benefit of virtualized test environments.


[View source]