DisplayProtocol

public protocol DisplayProtocol : ObjectProtocol

The DisplayProtocol protocol exposes the methods and properties of an underlying GdkDisplay instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Display. Alternatively, use DisplayRef as a lighweight, unowned reference if you already have an instance you just want to use.

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.

  • ptr

    Untyped pointer to the underlying GdkDisplay instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • display_ptr Default implementation

    Typed pointer to the underlying GdkDisplay instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GdkDisplay instance.

    Declaration

    Swift

    var display_ptr: UnsafeMutablePointer<GdkDisplay>! { get }
  • Required Initialiser for types conforming to DisplayProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Display Class

  • Bind a DisplayPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: DisplayPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a Display property

    Declaration

    Swift

    @inlinable
    func get(property: DisplayPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a Display property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: DisplayPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Display signals

  • Connect a Swift signal handler to the given, typed DisplaySignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: DisplaySignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    handler

    The Swift signal handler (function or callback) to invoke on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • Connect a C signal handler to the given, typed DisplaySignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: DisplaySignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    signalHandler

    The C function to be called on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • onClosed(flags:handler:) Extension method

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

    Note

    This represents the underlying closed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onClosed(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ isError: Bool) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    isError

    true if the display was closed due to an error

    handler

    The signal handler to call Run the given callback whenever the closed signal is emitted

  • closedSignal Extension method

    Typed closed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var closedSignal: DisplaySignalName { get }
  • onOpened(flags:handler:) Extension method

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

    Note

    This represents the underlying opened signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onOpened(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    handler

    The signal handler to call Run the given callback whenever the opened signal is emitted

  • openedSignal Extension method

    Typed opened signal for using the connect(signal:) methods

    Declaration

    Swift

    static var openedSignal: DisplaySignalName { get }
  • onSeatAdded(flags:handler:) Extension method

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

    Note

    This represents the underlying seat-added signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onSeatAdded(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ seat: SeatRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    seat

    the seat that was just added

    handler

    The signal handler to call Run the given callback whenever the seatAdded signal is emitted

  • seatAddedSignal Extension method

    Typed seat-added signal for using the connect(signal:) methods

    Declaration

    Swift

    static var seatAddedSignal: DisplaySignalName { get }
  • Emitted whenever a seat is removed by the windowing system.

    Note

    This represents the underlying seat-removed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onSeatRemoved(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ seat: SeatRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    seat

    the seat that was just removed

    handler

    The signal handler to call Run the given callback whenever the seatRemoved signal is emitted

  • seatRemovedSignal Extension method

    Typed seat-removed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var seatRemovedSignal: DisplaySignalName { get }
  • Emitted whenever a setting changes its value.

    Note

    This represents the underlying setting-changed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onSettingChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ setting: String) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    setting

    the name of the setting that changed

    handler

    The signal handler to call Run the given callback whenever the settingChanged signal is emitted

  • settingChangedSignal Extension method

    Typed setting-changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var settingChangedSignal: DisplaySignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this: (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::composited signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyComposited(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyComposited signal is emitted

  • notifyCompositedSignal Extension method

    Typed notify::composited signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyCompositedSignal: DisplaySignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this: (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::input-shapes signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyInputShapes(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyInputShapes signal is emitted

  • notifyInputShapesSignal Extension method

    Typed notify::input-shapes signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyInputShapesSignal: DisplaySignalName { get }
  • onNotifyRgba(flags:handler:) Extension method

    The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this: (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::rgba signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyRgba(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyRgba signal is emitted

  • notifyRgbaSignal Extension method

    Typed notify::rgba signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyRgbaSignal: DisplaySignalName { get }

Display Class: DisplayProtocol extension (methods and fields)

  • beep() Extension method

    Emits a short beep on display

    Declaration

    Swift

    @inlinable
    func beep()
  • close() Extension method

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

    This cleans up associated resources.

    Declaration

    Swift

    @inlinable
    func close()
  • deviceIsGrabbed(device:) Extension method

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

    Declaration

    Swift

    @inlinable
    func deviceIsGrabbed<DeviceT>(device: DeviceT) -> Bool where DeviceT : DeviceProtocol
  • flush() Extension method

    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.

    Declaration

    Swift

    @inlinable
    func flush()
  • getAppLaunchContext() Extension method

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

    Declaration

    Swift

    @inlinable
    func getAppLaunchContext() -> AppLaunchContextRef!
  • getClipboard() Extension method

    Gets the clipboard used for copy/paste operations.

    Declaration

    Swift

    @inlinable
    func getClipboard() -> ClipboardRef!
  • getDefaultSeat() Extension method

    Returns the default GdkSeat for this display.

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

    Declaration

    Swift

    @inlinable
    func getDefaultSeat() -> SeatRef!
  • getMonitorAt(surface:) Extension method

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

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

    Declaration

    Swift

    @inlinable
    func getMonitorAt<SurfaceT>(surface: SurfaceT) -> MonitorRef! where SurfaceT : SurfaceProtocol
  • getMonitors() Extension method

    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 GListModelitems-changed signal on this list to monitor changes to the monitor of this display.

    Declaration

    Swift

    @inlinable
    func getMonitors() -> GIO.ListModelRef!
  • getName() Extension method

    Gets the name of the display.

    Declaration

    Swift

    @inlinable
    func getName() -> String!
  • getPrimaryClipboard() Extension method

    Gets the clipboard used for the primary selection.

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

    Declaration

    Swift

    @inlinable
    func getPrimaryClipboard() -> ClipboardRef!
  • getSetting(name:value:) Extension method

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

    Declaration

    Swift

    @inlinable
    func getSetting<ValueT>(name: UnsafePointer<CChar>!, value: ValueT) -> Bool where ValueT : ValueProtocol
  • getStartupNotificationId() Extension method

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

    Declaration

    Swift

    @inlinable
    func getStartupNotificationId() -> String!
  • listSeats() Extension method

    Returns the list of seats known to display.

    Declaration

    Swift

    @inlinable
    func listSeats() -> GLib.ListRef!
  • 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().

    Declaration

    Swift

    @inlinable
    func map(keycode: Int, keys: UnsafeMutablePointer<UnsafeMutablePointer<GdkKeymapKey>?>! = nil, keyvals: UnsafeMutablePointer<UnsafeMutablePointer<guint>?>! = nil, nEntries: UnsafeMutablePointer<gint>!) -> Bool
  • map(keyval:keys:nKeys:) Extension method

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

    Declaration

    Swift

    @inlinable
    func map(keyval: Int, keys: UnsafeMutablePointer<UnsafeMutablePointer<GdkKeymapKey>?>!, nKeys: UnsafeMutablePointer<gint>!) -> Bool
  • Indicates to the GUI environment that the application has finished loading, using a given identifier.

    GTK will call this function automatically for [classGtk.Window] with custom startup-notification identifier unless [methodGtk.Window.set_auto_startup_notification] is called to disable that feature.

    Declaration

    Swift

    @inlinable
    func notifyStartupComplete(startupId: UnsafePointer<CChar>!)
  • put(event:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func put<EventT>(event: EventT) where EventT : EventProtocol
  • supportsInputShapes() Extension method

    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.

    Declaration

    Swift

    @inlinable
    func supportsInputShapes() -> Bool
  • sync() Extension method

    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.

    Declaration

    Swift

    @inlinable
    func sync()
  • 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 &lt;Control&gt;plus accelerator &lt;Shift&gt; 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.

    Declaration

    Swift

    @inlinable
    func translateKey(keycode: Int, state: ModifierType, group: Int, keyval: UnsafeMutablePointer<guint>! = nil, effectiveGroup: UnsafeMutablePointer<gint>! = nil, level: UnsafeMutablePointer<gint>! = nil, consumed: UnsafeMutablePointer<GdkModifierType>! = nil) -> Bool
  • appLaunchContext Extension method

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

    Declaration

    Swift

    @inlinable
    var appLaunchContext: AppLaunchContextRef! { get }
  • clipboard Extension method

    Gets the clipboard used for copy/paste operations.

    Declaration

    Swift

    @inlinable
    var clipboard: ClipboardRef! { get }
  • defaultSeat Extension method

    Returns the default GdkSeat for this display.

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

    Declaration

    Swift

    @inlinable
    var defaultSeat: SeatRef! { get }
  • isClosed Extension method

    Finds out if the display has been closed.

    Declaration

    Swift

    @inlinable
    var isClosed: Bool { get }
  • isComposited Extension method

    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.

    Declaration

    Swift

    @inlinable
    var isComposited: Bool { get }
  • isRgba Extension method

    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.

    Declaration

    Swift

    @inlinable
    var isRgba: Bool { get }
  • monitors Extension method

    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 GListModelitems-changed signal on this list to monitor changes to the monitor of this display.

    Declaration

    Swift

    @inlinable
    var monitors: GIO.ListModelRef! { get }
  • name Extension method

    Gets the name of the display.

    Declaration

    Swift

    @inlinable
    var name: String! { get }
  • primaryClipboard Extension method

    Gets the clipboard used for the primary selection.

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

    Declaration

    Swift

    @inlinable
    var primaryClipboard: ClipboardRef! { get }
  • startupNotificationId Extension method

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

    Declaration

    Swift

    @inlinable
    var startupNotificationId: String! { get }