SurfaceProtocol
public protocol SurfaceProtocol : ObjectProtocol
The SurfaceProtocol protocol exposes the methods and properties of an underlying GdkSurface 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 Surface.
Alternatively, use SurfaceRef as a lighweight, unowned reference if you already have an instance you just want to use.
A GdkSurface is a rectangular region on the screen.
It’s a low-level object, used to implement high-level objects
such as [classGtk.Window] or [classGtk.Dialog] in GTK.
The surfaces you see in practice are either [classGdk.Toplevel] or
[classGdk.Popup], and those interfaces provide much of the required
API to interact with these surfaces. Other, more specialized surface
types exist, but you will rarely interact with them directly.
-
Untyped pointer to the underlying
GdkSurfaceinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
surface_ptrDefault implementationTyped pointer to the underlying
GdkSurfaceinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkSurfaceinstance.Declaration
Swift
var surface_ptr: UnsafeMutablePointer<GdkSurface>! { get } -
Required Initialiser for types conforming to
SurfaceProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
SurfacePropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: SurfacePropertyName, 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 Surface property
Declaration
Swift
@inlinable func get(property: SurfacePropertyName) -> 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 Surface property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: SurfacePropertyName, 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
SurfaceSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: SurfaceSignalName, 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
SurfaceSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: SurfaceSignalName, 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)
-
onEnterMonitor(flags:Extension methodhandler: ) Emitted when
surfacestarts being present on the monitor.Note
This represents the underlyingenter-monitorsignalDeclaration
Swift
@discardableResult @inlinable func onEnterMonitor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ monitor: MonitorRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
monitorthe monitor
handlerThe signal handler to call Run the given callback whenever the
enterMonitorsignal is emitted -
enterMonitorSignalExtension methodTyped
enter-monitorsignal for using theconnect(signal:)methodsDeclaration
Swift
static var enterMonitorSignal: SurfaceSignalName { get } -
onEvent(flags:Extension methodhandler: ) Emitted when GDK receives an input event for
surface.Note
This represents the underlyingeventsignalDeclaration
Swift
@discardableResult @inlinable func onEvent(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ event: EventRef) -> Bool) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
eventan input event
handlertrueto indicate that the event has been handled Run the given callback whenever theeventsignal is emitted -
eventSignalExtension methodTyped
eventsignal for using theconnect(signal:)methodsDeclaration
Swift
static var eventSignal: SurfaceSignalName { get } -
onLayout(flags:Extension methodhandler: ) Emitted when the size of
surfaceis changed, or when relayout should be performed.Surface size is reported in ”application pixels”, not ”device pixels” (see
gdk_surface_get_scale_factor()).Note
This represents the underlyinglayoutsignalDeclaration
Swift
@discardableResult @inlinable func onLayout(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ width: Int, _ height: Int) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
widththe current width
heightthe current height
handlerThe signal handler to call Run the given callback whenever the
layoutsignal is emitted -
layoutSignalExtension methodTyped
layoutsignal for using theconnect(signal:)methodsDeclaration
Swift
static var layoutSignal: SurfaceSignalName { get } -
onLeaveMonitor(flags:Extension methodhandler: ) Emitted when
surfacestops being present on the monitor.Note
This represents the underlyingleave-monitorsignalDeclaration
Swift
@discardableResult @inlinable func onLeaveMonitor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ monitor: MonitorRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
monitorthe monitor
handlerThe signal handler to call Run the given callback whenever the
leaveMonitorsignal is emitted -
leaveMonitorSignalExtension methodTyped
leave-monitorsignal for using theconnect(signal:)methodsDeclaration
Swift
static var leaveMonitorSignal: SurfaceSignalName { get } -
onRender(flags:Extension methodhandler: ) Emitted when part of the surface needs to be redrawn.
Note
This represents the underlyingrendersignalDeclaration
Swift
@discardableResult @inlinable func onRender(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ region: Cairo.RegionRef) -> Bool) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
regionthe region that needs to be redrawn
handlertrueto indicate that the signal has been handled Run the given callback whenever therendersignal is emitted -
renderSignalExtension methodTyped
rendersignal for using theconnect(signal:)methodsDeclaration
Swift
static var renderSignal: SurfaceSignalName { get } -
onNotifyCursor(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::cursorsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyCursor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ 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
notifyCursorsignal is emitted -
notifyCursorSignalExtension methodTyped
notify::cursorsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyCursorSignal: SurfaceSignalName { get } -
onNotifyDisplay(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::displaysignalDeclaration
Swift
@discardableResult @inlinable func onNotifyDisplay(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ 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
notifyDisplaysignal is emitted -
notifyDisplaySignalExtension methodTyped
notify::displaysignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyDisplaySignal: SurfaceSignalName { get } -
onNotifyFrameClock(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::frame-clocksignalDeclaration
Swift
@discardableResult @inlinable func onNotifyFrameClock(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ 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
notifyFrameClocksignal is emitted -
notifyFrameClockSignalExtension methodTyped
notify::frame-clocksignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyFrameClockSignal: SurfaceSignalName { get } -
onNotifyHeight(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::heightsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyHeight(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ 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
notifyHeightsignal is emitted -
notifyHeightSignalExtension methodTyped
notify::heightsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyHeightSignal: SurfaceSignalName { get } -
onNotifyMapped(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::mappedsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyMapped(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ 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
notifyMappedsignal is emitted -
notifyMappedSignalExtension methodTyped
notify::mappedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyMappedSignal: SurfaceSignalName { get } -
onNotifyScaleFactor(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::scale-factorsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyScaleFactor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ 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
notifyScaleFactorsignal is emitted -
notifyScaleFactorSignalExtension methodTyped
notify::scale-factorsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyScaleFactorSignal: SurfaceSignalName { get } -
onNotifyWidth(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::widthsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyWidth(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: SurfaceRef, _ 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
notifyWidthsignal is emitted -
notifyWidthSignalExtension methodTyped
notify::widthsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyWidthSignal: SurfaceSignalName { get }
-
beep()Extension methodEmits a short beep associated to
surface.If the display of
surfacedoes not support per-surface beeps, emits a short beep on the display just as [methodGdk.Display.beep].Declaration
Swift
@inlinable func beep() -
createCairoContext()Extension methodCreates a new
GdkCairoContextfor rendering onsurface.Declaration
Swift
@inlinable func createCairoContext() -> CairoContextRef! -
createGlContext()Extension methodCreates a new
GdkGLContextfor theGdkSurface.The context is disconnected from any particular surface or surface. If the creation of the
GdkGLContextfailed,errorwill be set. Before using the returnedGdkGLContext, you will need to call [methodGdk.GLContext.make_current] or [methodGdk.GLContext.realize].Declaration
Swift
@inlinable func createGlContext() throws -> GLContextRef! -
createSimilarSurface(content:Extension methodwidth: height: ) Create a new Cairo surface that is as compatible as possible with the given
surface.For example the new surface will have the same fallback resolution and font options as
surface. Generally, the new surface will also use the same backend assurface, unless that is not possible for some reason. The type of the returned surface may be examined withcairo_surface_get_type().Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)
This function always returns a valid pointer, but it will return a pointer to a “nil” surface if
otheris already in an error state or any other error occurs.Declaration
Swift
@inlinable func createSimilarSurface(content: cairo_content_t, width: Int, height: Int) -> Cairo.SurfaceRef! -
createVulkanContext()Extension methodCreates a new
GdkVulkanContextfor rendering onsurface.If the creation of the
GdkVulkanContextfailed,errorwill be set.Declaration
Swift
@inlinable func createVulkanContext() throws -> VulkanContextRef! -
destroy()Extension methodDestroys the window system resources associated with
surfaceand decrementssurface‘s reference count.The window system resources for all children of
surfaceare also destroyed, but the children’s reference counts are not decremented.Note that a surface will not be destroyed automatically when its reference count reaches zero. You must call this function yourself before that happens.
Declaration
Swift
@inlinable func destroy() -
getCursor()Extension methodRetrieves a
GdkCursorpointer for the cursor currently set on theGdkSurface.If the return value is
nilthen there is no custom cursor set on the surface, and it is using the cursor for its parent surface.Declaration
Swift
@inlinable func getCursor() -> CursorRef! -
getDeviceCursor(device:Extension method) Retrieves a
GdkCursorpointer for thedevicecurrently set on the specifiedGdkSurface.If the return value is
nilthen there is no custom cursor set on the specified surface, and it is using the cursor for its parent surface.Declaration
Swift
@inlinable func getDeviceCursor<DeviceT>(device: DeviceT) -> CursorRef! where DeviceT : DeviceProtocol -
getDevicePosition(device:Extension methodx: y: mask: ) Obtains the current device position and modifier state.
The position is given in coordinates relative to the upper left corner of
surface.Declaration
Swift
@inlinable func getDevicePosition<DeviceT>(device: DeviceT, x: UnsafeMutablePointer<CDouble>! = nil, y: UnsafeMutablePointer<CDouble>! = nil, mask: UnsafeMutablePointer<GdkModifierType>! = nil) -> Bool where DeviceT : DeviceProtocol -
getDisplay()Extension methodGets the
GdkDisplayassociated with aGdkSurface.Declaration
Swift
@inlinable func getDisplay() -> DisplayRef! -
getFrameClock()Extension methodGets the frame clock for the surface.
The frame clock for a surface never changes unless the surface is reparented to a new toplevel surface.
Declaration
Swift
@inlinable func getFrameClock() -> FrameClockRef! -
getHeight()Extension methodReturns the height of the given
surface.Surface size is reported in ”application pixels”, not ”device pixels” (see [method
Gdk.Surface.get_scale_factor]).Declaration
Swift
@inlinable func getHeight() -> Int -
getMapped()Extension methodChecks whether the surface has been mapped.
A surface is mapped with [method
Gdk.Toplevel.present] or [methodGdk.Popup.present].Declaration
Swift
@inlinable func getMapped() -> Bool -
getScaleFactor()Extension methodReturns the internal scale factor that maps from surface coordinates to the actual device pixels.
On traditional systems this is 1, but on very high density outputs this can be a higher value (often 2). A higher value means that drawing is automatically scaled up to a higher resolution, so any code doing drawing will automatically look nicer. However, if you are supplying pixel-based data the scale value can be used to determine whether to use a pixel resource with higher resolution data.
The scale of a surface may change during runtime.
Declaration
Swift
@inlinable func getScaleFactor() -> Int -
getWidth()Extension methodReturns the width of the given
surface.Surface size is reported in ”application pixels”, not ”device pixels” (see [method
Gdk.Surface.get_scale_factor]).Declaration
Swift
@inlinable func getWidth() -> Int -
hide()Extension methodHide the surface.
For toplevel surfaces, withdraws them, so they will no longer be known to the window manager; for all surfaces, unmaps them, so they won’t be displayed. Normally done automatically as part of [method
Gtk.Widget.hide].Declaration
Swift
@inlinable func hide() -
queueRender()Extension methodForces a [signal
Gdk.Surface::render] signal emission forsurfaceto be scheduled.This function is useful for implementations that track invalid regions on their own.
Declaration
Swift
@inlinable func queueRender() -
requestLayout()Extension methodRequest a layout phase from the surface’s frame clock.
See [method
Gdk.FrameClock.request_phase].Declaration
Swift
@inlinable func requestLayout() -
set(cursor:Extension method) Sets the default mouse pointer for a
GdkSurface.Passing
nilfor thecursorargument means thatsurfacewill use the cursor of its parent surface. Most surfaces should use this default. Note thatcursormust be for the same display assurface.Use [ctor
Gdk.Cursor.new_from_name] or [ctorGdk.Cursor.new_from_texture] to create the cursor. To make the cursor invisible, useGDK_BLANK_CURSOR.Declaration
Swift
@inlinable func set(cursor: CursorRef? = nil) -
set(cursor:Extension method) Sets the default mouse pointer for a
GdkSurface.Passing
nilfor thecursorargument means thatsurfacewill use the cursor of its parent surface. Most surfaces should use this default. Note thatcursormust be for the same display assurface.Use [ctor
Gdk.Cursor.new_from_name] or [ctorGdk.Cursor.new_from_texture] to create the cursor. To make the cursor invisible, useGDK_BLANK_CURSOR.Declaration
Swift
@inlinable func set<CursorT>(cursor: CursorT?) where CursorT : CursorProtocol -
setDeviceCursor(device:Extension methodcursor: ) Sets a specific
GdkCursorfor a given device when it gets insidesurface.Passing
nilfor thecursorargument means thatsurfacewill use the cursor of its parent surface. Most surfaces should use this default.Use [ctor
Gdk.Cursor.new_from_name] or [ctorGdk.Cursor.new_from_texture] to create the cursor. To make the cursor invisible, useGDK_BLANK_CURSOR.Declaration
Swift
@inlinable func setDeviceCursor<CursorT, DeviceT>(device: DeviceT, cursor: CursorT) where CursorT : CursorProtocol, DeviceT : DeviceProtocol -
setInput(region:Extension method) Apply the region to the surface for the purpose of event handling.
Mouse events which happen while the pointer position corresponds to an unset bit in the mask will be passed on the surface below
surface.An input region is typically used with RGBA surfaces. The alpha channel of the surface defines which pixels are invisible and allows for nicely antialiased borders, and the input region controls where the surface is “clickable”.
Use [method
Gdk.Display.supports_input_shapes] to find out if a particular backend supports input regions.Declaration
Swift
@inlinable func setInput<RegionT>(region: RegionT) where RegionT : RegionProtocol -
setOpaque(region:Extension method) Marks a region of the
GdkSurfaceas opaque.For optimisation purposes, compositing window managers may like to not draw obscured regions of surfaces, or turn off blending during for these regions. With RGB windows with no transparency, this is just the shape of the window, but with ARGB32 windows, the compositor does not know what regions of the window are transparent or not.
This function only works for toplevel surfaces.
GTK will update this property automatically if the
surfacebackground is opaque, as we know where the opaque regions are. If your surface background is not opaque, please update this property in yourGtkWidgetClass.css_changed()handler.Declaration
Swift
@inlinable func setOpaque(region: Cairo.RegionRef? = nil) -
setOpaque(region:Extension method) Marks a region of the
GdkSurfaceas opaque.For optimisation purposes, compositing window managers may like to not draw obscured regions of surfaces, or turn off blending during for these regions. With RGB windows with no transparency, this is just the shape of the window, but with ARGB32 windows, the compositor does not know what regions of the window are transparent or not.
This function only works for toplevel surfaces.
GTK will update this property automatically if the
surfacebackground is opaque, as we know where the opaque regions are. If your surface background is not opaque, please update this property in yourGtkWidgetClass.css_changed()handler.Declaration
Swift
@inlinable func setOpaque<RegionT>(region: RegionT?) where RegionT : RegionProtocol -
translateCoordinates(to:Extension methodx: y: ) Translates coordinates between two surfaces.
Note that this only works if
toandfromare popups or transient-for to the same toplevel (directly or indirectly).Declaration
Swift
@inlinable func translateCoordinates<SurfaceT>(to: SurfaceT, x: UnsafeMutablePointer<CDouble>!, y: UnsafeMutablePointer<CDouble>!) -> Bool where SurfaceT : SurfaceProtocol -
cairoDrawFromGl(cr:Extension methodsource: sourceType: bufferScale: x: y: width: height: ) The main way to draw GL content in GTK.
It takes a render buffer ID (
source_type==GL_RENDERBUFFER) or a texture id (source_type==GL_TEXTURE) and draws it ontocrwith an OVER operation, respecting the current clip. The top left corner of the rectangle specified byx,y,widthandheightwill be drawn at the current (0,0) position of thecairo_t.This will work for all
cairo_t, as long assurfaceis realized, but the fallback implementation that reads back the pixels from the buffer may be used in the general case. In the case of direct drawing to a surface with no special effects applied tocrit will however use a more efficient approach.For
GL_RENDERBUFFERthe code will always fall back to software for buffers with alpha components, so make sure you useGL_TEXTUREif using alpha.Calling this may change the current GL context.
Declaration
Swift
@inlinable func cairoDrawFromGl<ContextT>(cr: ContextT, source: Int, sourceType: Int, bufferScale: Int, x: Int, y: Int, width: Int, height: Int) where ContextT : ContextProtocol -
cursorExtension methodThe mouse pointer for the
GdkSurface.Declaration
Swift
@inlinable var cursor: CursorRef! { get nonmutating set } -
displayExtension methodThe
GdkDisplayconnection of the surface.Declaration
Swift
@inlinable var display: DisplayRef! { get } -
frameClockExtension methodGets the frame clock for the surface.
The frame clock for a surface never changes unless the surface is reparented to a new toplevel surface.
Declaration
Swift
@inlinable var frameClock: FrameClockRef! { get } -
heightExtension methodThe height of the surface, in pixels.
Declaration
Swift
@inlinable var height: Int { get } -
isDestroyedExtension methodCheck to see if a surface is destroyed.
Declaration
Swift
@inlinable var isDestroyed: Bool { get } -
mappedExtension methodWhether the surface is mapped.
Declaration
Swift
@inlinable var mapped: Bool { get } -
scaleFactorExtension methodReturns the internal scale factor that maps from surface coordinates to the actual device pixels.
On traditional systems this is 1, but on very high density outputs this can be a higher value (often 2). A higher value means that drawing is automatically scaled up to a higher resolution, so any code doing drawing will automatically look nicer. However, if you are supplying pixel-based data the scale value can be used to determine whether to use a pixel resource with higher resolution data.
The scale of a surface may change during runtime.
Declaration
Swift
@inlinable var scaleFactor: Int { get } -
widthExtension methodThe width of the surface in pixels.
Declaration
Swift
@inlinable var width: Int { get }
View on GitHub
Install in Dash
SurfaceProtocol Protocol Reference