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.
-
Untyped pointer to the underlying
GdkDisplayinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
display_ptrDefault implementationTyped pointer to the underlying
GdkDisplayinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkDisplayinstance.Declaration
Swift
var display_ptr: UnsafeMutablePointer<GdkDisplay>! { get } -
Required Initialiser for types conforming to
DisplayProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
DisplayPropertyNamesource 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 : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a Display property
Declaration
Swift
@inlinable func get(property: DisplayPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) 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
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
DisplaySignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: DisplaySignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe 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(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
DisplaySignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: DisplaySignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onClosed(flags:Extension methodhandler: ) Emitted when the connection to the windowing system for
displayis closed.Note
This represents the underlyingclosedsignalDeclaration
Swift
@discardableResult @inlinable func onClosed(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ isError: Bool) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
isErrortrueif the display was closed due to an errorhandlerThe signal handler to call Run the given callback whenever the
closedsignal is emitted -
closedSignalExtension methodTyped
closedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var closedSignal: DisplaySignalName { get } -
onOpened(flags:Extension methodhandler: ) Emitted when the connection to the windowing system for
displayis opened.Note
This represents the underlyingopenedsignalDeclaration
Swift
@discardableResult @inlinable func onOpened(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
openedsignal is emitted -
openedSignalExtension methodTyped
openedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var openedSignal: DisplaySignalName { get } -
onSeatAdded(flags:Extension methodhandler: ) Emitted whenever a new seat is made known to the windowing system.
Note
This represents the underlyingseat-addedsignalDeclaration
Swift
@discardableResult @inlinable func onSeatAdded(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ seat: SeatRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
seatthe seat that was just added
handlerThe signal handler to call Run the given callback whenever the
seatAddedsignal is emitted -
seatAddedSignalExtension methodTyped
seat-addedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var seatAddedSignal: DisplaySignalName { get } -
onSeatRemoved(flags:Extension methodhandler: ) Emitted whenever a seat is removed by the windowing system.
Note
This represents the underlyingseat-removedsignalDeclaration
Swift
@discardableResult @inlinable func onSeatRemoved(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ seat: SeatRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
seatthe seat that was just removed
handlerThe signal handler to call Run the given callback whenever the
seatRemovedsignal is emitted -
seatRemovedSignalExtension methodTyped
seat-removedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var seatRemovedSignal: DisplaySignalName { get } -
onSettingChanged(flags:Extension methodhandler: ) Emitted whenever a setting changes its value.
Note
This represents the underlyingsetting-changedsignalDeclaration
Swift
@discardableResult @inlinable func onSettingChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ setting: String) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
settingthe name of the setting that changed
handlerThe signal handler to call Run the given callback whenever the
settingChangedsignal is emitted -
settingChangedSignalExtension methodTyped
setting-changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var settingChangedSignal: DisplaySignalName { get } -
onNotifyComposited(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::compositedsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyComposited(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyCompositedsignal is emitted -
notifyCompositedSignalExtension methodTyped
notify::compositedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyCompositedSignal: DisplaySignalName { get } -
onNotifyInputShapes(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::input-shapessignalDeclaration
Swift
@discardableResult @inlinable func onNotifyInputShapes(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyInputShapessignal is emitted -
notifyInputShapesSignalExtension methodTyped
notify::input-shapessignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyInputShapesSignal: DisplaySignalName { get } -
onNotifyRgba(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::rgbasignalDeclaration
Swift
@discardableResult @inlinable func onNotifyRgba(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyRgbasignal is emitted -
notifyRgbaSignalExtension methodTyped
notify::rgbasignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyRgbaSignal: DisplaySignalName { get }
-
beep()Extension methodEmits a short beep on
displayDeclaration
Swift
@inlinable func beep() -
close()Extension methodCloses 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
trueif there is an ongoing grab ondevicefordisplay.Declaration
Swift
@inlinable func deviceIsGrabbed<DeviceT>(device: DeviceT) -> Bool where DeviceT : DeviceProtocol -
flush()Extension methodFlushes 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 methodReturns a
GdkAppLaunchContextsuitable for launching applications on the given display.Declaration
Swift
@inlinable func getAppLaunchContext() -> AppLaunchContextRef! -
getClipboard()Extension methodGets the clipboard used for copy/paste operations.
Declaration
Swift
@inlinable func getClipboard() -> ClipboardRef! -
getDefaultSeat()Extension methodReturns the default
GdkSeatfor 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
surfaceresides.Returns a monitor close to
surfaceif it is outside of all monitors.Declaration
Swift
@inlinable func getMonitorAt<SurfaceT>(surface: SurfaceT) -> MonitorRef! where SurfaceT : SurfaceProtocol -
getMonitors()Extension methodGets 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-changedsignal on this list to monitor changes to the monitor of this display.Declaration
Swift
@inlinable func getMonitors() -> GIO.ListModelRef! -
getName()Extension methodGets the name of the display.
Declaration
Swift
@inlinable func getName() -> String! -
getPrimaryClipboard()Extension methodGets 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:Extension methodvalue: ) 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 methodGets the startup notification ID for a Wayland display, or
nilif no ID has been defined.Declaration
Swift
@inlinable func getStartupNotificationId() -> String! -
listSeats()Extension methodReturns the list of seats known to
display.Declaration
Swift
@inlinable func listSeats() -> GLib.ListRef! -
map(keycode:Extension methodkeys: keyvals: nEntries: ) Returns the keyvals bound to
keycode.The Nth
GdkKeymapKeyinkeysis bound to the Nth keyval inkeyvals.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:Extension methodkeys: nKeys: ) 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.
GdkEventKeycontains agroupfield 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 -
notifyStartupComplete(startupId:Extension method) Indicates to the GUI environment that the application has finished loading, using a given identifier.
GTK will call this function automatically for [class
Gtk.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 methodReturns
trueif the display supports input shapes.This means that [method
Gdk.Surface.set_input_region] can be used to modify the input shape of surfaces ondisplay.On modern displays, this value is always
true.Declaration
Swift
@inlinable func supportsInputShapes() -> Bool -
sync()Extension methodFlushes 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 [method
Gdk.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
GdkEventKeyinto 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_groupis the group that was actually used for the translation; some keys such as Enter are not affected by the active keyboard group. Thelevelis derived fromstate.consumed_modifiersgives modifiers that should be masked out fromstatewhen comparing this key press to a keyboard shortcut. For instance, on a US keyboard, theplussymbol is shifted, so when comparing a key press to a<Control>plusaccelerator<Shift>should be masked out.This function should rarely be needed, since
GdkEventKeyalready 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 -
appLaunchContextExtension methodReturns a
GdkAppLaunchContextsuitable for launching applications on the given display.Declaration
Swift
@inlinable var appLaunchContext: AppLaunchContextRef! { get } -
clipboardExtension methodGets the clipboard used for copy/paste operations.
Declaration
Swift
@inlinable var clipboard: ClipboardRef! { get } -
defaultSeatExtension methodReturns the default
GdkSeatfor 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 } -
isClosedExtension methodFinds out if the display has been closed.
Declaration
Swift
@inlinable var isClosed: Bool { get } -
isCompositedExtension methodReturns whether surfaces can reasonably be expected to have their alpha channel drawn correctly on the screen.
Check [method
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.Declaration
Swift
@inlinable var isComposited: Bool { get } -
isRgbaExtension methodReturns whether surfaces on this
displayare created with an alpha channel.Even if a
trueis 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 } -
monitorsExtension methodGets 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-changedsignal on this list to monitor changes to the monitor of this display.Declaration
Swift
@inlinable var monitors: GIO.ListModelRef! { get } -
nameExtension methodGets the name of the display.
Declaration
Swift
@inlinable var name: String! { get } -
primaryClipboardExtension methodGets 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 } -
startupNotificationIdExtension methodGets the startup notification ID for a Wayland display, or
nilif no ID has been defined.Declaration
Swift
@inlinable var startupNotificationId: String! { get }
View on GitHub
Install in Dash
DisplayProtocol Protocol Reference