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
GdkDisplay
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
display_ptr
Default implementationTyped 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)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) 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 transformationtransform_to
ValueTransformer
to use for backwards transformationReturn 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:
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
property
the 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
DisplaySignalName
signalDeclaration
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 byuserData
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(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
DisplaySignalName
signalDeclaration
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 byuserData
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:
Extension methodhandler: ) Emitted when the connection to the windowing system for
display
is closed.Note
This represents the underlyingclosed
signalDeclaration
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 errorhandler
The signal handler to call Run the given callback whenever the
closed
signal is emitted -
closedSignal
Extension methodTyped
closed
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var closedSignal: DisplaySignalName { get }
-
onOpened(flags:
Extension methodhandler: ) Emitted when the connection to the windowing system for
display
is opened.Note
This represents the underlyingopened
signalDeclaration
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 methodTyped
opened
signal 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-added
signalDeclaration
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 methodTyped
seat-added
signal 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-removed
signalDeclaration
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 methodTyped
seat-removed
signal 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-changed
signalDeclaration
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 methodTyped
setting-changed
signal 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 innotify
being 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::composited
signalDeclaration
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 methodTyped
notify::composited
signal 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 innotify
being 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-shapes
signalDeclaration
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 methodTyped
notify::input-shapes
signal 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 innotify
being 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::rgba
signalDeclaration
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 methodTyped
notify::rgba
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyRgbaSignal: DisplaySignalName { get }
-
beep()
Extension methodEmits a short beep on
display
Declaration
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
true
if there is an ongoing grab ondevice
fordisplay
.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
GdkAppLaunchContext
suitable 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
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 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-changed
signal 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
nil
if 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
GdkKeymapKey
inkeys
is 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.
GdkEventKey
contains agroup
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
-
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
true
if 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
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. Thelevel
is derived fromstate
.consumed_modifiers
gives modifiers that should be masked out fromstate
when comparing this key press to a keyboard shortcut. For instance, on a US keyboard, theplus
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.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 methodReturns a
GdkAppLaunchContext
suitable for launching applications on the given display.Declaration
Swift
@inlinable var appLaunchContext: AppLaunchContextRef! { get }
-
clipboard
Extension methodGets the clipboard used for copy/paste operations.
Declaration
Swift
@inlinable var clipboard: ClipboardRef! { get }
-
defaultSeat
Extension methodReturns 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 methodFinds out if the display has been closed.
Declaration
Swift
@inlinable var isClosed: Bool { get }
-
isComposited
Extension 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 }
-
isRgba
Extension methodReturns 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 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-changed
signal on this list to monitor changes to the monitor of this display.Declaration
Swift
@inlinable var monitors: GIO.ListModelRef! { get }
-
name
Extension methodGets the name of the display.
Declaration
Swift
@inlinable var name: String! { get }
-
primaryClipboard
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 var primaryClipboard: ClipboardRef! { get }
-
startupNotificationId
Extension methodGets the startup notification ID for a Wayland display, or
nil
if no ID has been defined.Declaration
Swift
@inlinable var startupNotificationId: String! { get }