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 purpose are two fold:
To manage and provide information about input devices (pointers and keyboards)
To manage and provide information about the available
GdkScreens
GdkDisplay objects are the GDK representation of an X Display,
which can be described as a workstation consisting of
a keyboard, a pointing device (such as a mouse) and one or more
screens.
It is used to open and keep track of various GdkScreen objects
currently instantiated by the application. It is also used to
access the keyboard(s)
and mouse pointer(s)
of the display.
Most of the input device handling has been factored out into
the separate GdkDeviceManager
object. Every display has a
device manager, which you can obtain using
gdk_display_get_device_manager()
.
-
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)
-
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: ) The
closed
signal is emitted when the connection to the windowing system fordisplay
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 }
-
onMonitorAdded(flags:
Extension methodhandler: ) The
monitor-added
signal is emitted whenever a monitor is added.Note
This represents the underlyingmonitor-added
signalDeclaration
Swift
@discardableResult @inlinable func onMonitorAdded(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ monitor: MonitorRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
monitor
the monitor that was just added
handler
The signal handler to call Run the given callback whenever the
monitorAdded
signal is emitted -
monitorAddedSignal
Extension methodTyped
monitor-added
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var monitorAddedSignal: DisplaySignalName { get }
-
onMonitorRemoved(flags:
Extension methodhandler: ) The
monitor-removed
signal is emitted whenever a monitor is removed.Note
This represents the underlyingmonitor-removed
signalDeclaration
Swift
@discardableResult @inlinable func onMonitorRemoved(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: DisplayRef, _ monitor: MonitorRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
monitor
the monitor that was just removed
handler
The signal handler to call Run the given callback whenever the
monitorRemoved
signal is emitted -
monitorRemovedSignal
Extension methodTyped
monitor-removed
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var monitorRemovedSignal: DisplaySignalName { get }
-
onOpened(flags:
Extension methodhandler: ) The
opened
signal is emitted when the connection to the windowing system fordisplay
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: ) The
seat-added
signal is 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: ) The
seat-removed
signal is 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 }
-
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, and 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!
-
getDefaultCursorSize()
Extension methodReturns the default size to use for cursors on
display
.Declaration
Swift
@inlinable func getDefaultCursorSize() -> Int
-
getDefaultGroup()
Extension methodReturns the default group leader window for all toplevel windows on
display
. This window is implicitly created by GDK. Seegdk_window_set_group()
.Declaration
Swift
@inlinable func getDefaultGroup() -> WindowRef!
-
getDefaultScreen()
Extension methodGet the default
GdkScreen
fordisplay
.Declaration
Swift
@inlinable func getDefaultScreen() -> ScreenRef!
-
getDefaultSeat()
Extension methodReturns the default
GdkSeat
for this display.Declaration
Swift
@inlinable func getDefaultSeat() -> SeatRef!
-
getDeviceManager()
Extension methodReturns the
GdkDeviceManager
associated todisplay
.get_device_manager is deprecated: Use gdk_display_get_default_seat() and #GdkSeat operations.
Declaration
Swift
@available(*, deprecated) @inlinable func getDeviceManager() -> DeviceManagerRef!
-
getEvent()
Extension methodGets the next
GdkEvent
to be processed fordisplay
, fetching events from the windowing system if necessary.Declaration
Swift
@inlinable func getEvent() -> EventRef!
-
getMaximalCursorSize(width:
Extension methodheight: ) Gets the maximal size to use for cursors on
display
.Declaration
Swift
@inlinable func getMaximalCursorSize(width: UnsafeMutablePointer<guint>!, height: UnsafeMutablePointer<guint>!)
-
getMonitor(monitorNum:
Extension method) Gets a monitor associated with this display.
Declaration
Swift
@inlinable func getMonitor(monitorNum: Int) -> MonitorRef!
-
getMonitorAtPoint(x:
Extension methody: ) Gets the monitor in which the point (
x
,y
) is located, or a nearby monitor if the point is not in any monitor.Declaration
Swift
@inlinable func getMonitorAtPoint(x: Int, y: Int) -> MonitorRef!
-
getMonitorAt(window:
Extension method) Gets the monitor in which the largest area of
window
resides, or a monitor close towindow
if it is outside of all monitors.Declaration
Swift
@inlinable func getMonitorAt<WindowT>(window: WindowT) -> MonitorRef! where WindowT : WindowProtocol
-
getNMonitors()
Extension methodGets the number of monitors that belong to
display
.The returned number is valid until the next emission of the
GdkDisplay::monitor-added
orGdkDisplay::monitor-removed
signal.Declaration
Swift
@inlinable func getNMonitors() -> Int
-
getNScreens()
Extension methodGets the number of screen managed by the
display
.get_n_screens is deprecated: The number of screens is always 1.
Declaration
Swift
@available(*, deprecated) @inlinable func getNScreens() -> Int
-
getName()
Extension methodGets the name of the display.
Declaration
Swift
@inlinable func getName() -> String!
-
getPointer(screen:
Extension methodx: y: mask: ) Gets the current location of the pointer and the current modifier mask for a given display.
get_pointer is deprecated: Use gdk_device_get_position() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getPointer(screen: UnsafeMutablePointer<UnsafeMutablePointer<GdkScreen>?>! = nil, x: UnsafeMutablePointer<gint>! = nil, y: UnsafeMutablePointer<gint>! = nil, mask: UnsafeMutablePointer<GdkModifierType>! = nil)
-
getPrimaryMonitor()
Extension methodGets the primary monitor for the display.
The primary monitor is considered the monitor where the “main desktop” lives. While normal application windows typically allow the window manager to place the windows, specialized desktop applications such as panels should place themselves on the primary monitor.
Declaration
Swift
@inlinable func getPrimaryMonitor() -> MonitorRef!
-
getScreen(screenNum:
Extension method) Returns a screen object for one of the screens of the display.
get_screen is deprecated: There is only one screen; use gdk_display_get_default_screen() to get it.
Declaration
Swift
@available(*, deprecated) @inlinable func getScreen(screenNum: Int) -> ScreenRef!
-
getWindowAtPointer(winX:
Extension methodwinY: ) Obtains the window underneath the mouse pointer, returning the location of the pointer in that window in
win_x
,win_y
forscreen
. Returnsnil
if the window under the mouse pointer is not known to GDK (for example, belongs to another application).get_window_at_pointer is deprecated: Use gdk_device_get_window_at_position() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getWindowAtPointer(winX: UnsafeMutablePointer<gint>! = nil, winY: UnsafeMutablePointer<gint>! = nil) -> WindowRef!
-
hasPending()
Extension methodReturns whether the display has events that are waiting to be processed.
Declaration
Swift
@inlinable func hasPending() -> Bool
-
keyboardUngrab(time_:
Extension method) Release any keyboard grab
keyboard_ungrab is deprecated: Use gdk_device_ungrab(), together with gdk_device_grab() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func keyboardUngrab(time_: guint32)
-
listDevices()
Extension methodReturns the list of available input devices attached to
display
. The list is statically allocated and should not be freed.list_devices is deprecated: Use gdk_device_manager_list_devices() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func listDevices() -> GLib.ListRef!
-
listSeats()
Extension methodReturns the list of seats known to
display
.Declaration
Swift
@inlinable func listSeats() -> GLib.ListRef!
-
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
GtkWindow
with custom startup-notification identifier unlessgtk_window_set_auto_startup_notification()
is called to disable that feature.Declaration
Swift
@inlinable func notifyStartupComplete(startupId: UnsafePointer<gchar>!)
-
peekEvent()
Extension methodGets a copy of the first
GdkEvent
in thedisplay
’s event queue, without removing the event from the queue. (Note that this function will not get more events from the windowing system. It only checks the events that have already been moved to the GDK event queue.)Declaration
Swift
@inlinable func peekEvent() -> EventRef!
-
pointerIsGrabbed()
Extension methodTest if the pointer is grabbed.
pointer_is_grabbed is deprecated: Use gdk_display_device_is_grabbed() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func pointerIsGrabbed() -> Bool
-
pointerUngrab(time_:
Extension method) Release any pointer grab.
pointer_ungrab is deprecated: Use gdk_device_ungrab(), together with gdk_device_grab() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func pointerUngrab(time_: guint32)
-
put(event:
Extension method) Appends a copy of the given event onto the front of the event queue for
display
.Declaration
Swift
@inlinable func put<EventT>(event: EventT) where EventT : EventProtocol
-
requestSelectionNotification(selection:
Extension method) Request
GdkEventOwnerChange
events for ownership changes of the selection named by the given atom.Declaration
Swift
@inlinable func requestSelectionNotification(selection: GdkAtom!) -> Bool
-
setDoubleClick(distance:
Extension method) Sets the double click distance (two clicks within this distance count as a double click and result in a
GDK_2BUTTON_PRESS
event). See alsogdk_display_set_double_click_time()
. Applications should not set this, it is a global user-configured setting.Declaration
Swift
@inlinable func setDoubleClick(distance: Int)
-
setDoubleClickTime(msec:
Extension method) Sets the double click time (two clicks within this time interval count as a double click and result in a
GDK_2BUTTON_PRESS
event). Applications should not set this, it is a global user-configured setting.Declaration
Swift
@inlinable func setDoubleClickTime(msec: Int)
-
storeClipboard(clipboardWindow:
Extension methodtime_: targets: nTargets: ) Issues a request to the clipboard manager to store the clipboard data. On X11, this is a special program that works according to the FreeDesktop Clipboard Specification.
Declaration
Swift
@inlinable func storeClipboard<WindowT>(clipboardWindow: WindowT, time_: guint32, targets: UnsafePointer<GdkAtom?>! = nil, nTargets: Int) where WindowT : WindowProtocol
-
supportsClipboardPersistence()
Extension methodReturns whether the speicifed display supports clipboard persistance; i.e. if it’s possible to store the clipboard data after an application has quit. On X11 this checks if a clipboard daemon is running.
Declaration
Swift
@inlinable func supportsClipboardPersistence() -> Bool
-
supportsComposite()
Extension methodReturns
true
ifgdk_window_set_composited()
can be used to redirect drawing on the window using compositing.Currently this only works on X11 with XComposite and XDamage extensions available.
supports_composite is deprecated: Compositing is an outdated technology that only ever worked on X11.
Declaration
Swift
@available(*, deprecated) @inlinable func supportsComposite() -> Bool
-
supportsCursorAlpha()
Extension methodReturns
true
if cursors can use an 8bit alpha channel ondisplay
. Otherwise, cursors are restricted to bilevel alpha (i.e. a mask).Declaration
Swift
@inlinable func supportsCursorAlpha() -> Bool
-
supportsCursorColor()
Extension methodReturns
true
if multicolored cursors are supported ondisplay
. Otherwise, cursors have only a forground and a background color.Declaration
Swift
@inlinable func supportsCursorColor() -> Bool
-
supportsInputShapes()
Extension methodReturns
true
ifgdk_window_input_shape_combine_mask()
can be used to modify the input shape of windows ondisplay
.Declaration
Swift
@inlinable func supportsInputShapes() -> Bool
-
supportsSelectionNotification()
Extension methodReturns whether
GdkEventOwnerChange
events will be sent when the owner of a selection changes.Declaration
Swift
@inlinable func supportsSelectionNotification() -> Bool
-
supportsShapes()
Extension methodReturns
true
ifgdk_window_shape_combine_mask()
can be used to create shaped windows ondisplay
.Declaration
Swift
@inlinable func supportsShapes() -> 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
gdk_display_sync()
beforegdk_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()
-
warpPointer(screen:
Extension methodx: y: ) Warps the pointer of
display
to the pointx
,y
on the screenscreen
, unless the pointer is confined to a window by a grab, in which case it will be moved as far as allowed by the grab. Warping the pointer creates events as if the user had moved the mouse instantaneously to the destination.Note that the pointer should normally be under the control of the user. This function was added to cover some rare use cases like keyboard navigation support for the color picker in the
GtkColorSelectionDialog
.warp_pointer is deprecated: Use gdk_device_warp() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func warpPointer<ScreenT>(screen: ScreenT, x: Int, y: Int) where ScreenT : ScreenProtocol
-
pangoContextGetForDisplay()
Extension methodCreates a
PangoContext
fordisplay
.The context must be freed when you’re finished with it.
When using GTK+, normally you should use
gtk_widget_get_pango_context()
instead of this function, to get the appropriate context for the widget you intend to render text onto.The newly created context will have the default font options (see
cairo_font_options_t
) for the display; if these options change it will not be updated. Usinggtk_widget_get_pango_context()
is more convenient if you want to keep a context around and track changes to the font rendering settings.Declaration
Swift
@inlinable func pangoContextGetForDisplay() -> Pango.ContextRef!
-
selectionOwnerGetForDisplay(selection:
Extension method) Determine the owner of the given selection.
Note that the return value may be owned by a different process if a foreign window was previously created for that window, but a new foreign window will never be created by this call.
Declaration
Swift
@inlinable func selectionOwnerGetForDisplay(selection: GdkAtom!) -> WindowRef!
-
selectionOwnerSetForDisplay(owner:
Extension methodselection: time_: sendEvent: ) Sets the
GdkWindow
owner
as the current owner of the selectionselection
.Declaration
Swift
@inlinable func selectionOwnerSetForDisplay(owner: WindowRef? = nil, selection: GdkAtom!, time_: guint32, sendEvent: Bool) -> Bool
-
selectionOwnerSetForDisplay(owner:
Extension methodselection: time_: sendEvent: ) Sets the
GdkWindow
owner
as the current owner of the selectionselection
.Declaration
Swift
@inlinable func selectionOwnerSetForDisplay<WindowT>(owner: WindowT?, selection: GdkAtom!, time_: guint32, sendEvent: Bool) -> Bool where WindowT : WindowProtocol
-
Send a response to SelectionRequest event.
Declaration
Swift
@inlinable func selectionSendNotifyForDisplay<WindowT>(requestor: WindowT, selection: GdkAtom!, target: GdkAtom!, property: GdkAtom!, time_: guint32) where WindowT : WindowProtocol
-
textPropertyToUtf8ListForDisplay(encoding:
Extension methodformat: text: length: list: ) Converts a text property in the given encoding to a list of UTF-8 strings.
Declaration
Swift
@inlinable func textPropertyToUtf8ListForDisplay(encoding: GdkAtom!, format: Int, text: UnsafePointer<guchar>!, length: Int, list: UnsafeMutablePointer<UnsafeMutablePointer<UnsafeMutablePointer<gchar>?>?>!) -> Int
-
appLaunchContext
Extension methodReturns a
GdkAppLaunchContext
suitable for launching applications on the given display.Declaration
Swift
@inlinable var appLaunchContext: AppLaunchContextRef! { get }
-
defaultCursorSize
Extension methodReturns the default size to use for cursors on
display
.Declaration
Swift
@inlinable var defaultCursorSize: Int { get }
-
defaultGroup
Extension methodReturns the default group leader window for all toplevel windows on
display
. This window is implicitly created by GDK. Seegdk_window_set_group()
.Declaration
Swift
@inlinable var defaultGroup: WindowRef! { get }
-
defaultScreen
Extension methodGet the default
GdkScreen
fordisplay
.Declaration
Swift
@inlinable var defaultScreen: ScreenRef! { get }
-
defaultSeat
Extension methodReturns the default
GdkSeat
for this display.Declaration
Swift
@inlinable var defaultSeat: SeatRef! { get }
-
deviceManager
Extension methodReturns the
GdkDeviceManager
associated todisplay
.get_device_manager is deprecated: Use gdk_display_get_default_seat() and #GdkSeat operations.
Declaration
Swift
@inlinable var deviceManager: DeviceManagerRef! { get }
-
event
Extension methodGets the next
GdkEvent
to be processed fordisplay
, fetching events from the windowing system if necessary.Declaration
Swift
@inlinable var event: EventRef! { get }
-
isClosed
Extension methodFinds out if the display has been closed.
Declaration
Swift
@inlinable var isClosed: Bool { get }
-
nMonitors
Extension methodGets the number of monitors that belong to
display
.The returned number is valid until the next emission of the
GdkDisplay::monitor-added
orGdkDisplay::monitor-removed
signal.Declaration
Swift
@inlinable var nMonitors: Int { get }
-
nScreens
Extension methodGets the number of screen managed by the
display
.get_n_screens is deprecated: The number of screens is always 1.
Declaration
Swift
@inlinable var nScreens: Int { get }
-
name
Extension methodGets the name of the display.
Declaration
Swift
@inlinable var name: String! { get }
-
primaryMonitor
Extension methodGets the primary monitor for the display.
The primary monitor is considered the monitor where the “main desktop” lives. While normal application windows typically allow the window manager to place the windows, specialized desktop applications such as panels should place themselves on the primary monitor.
Declaration
Swift
@inlinable var primaryMonitor: MonitorRef! { get }