Structures
The following structures are available globally.
-
The
AppLaunchContextReftype acts as a lightweight Swift reference to an underlyingGdkAppLaunchContextinstance. It exposes methods that can operate on this data type throughAppLaunchContextProtocolconformance. UseAppLaunchContextRefonly as anunownedreference to an existingGdkAppLaunchContextinstance.GdkAppLaunchContexthandles launching an application in a graphical context.It is an implementation of
GAppLaunchContextthat provides startup notification and allows to launch applications on a specific screen or workspace.Launching an application
See moreGdkAppLaunchContext *context; context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_display (display); gdk_app_launch_context_set_timestamp (gdk_event_get_time (event)); if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &error)) g_warning ("Launching failed: `s`\n", error->message); g_object_unref (context);Declaration
Swift
public struct AppLaunchContextRef : AppLaunchContextProtocol, GWeakCapturing
-
The
ButtonEventReftype acts as a lightweight Swift reference to an underlyingGdkButtonEventinstance. It exposes methods that can operate on this data type throughButtonEventProtocolconformance. UseButtonEventRefonly as anunownedreference to an existingGdkButtonEventinstance.An event related to a button on a pointer device.
See moreDeclaration
Swift
public struct ButtonEventRef : ButtonEventProtocol
-
The
CairoContextReftype acts as a lightweight Swift reference to an underlyingGdkCairoContextinstance. It exposes methods that can operate on this data type throughCairoContextProtocolconformance. UseCairoContextRefonly as anunownedreference to an existingGdkCairoContextinstance.GdkCairoContextis an object representing the platform-specific draw context.
See moreGdkCairoContexts are created for a surface using [methodGdk.Surface.create_cairo_context], and the context can then be used to draw on that surface.Declaration
Swift
public struct CairoContextRef : CairoContextProtocol, GWeakCapturing
-
The
ClipboardReftype acts as a lightweight Swift reference to an underlyingGdkClipboardinstance. It exposes methods that can operate on this data type throughClipboardProtocolconformance. UseClipboardRefonly as anunownedreference to an existingGdkClipboardinstance.The
GdkClipboardobject represents data shared between applications or inside an application.To get a
GdkClipboardobject, use [methodGdk.Display.get_clipboard] or [methodGdk.Display.get_primary_clipboard]. You can find out about the data that is currently available in a clipboard using [methodGdk.Clipboard.get_formats].To make text or image data available in a clipboard, use [method
Gdk.Clipboard.set_text] or [methodGdk.Clipboard.set_texture]. For other data, you can use [methodGdk.Clipboard.set_content], which takes a [classGdk.ContentProvider] object.To read textual or image data from a clipboard, use [method
See moreGdk.Clipboard.read_text_async] or [methodGdk.Clipboard.read_texture_async]. For other data, use [methodGdk.Clipboard.read_async], which provides aGInputStreamobject.Declaration
Swift
public struct ClipboardRef : ClipboardProtocol, GWeakCapturing
-
The
ContentDeserializerReftype acts as a lightweight Swift reference to an underlyingGdkContentDeserializerinstance. It exposes methods that can operate on this data type throughContentDeserializerProtocolconformance. UseContentDeserializerRefonly as anunownedreference to an existingGdkContentDeserializerinstance.A
GdkContentDeserializeris used to deserialize content received via inter-application data transfers.The
GdkContentDeserializertransforms serialized content that is identified by a mime type into an object identified by a GType.GTK provides serializers and deserializers for common data types such as text, colors, images or file lists. To register your own deserialization functions, use [func
content_register_deserializer].Also see [class
See moreGdk.ContentSerializer].Declaration
Swift
public struct ContentDeserializerRef : ContentDeserializerProtocol, GWeakCapturing
-
The
ContentProviderReftype acts as a lightweight Swift reference to an underlyingGdkContentProviderinstance. It exposes methods that can operate on this data type throughContentProviderProtocolconformance. UseContentProviderRefonly as anunownedreference to an existingGdkContentProviderinstance.A
GdkContentProvideris used to provide content for the clipboard or for drag-and-drop operations in a number of formats.To create a
GdkContentProvider, use [ctorGdk.ContentProvider.new_for_value] or [ctorGdk.ContentProvider.new_for_bytes].GDK knows how to handle common text and image formats out-of-the-box. See [class
See moreGdk.ContentSerializer] and [classGdk.ContentDeserializer] if you want to add support for application-specific data formats.Declaration
Swift
public struct ContentProviderRef : ContentProviderProtocol, GWeakCapturing
-
The
ContentSerializerReftype acts as a lightweight Swift reference to an underlyingGdkContentSerializerinstance. It exposes methods that can operate on this data type throughContentSerializerProtocolconformance. UseContentSerializerRefonly as anunownedreference to an existingGdkContentSerializerinstance.A
GdkContentSerializeris used to serialize content for inter-application data transfers.The
GdkContentSerializertransforms an object that is identified by a GType into a serialized form (i.e. a byte stream) that is identified by a mime type.GTK provides serializers and deserializers for common data types such as text, colors, images or file lists. To register your own serialization functions, use [func
content_register_serializer].Also see [class
See moreGdk.ContentDeserializer].Declaration
Swift
public struct ContentSerializerRef : ContentSerializerProtocol, GWeakCapturing
-
The
CrossingEventReftype acts as a lightweight Swift reference to an underlyingGdkCrossingEventinstance. It exposes methods that can operate on this data type throughCrossingEventProtocolconformance. UseCrossingEventRefonly as anunownedreference to an existingGdkCrossingEventinstance.An event caused by a pointing device moving between surfaces.
See moreDeclaration
Swift
public struct CrossingEventRef : CrossingEventProtocol
-
The
CursorReftype acts as a lightweight Swift reference to an underlyingGdkCursorinstance. It exposes methods that can operate on this data type throughCursorProtocolconformance. UseCursorRefonly as anunownedreference to an existingGdkCursorinstance.GdkCursoris used to create and destroy cursors.Cursors are immutable objects, so once you created them, there is no way to modify them later. You should create a new cursor when you want to change something about it.
Cursors by themselves are not very interesting: they must be bound to a window for users to see them. This is done with [method
Gdk.Surface.set_cursor] or [methodGdk.Surface.set_device_cursor]. Applications will typically use higher-level GTK functions such as [methodGtk.Widget.set_cursor]` instead.Cursors are not bound to a given [class
Gdk.Display], so they can be shared. However, the appearance of cursors may vary when used on different platforms.Named and texture cursors
There are multiple ways to create cursors. The platform’s own cursors can be created with [ctor
Gdk.Cursor.new_from_name]. That function lists the commonly available names that are shared with the CSS specification. Other names may be available, depending on the platform in use. On some platforms, what images are used for named cursors may be influenced by the cursor theme.Another option to create a cursor is to use [ctor
Gdk.Cursor.new_from_texture] and provide an image to use for the cursor.To ease work with unsupported cursors, a fallback cursor can be provided. If a [class
See moreGdk.Surface] cannot use a cursor because of the reasons mentioned above, it will try the fallback cursor. Fallback cursors can themselves have fallback cursors again, so it is possible to provide a chain of progressively easier to support cursors. If none of the provided cursors can be supported, the default cursor will be the ultimate fallback.Declaration
Swift
public struct CursorRef : CursorProtocol, GWeakCapturing
-
The
DNDEventReftype acts as a lightweight Swift reference to an underlyingGdkDNDEventinstance. It exposes methods that can operate on this data type throughDNDEventProtocolconformance. UseDNDEventRefonly as anunownedreference to an existingGdkDNDEventinstance.An event related to drag and drop operations.
See moreDeclaration
Swift
public struct DNDEventRef : DNDEventProtocol
-
The
ContentFormatsReftype acts as a lightweight Swift reference to an underlyingGdkContentFormatsinstance. It exposes methods that can operate on this data type throughContentFormatsProtocolconformance. UseContentFormatsRefonly as anunownedreference to an existingGdkContentFormatsinstance.The
GdkContentFormatsstructure is used to advertise and negotiate the format of content.You will encounter
GdkContentFormatswhen interacting with objects controlling operations that pass data between different widgets, window or application, like [classGdk.Drag], [classGdk.Drop], [classGdk.Clipboard] or [classGdk.ContentProvider].GDK supports content in 2 forms:
GTypeand mime type. UsingGTypesis meant only for in-process content transfers. Mime types are meant to be used for data passing both in-process and out-of-process. The details of how data is passed is described in the documentation of the actual implementations. To transform between the two forms, [classGdk.ContentSerializer] and [classGdk.ContentDeserializer] are used.A
GdkContentFormatsdescribes a set of possible formats content can be exchanged in. It is assumed that this set is ordered.GTypesare more important than mime types. Order between differentGTypesor mime types is the order they were added in, most important first. Functions that care about order, such as [methodGdk.ContentFormats.union], will describe in their documentation how they interpret that order, though in general the order of the first argument is considered the primary order of the result, followed by the order of further arguments.For debugging purposes, the function [method
Gdk.ContentFormats.to_string] exists. It will print a comma-separated list of formats from most important to least important.
See moreGdkContentFormatsis an immutable struct. After creation, you cannot change the types it represents. Instead, newGdkContentFormatshave to be created. The [structGdk.ContentFormatsBuilder]` structure is meant to help in this endeavor.Declaration
Swift
public struct ContentFormatsRef : ContentFormatsProtocol
-
The
ContentFormatsBuilderReftype acts as a lightweight Swift reference to an underlyingGdkContentFormatsBuilderinstance. It exposes methods that can operate on this data type throughContentFormatsBuilderProtocolconformance. UseContentFormatsBuilderRefonly as anunownedreference to an existingGdkContentFormatsBuilderinstance.A
See moreGdkContentFormatsBuilderis an auxiliary struct used to create newGdkContentFormats, and should not be kept around.Declaration
Swift
public struct ContentFormatsBuilderRef : ContentFormatsBuilderProtocol
-
The
ContentProviderClassReftype acts as a lightweight Swift reference to an underlyingGdkContentProviderClassinstance. It exposes methods that can operate on this data type throughContentProviderClassProtocolconformance. UseContentProviderClassRefonly as anunownedreference to an existingGdkContentProviderClassinstance.Class structure for
See moreGdkContentProvider.Declaration
Swift
public struct ContentProviderClassRef : ContentProviderClassProtocol
-
The
See moreDevicePadInterfaceReftype acts as a lightweight Swift reference to an underlyingGdkDevicePadInterfaceinstance. It exposes methods that can operate on this data type throughDevicePadInterfaceProtocolconformance. UseDevicePadInterfaceRefonly as anunownedreference to an existingGdkDevicePadInterfaceinstance.Declaration
Swift
public struct DevicePadInterfaceRef : DevicePadInterfaceProtocol
-
The
DeleteEventReftype acts as a lightweight Swift reference to an underlyingGdkDeleteEventinstance. It exposes methods that can operate on this data type throughDeleteEventProtocolconformance. UseDeleteEventRefonly as anunownedreference to an existingGdkDeleteEventinstance.An event related to closing a top-level surface.
See moreDeclaration
Swift
public struct DeleteEventRef : DeleteEventProtocol
-
The
DeviceReftype acts as a lightweight Swift reference to an underlyingGdkDeviceinstance. It exposes methods that can operate on this data type throughDeviceProtocolconformance. UseDeviceRefonly as anunownedreference to an existingGdkDeviceinstance.The
GdkDeviceobject represents an input device, such as a keyboard, a mouse, or a touchpad.See the [class
See moreGdk.Seat] documentation for more information about the various kinds of devices, and their relationships.Declaration
Swift
public struct DeviceRef : DeviceProtocol, GWeakCapturing
-
The
DeviceToolReftype acts as a lightweight Swift reference to an underlyingGdkDeviceToolinstance. It exposes methods that can operate on this data type throughDeviceToolProtocolconformance. UseDeviceToolRefonly as anunownedreference to an existingGdkDeviceToolinstance.A physical tool associated to a
See moreGdkDevice.Declaration
Swift
public struct DeviceToolRef : DeviceToolProtocol, GWeakCapturing
-
The
DisplayReftype acts as a lightweight Swift reference to an underlyingGdkDisplayinstance. It exposes methods that can operate on this data type throughDisplayProtocolconformance. UseDisplayRefonly as anunownedreference to an existingGdkDisplayinstance.GdkDisplayobjects 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 [class
Gdk.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 [class
See moreGdk.Monitor] objects, which can be accessed with [methodGdk.Display.get_monitor_at_surface] and similar APIs.Declaration
Swift
public struct DisplayRef : DisplayProtocol, GWeakCapturing
-
The
DisplayManagerReftype acts as a lightweight Swift reference to an underlyingGdkDisplayManagerinstance. It exposes methods that can operate on this data type throughDisplayManagerProtocolconformance. UseDisplayManagerRefonly as anunownedreference to an existingGdkDisplayManagerinstance.A singleton object that offers notification when displays appear or disappear.
You can use [func
Gdk.DisplayManager.get] to obtain theGdkDisplayManagersingleton, but that should be rarely necessary. Typically, initializing GTK opens a display that you can work with without ever accessing theGdkDisplayManager.The GDK library can be built with support for multiple backends. The
GdkDisplayManagerobject determines which backend is used at runtime.In the rare case that you need to influence which of the backends is being used, you can use [func
Gdk.set_allowed_backends]. Note that you need to call this function before initializing GTK.Backend-specific code
When writing backend-specific code that is supposed to work with multiple GDK backends, you have to consider both compile time and runtime. At compile time, use the
GDK_WINDOWING_X11,GDK_WINDOWING_WIN32macros, etc. to find out which backends are present in the GDK library you are building your application against. At runtime, use type-check macros likeGDK_IS_X11_DISPLAY()to find out which backend is in use:
See more`ifdef` GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (display)) { // make X11-specific calls here } else `endif` `ifdef` GDK_WINDOWING_MACOS if (GDK_IS_MACOS_DISPLAY (display)) { // make Quartz-specific calls here } else `endif` g_error ("Unsupported GDK backend");Declaration
Swift
public struct DisplayManagerRef : DisplayManagerProtocol, GWeakCapturing
-
The
DragReftype acts as a lightweight Swift reference to an underlyingGdkDraginstance. It exposes methods that can operate on this data type throughDragProtocolconformance. UseDragRefonly as anunownedreference to an existingGdkDraginstance.The
GdkDragobject represents the source of an ongoing DND operation.A
GdkDragis created when a drag is started, and stays alive for duration of the DND operation. After a drag has been started with [funcGdk.Drag.begin], the caller gets informed about the status of the ongoing drag operation with signals on theGdkDragobject.GTK provides a higher level abstraction based on top of these functions, and so they are not normally needed in GTK applications. See the “Drag and Drop” section of the GTK documentation for more information.
See moreDeclaration
Swift
public struct DragRef : DragProtocol, GWeakCapturing
-
The
DrawContextReftype acts as a lightweight Swift reference to an underlyingGdkDrawContextinstance. It exposes methods that can operate on this data type throughDrawContextProtocolconformance. UseDrawContextRefonly as anunownedreference to an existingGdkDrawContextinstance.Base class for objects implementing different rendering methods.
GdkDrawContextis the base object used by contexts implementing different rendering methods, such as [classGdk.CairoContext] or [classGdk.GLContext]. It provides shared functionality between those contexts.You will always interact with one of those subclasses.
A
See moreGdkDrawContextis always associated with a single toplevel surface.Declaration
Swift
public struct DrawContextRef : DrawContextProtocol, GWeakCapturing
-
The
DropReftype acts as a lightweight Swift reference to an underlyingGdkDropinstance. It exposes methods that can operate on this data type throughDropProtocolconformance. UseDropRefonly as anunownedreference to an existingGdkDropinstance.The
GdkDropobject represents the target of an ongoing DND operation.Possible drop sites get informed about the status of the ongoing drag operation with events of type
GDK_DRAG_ENTER,GDK_DRAG_LEAVE,GDK_DRAG_MOTIONandGDK_DROP_START. TheGdkDropobject can be obtained from these [classGdk.Event] types using [methodGdk.DNDEvent.get_drop].The actual data transfer is initiated from the target side via an async read, using one of the
GdkDropmethods for this purpose: [methodGdk.Drop.read_async] or [methodGdk.Drop.read_value_async].GTK provides a higher level abstraction based on top of these functions, and so they are not normally needed in GTK applications. See the “Drag and Drop” section of the GTK documentation for more information.
See moreDeclaration
Swift
public struct DropRef : DropProtocol, GWeakCapturing
-
The
EventReftype acts as a lightweight Swift reference to an underlyingGdkEventinstance. It exposes methods that can operate on this data type throughEventProtocolconformance. UseEventRefonly as anunownedreference to an existingGdkEventinstance.GdkEvents are immutable data structures, created by GDK to represent windowing system events.In GTK applications the events are handled automatically by toplevel widgets and passed on to the event controllers of appropriate widgets, so using
See moreGdkEventand its related API is rarely needed.Declaration
Swift
public struct EventRef : EventProtocol
-
The
DevicePadReftype acts as a lightweight Swift reference to an underlyingGdkDevicePadinstance. It exposes methods that can operate on this data type throughDevicePadProtocolconformance. UseDevicePadRefonly as anunownedreference to an existingGdkDevicePadinstance.GdkDevicePadis an interface implemented by devices of typeGDK_SOURCE_TABLET_PADIt allows querying the features provided by the pad device.
Tablet pads may contain one or more groups, each containing a subset of the buttons/rings/strips available. [method
Gdk.DevicePad.get_n_groups] can be used to obtain the number of groups, [methodGdk.DevicePad.get_n_features] and [methodGdk.DevicePad.get_feature_group] can be combined to find out the number of buttons/rings/strips the device has, and how are they grouped.Each of those groups have different modes, which may be used to map each individual pad feature to multiple actions. Only one mode is effective (current) for each given group, different groups may have different current modes. The number of available modes in a group can be found out through [method
See moreGdk.DevicePad.get_group_n_modes], and the current mode for a given group will be notified through events of typeGDK_PAD_GROUP_MODE.Declaration
Swift
public struct DevicePadRef : DevicePadProtocol, GWeakCapturing
-
The
DragSurfaceReftype acts as a lightweight Swift reference to an underlyingGdkDragSurfaceinstance. It exposes methods that can operate on this data type throughDragSurfaceProtocolconformance. UseDragSurfaceRefonly as anunownedreference to an existingGdkDragSurfaceinstance.A
See moreGdkDragSurfaceis an interface for surfaces used during DND.Declaration
Swift
public struct DragSurfaceRef : DragSurfaceProtocol, GWeakCapturing
-
The
PaintableReftype acts as a lightweight Swift reference to an underlyingGdkPaintableinstance. It exposes methods that can operate on this data type throughPaintableProtocolconformance. UsePaintableRefonly as anunownedreference to an existingGdkPaintableinstance.GdkPaintableis a simple interface used by GTK to represent content that can be painted.The content of a
GdkPaintablecan be painted anywhere at any size without requiring any sort of layout. The interface is inspired by similar concepts elsewhere, such as ClutterContent, HTML/CSS Paint Sources, or SVG Paint Servers.A
GdkPaintablecan be snapshot at any time and size using [methodGdk.Paintable.snapshot]. How the paintable interprets that size and if it scales or centers itself into the given rectangle is implementation defined, though if you are implementing aGdkPaintableand don’t know what to do, it is suggested that you scale your paintable ignoring any potential aspect ratio.The contents that a
GdkPaintableproduces may depend on the [classGdkSnapshot] passed to it. For example, paintables may decide to use more detailed images on higher resolution screens or when OpenGL is available. AGdkPaintablewill however always produce the same output for the same snapshot.A
GdkPaintablemay change its contents, meaning that it will now produce a different output with the same snapshot. Once that happens, it will call [methodGdk.Paintable.invalidate_contents] which will emit the [signalGdkPaintable::invalidate-contents] signal. If a paintable is known to never change its contents, it will set theGDK_PAINTABLE_STATIC_CONTENTSflag. If a consumer cannot deal with changing contents, it may call [methodGdk.Paintable.get_current_image] which will return a static paintable and use that.A paintable can report an intrinsic (or preferred) size or aspect ratio it wishes to be rendered at, though it doesn’t have to. Consumers of the interface can use this information to layout thepaintable appropriately. Just like the contents, the size of a paintable can change. A paintable will indicate this by calling [method
Gdk.Paintable.invalidate_size] which will emit the [signalGdkPaintable::invalidate-size] signal. And just like for contents, if a paintable is known to never change its size, it will set theGDK_PAINTABLE_STATIC_SIZEflag.Besides API for applications, there are some functions that are only useful for implementing subclasses and should not be used by applications: [method
See moreGdk.Paintable.invalidate_contents], [methodGdk.Paintable.invalidate_size], [funcGdk.Paintable.new_empty].Declaration
Swift
public struct PaintableRef : PaintableProtocol
-
The
DragSurfaceInterfaceReftype acts as a lightweight Swift reference to an underlyingGdkDragSurfaceInterfaceinstance. It exposes methods that can operate on this data type throughDragSurfaceInterfaceProtocolconformance. UseDragSurfaceInterfaceRefonly as anunownedreference to an existingGdkDragSurfaceInterfaceinstance.The
See moreGdkDragSurfaceInterfaceimplementation is private to GDK.Declaration
Swift
public struct DragSurfaceInterfaceRef : DragSurfaceInterfaceProtocol
-
The
EventSequenceReftype acts as a lightweight Swift reference to an underlyingGdkEventSequenceinstance. It exposes methods that can operate on this data type throughEventSequenceProtocolconformance. UseEventSequenceRefonly as anunownedreference to an existingGdkEventSequenceinstance.
See moreGdkEventSequenceis an opaque type representing a sequence of related touch events.Declaration
Swift
public struct EventSequenceRef : EventSequenceProtocol
-
The
FocusEventReftype acts as a lightweight Swift reference to an underlyingGdkFocusEventinstance. It exposes methods that can operate on this data type throughFocusEventProtocolconformance. UseFocusEventRefonly as anunownedreference to an existingGdkFocusEventinstance.An event related to a keyboard focus change.
See moreDeclaration
Swift
public struct FocusEventRef : FocusEventProtocol
-
The
FrameClockReftype acts as a lightweight Swift reference to an underlyingGdkFrameClockinstance. It exposes methods that can operate on this data type throughFrameClockProtocolconformance. UseFrameClockRefonly as anunownedreference to an existingGdkFrameClockinstance.A
GdkFrameClocktells the application when to update and repaint a surface.This may be synced to the vertical refresh rate of the monitor, for example. Even when the frame clock uses a simple timer rather than a hardware-based vertical sync, the frame clock helps because it ensures everything paints at the same time (reducing the total number of frames).
The frame clock can also automatically stop painting when it knows the frames will not be visible, or scale back animation framerates.
GdkFrameClockis designed to be compatible with an OpenGL-based implementation or with mozRequestAnimationFrame in Firefox, for example.A frame clock is idle until someone requests a frame with [method
Gdk.FrameClock.request_phase]. At some later point that makes sense for the synchronization being implemented, the clock will process a frame and emit signals for each phase that has been requested. (See the signals of theGdkFrameClockclass for documentation of the phases.GDK_FRAME_CLOCK_PHASE_UPDATEand the [signalGdkFrameClock::update] signal are most interesting for application writers, and are used to update the animations, using the frame time given by [metohdGdk.FrameClock.get_frame_time].The frame time is reported in microseconds and generally in the same timescale as
See moreg_get_monotonic_time(), however, it is not the same asg_get_monotonic_time(). The frame time does not advance during the time a frame is being painted, and outside of a frame, an attempt is made so that all calls to [methodGdk.FrameClock.get_frame_time] that are called at a “similar” time get the same value. This means that if different animations are timed by looking at the difference in time between an initial value from [methodGdk.FrameClock.get_frame_time] and the value inside the [signalGdkFrameClock::update] signal of the clock, they will stay exactly synchronized.Declaration
Swift
public struct FrameClockRef : FrameClockProtocol, GWeakCapturing
-
The
GLContextReftype acts as a lightweight Swift reference to an underlyingGdkGLContextinstance. It exposes methods that can operate on this data type throughGLContextProtocolconformance. UseGLContextRefonly as anunownedreference to an existingGdkGLContextinstance.GdkGLContextis an object representing a platform-specific OpenGL draw context.GdkGLContexts are created for a surface using [methodGdk.Surface.create_gl_context], and the context will match the the characteristics of the surface.A
GdkGLContextis not tied to any particular normal framebuffer. For instance, it cannot draw to the surface back buffer. The GDK repaint system is in full control of the painting to that. Instead, you can create render buffers or textures and use [funccairo_draw_from_gl] in the draw function of your widget to draw them. Then GDK will handle the integration of your rendering with that of other widgets.Support for
GdkGLContextis platform-specific and context creation can fail, returningnilcontext.A
GdkGLContexthas to be made “current” in order to start using it, otherwise any OpenGL call will be ignored.Creating a new OpenGL context
In order to create a new
GdkGLContextinstance you need aGdkSurface, which you typically get during the realize call of a widget.A
GdkGLContextis not realized until either [methodGdk.GLContext.make_current] or [methodGdk.GLContext.realize] is called. It is possible to specify details of the GL context like the OpenGL version to be used, or whether the GL context should have extra state validation enabled after calling [methodGdk.Surface.create_gl_context] by calling [methodGdk.GLContext.realize]. If the realization fails you have the option to change the settings of theGdkGLContextand try again.Using a GdkGLContext
You will need to make the
GdkGLContextthe current context before issuing OpenGL calls; the system sends OpenGL commands to whichever context is current. It is possible to have multiple contexts, so you always need to ensure that the one which you want to draw with is the current one before issuing commands:gdk_gl_context_make_current (context);You can now perform your drawing using OpenGL commands.
You can check which
See moreGdkGLContextis the current one by using [funcGdk.GLContext.get_current]; you can also unset anyGdkGLContextthat is currently set by calling [funcGdk.GLContext.clear_current].Declaration
Swift
public struct GLContextRef : GLContextProtocol, GWeakCapturing
-
The
See moreFrameClockClassReftype acts as a lightweight Swift reference to an underlyingGdkFrameClockClassinstance. It exposes methods that can operate on this data type throughFrameClockClassProtocolconformance. UseFrameClockClassRefonly as anunownedreference to an existingGdkFrameClockClassinstance.Declaration
Swift
public struct FrameClockClassRef : FrameClockClassProtocol
-
The
FrameTimingsReftype acts as a lightweight Swift reference to an underlyingGdkFrameTimingsinstance. It exposes methods that can operate on this data type throughFrameTimingsProtocolconformance. UseFrameTimingsRefonly as anunownedreference to an existingGdkFrameTimingsinstance.A
GdkFrameTimingsobject holds timing information for a single frame of the application’s displays.To retrieve
See moreGdkFrameTimingsobjects, use [methodGdk.FrameClock.get_timings] or [methodGdk.FrameClock.get_current_timings]. The information inGdkFrameTimingsis useful for precise synchronization of video with the event or audio streams, and for measuring quality metrics for the application’s display, such as latency and jitter.Declaration
Swift
public struct FrameTimingsRef : FrameTimingsProtocol
-
The
See moreGLTextureClassReftype acts as a lightweight Swift reference to an underlyingGdkGLTextureClassinstance. It exposes methods that can operate on this data type throughGLTextureClassProtocolconformance. UseGLTextureClassRefonly as anunownedreference to an existingGdkGLTextureClassinstance.Declaration
Swift
public struct GLTextureClassRef : GLTextureClassProtocol
-
The
GLTextureReftype acts as a lightweight Swift reference to an underlyingGdkGLTextureinstance. It exposes methods that can operate on this data type throughGLTextureProtocolconformance. UseGLTextureRefonly as anunownedreference to an existingGdkGLTextureinstance.A GdkTexture representing a GL texture object.
See moreDeclaration
Swift
public struct GLTextureRef : GLTextureProtocol, GWeakCapturing
-
The
GrabBrokenEventReftype acts as a lightweight Swift reference to an underlyingGdkGrabBrokenEventinstance. It exposes methods that can operate on this data type throughGrabBrokenEventProtocolconformance. UseGrabBrokenEventRefonly as anunownedreference to an existingGdkGrabBrokenEventinstance.An event related to a broken windowing system grab.
See moreDeclaration
Swift
public struct GrabBrokenEventRef : GrabBrokenEventProtocol
-
The
KeyEventReftype acts as a lightweight Swift reference to an underlyingGdkKeyEventinstance. It exposes methods that can operate on this data type throughKeyEventProtocolconformance. UseKeyEventRefonly as anunownedreference to an existingGdkKeyEventinstance.An event related to a key-based device.
See moreDeclaration
Swift
public struct KeyEventRef : KeyEventProtocol
-
The
KeymapKeyReftype acts as a lightweight Swift reference to an underlyingGdkKeymapKeyinstance. It exposes methods that can operate on this data type throughKeymapKeyProtocolconformance. UseKeymapKeyRefonly as anunownedreference to an existingGdkKeymapKeyinstance.A
See moreGdkKeymapKeyis a hardware key that can be mapped to a keyval.Declaration
Swift
public struct KeymapKeyRef : KeymapKeyProtocol
-
The
See moreMemoryTextureClassReftype acts as a lightweight Swift reference to an underlyingGdkMemoryTextureClassinstance. It exposes methods that can operate on this data type throughMemoryTextureClassProtocolconformance. UseMemoryTextureClassRefonly as anunownedreference to an existingGdkMemoryTextureClassinstance.Declaration
Swift
public struct MemoryTextureClassRef : MemoryTextureClassProtocol
-
The
MemoryTextureReftype acts as a lightweight Swift reference to an underlyingGdkMemoryTextureinstance. It exposes methods that can operate on this data type throughMemoryTextureProtocolconformance. UseMemoryTextureRefonly as anunownedreference to an existingGdkMemoryTextureinstance.A
See moreGdkTexturerepresenting image data in memory.Declaration
Swift
public struct MemoryTextureRef : MemoryTextureProtocol, GWeakCapturing
-
The
MonitorReftype acts as a lightweight Swift reference to an underlyingGdkMonitorinstance. It exposes methods that can operate on this data type throughMonitorProtocolconformance. UseMonitorRefonly as anunownedreference to an existingGdkMonitorinstance.GdkMonitorobjects represent the individual outputs that are associated with aGdkDisplay.
See moreGdkDisplaykeeps aGListModelto enumerate and monitor monitors with [methodGdk.Display.get_monitors]. You can use [methodGdk.Display.get_monitor_at_surface] to find a particular monitor.Declaration
Swift
public struct MonitorRef : MonitorProtocol, GWeakCapturing
-
The
MotionEventReftype acts as a lightweight Swift reference to an underlyingGdkMotionEventinstance. It exposes methods that can operate on this data type throughMotionEventProtocolconformance. UseMotionEventRefonly as anunownedreference to an existingGdkMotionEventinstance.An event related to a pointer or touch device motion.
See moreDeclaration
Swift
public struct MotionEventRef : MotionEventProtocol
-
The
PadEventReftype acts as a lightweight Swift reference to an underlyingGdkPadEventinstance. It exposes methods that can operate on this data type throughPadEventProtocolconformance. UsePadEventRefonly as anunownedreference to an existingGdkPadEventinstance.An event related to a pad-based device.
See moreDeclaration
Swift
public struct PadEventRef : PadEventProtocol
-
The
See moreMonitorClassReftype acts as a lightweight Swift reference to an underlyingGdkMonitorClassinstance. It exposes methods that can operate on this data type throughMonitorClassProtocolconformance. UseMonitorClassRefonly as anunownedreference to an existingGdkMonitorClassinstance.Declaration
Swift
public struct MonitorClassRef : MonitorClassProtocol
-
The
PaintableInterfaceReftype acts as a lightweight Swift reference to an underlyingGdkPaintableInterfaceinstance. It exposes methods that can operate on this data type throughPaintableInterfaceProtocolconformance. UsePaintableInterfaceRefonly as anunownedreference to an existingGdkPaintableInterfaceinstance.The list of functions that can be implemented for the
GdkPaintableinterface.Note that apart from the
See moreGdkPaintableInterface.snapshot()function, no virtual function of this interface is mandatory to implement, though it is a good idea to implementGdkPaintableInterface.get_current_image()for non-static paintables andGdkPaintableInterface.get_flags()if the image is not dynamic as the default implementation returns no flags and that will make the implementation likely quite slow.Declaration
Swift
public struct PaintableInterfaceRef : PaintableInterfaceProtocol
-
The
PopupReftype acts as a lightweight Swift reference to an underlyingGdkPopupinstance. It exposes methods that can operate on this data type throughPopupProtocolconformance. UsePopupRefonly as anunownedreference to an existingGdkPopupinstance.A
GdkPopupis a surface that is attached to another surface.The
GdkPopupis positioned relative to its parent surface.
See moreGdkPopups are typically used to implement menus and similar popups. They can be modal, which is indicated by the [propertyGdkPopup:autohide] property.Declaration
Swift
public struct PopupRef : PopupProtocol, GWeakCapturing
-
The
ToplevelReftype acts as a lightweight Swift reference to an underlyingGdkToplevelinstance. It exposes methods that can operate on this data type throughToplevelProtocolconformance. UseToplevelRefonly as anunownedreference to an existingGdkToplevelinstance.A
GdkToplevelis a freestanding toplevel surface.The
See moreGdkToplevelinterface provides useful APIs for interacting with the windowing system, such as controlling maximization and size of the surface, setting icons and transient parents for dialogs.Declaration
Swift
public struct ToplevelRef : ToplevelProtocol, GWeakCapturing
-
The
See morePopupInterfaceReftype acts as a lightweight Swift reference to an underlyingGdkPopupInterfaceinstance. It exposes methods that can operate on this data type throughPopupInterfaceProtocolconformance. UsePopupInterfaceRefonly as anunownedreference to an existingGdkPopupInterfaceinstance.Declaration
Swift
public struct PopupInterfaceRef : PopupInterfaceProtocol
-
The
PopupLayoutReftype acts as a lightweight Swift reference to an underlyingGdkPopupLayoutinstance. It exposes methods that can operate on this data type throughPopupLayoutProtocolconformance. UsePopupLayoutRefonly as anunownedreference to an existingGdkPopupLayoutinstance.The
GdkPopupLayoutstruct contains information that is necessary position a [interfaceGdk.Popup] relative to its parent.The positioning requires a negotiation with the windowing system, since it depends on external constraints, such as the position of the parent surface, and the screen dimensions.
The basic ingredients are a rectangle on the parent surface, and the anchor on both that rectangle and the popup. The anchors specify a side or corner to place next to each other.

For cases where placing the anchors next to each other would make the popup extend offscreen, the layout includes some hints for how to resolve this problem. The hints may suggest to flip the anchor position to the other side, or to ‘slide’ the popup along a side, or to resize it.


These hints may be combined.
Ultimatively, it is up to the windowing system to determine the position and size of the popup. You can learn about the result by calling [method
See moreGdk.Popup.get_position_x], [methodGdk.Popup.get_position_y], [methodGdk.Popup.get_rect_anchor] and [methodGdk.Popup.get_surface_anchor] after the popup has been presented. This can be used to adjust the rendering. For example, [classGtk.Popover] changes its arrow position accordingly. But you have to be careful avoid changing the size of the popover, or it has to be presented again.Declaration
Swift
public struct PopupLayoutRef : PopupLayoutProtocol
-
The
RGBAReftype acts as a lightweight Swift reference to an underlyingGdkRGBAinstance. It exposes methods that can operate on this data type throughRGBAProtocolconformance. UseRGBARefonly as anunownedreference to an existingGdkRGBAinstance.A
GdkRGBAis used to represent a color, in a way that is compatible with cairo’s notion of color.
See moreGdkRGBAis a convenient way to pass colors around. It’s based on cairo’s way to deal with colors and mirrors its behavior. All values are in the range from 0.0 to 1.0 inclusive. So the color (0.0, 0.0, 0.0, 0.0) represents transparent black and (1.0, 1.0, 1.0, 1.0) is opaque white. Other values will be clamped to this range when drawing.Declaration
Swift
public struct RGBARef : RGBAProtocol
-
The
ProximityEventReftype acts as a lightweight Swift reference to an underlyingGdkProximityEventinstance. It exposes methods that can operate on this data type throughProximityEventProtocolconformance. UseProximityEventRefonly as anunownedreference to an existingGdkProximityEventinstance.An event related to the proximity of a tool to a device.
See moreDeclaration
Swift
public struct ProximityEventRef : ProximityEventProtocol
-
The
ScrollEventReftype acts as a lightweight Swift reference to an underlyingGdkScrollEventinstance. It exposes methods that can operate on this data type throughScrollEventProtocolconformance. UseScrollEventRefonly as anunownedreference to an existingGdkScrollEventinstance.An event related to a scrolling motion.
See moreDeclaration
Swift
public struct ScrollEventRef : ScrollEventProtocol
-
The
RectangleReftype acts as a lightweight Swift reference to an underlyingGdkRectangleinstance. It exposes methods that can operate on this data type throughRectangleProtocolconformance. UseRectangleRefonly as anunownedreference to an existingGdkRectangleinstance.A
GdkRectangledata type for representing rectangles.GdkRectangleis identical tocairo_rectangle_t. Together with Cairo’scairo_region_tdata type, these are the central types for representing sets of pixels.The intersection of two rectangles can be computed with [method
Gdk.Rectangle.intersect]; to find the union of two rectangles use [methodGdk.Rectangle.union].The
cairo_region_ttype provided by Cairo is usually used for managing non-rectangular clipping of graphical operations.The Graphene library has a number of other data types for regions and volumes in 2D and 3D.
See moreDeclaration
Swift
public struct RectangleRef : RectangleProtocol
-
The
See moreSnapshotClassReftype acts as a lightweight Swift reference to an underlyingGdkSnapshotClassinstance. It exposes methods that can operate on this data type throughSnapshotClassProtocolconformance. UseSnapshotClassRefonly as anunownedreference to an existingGdkSnapshotClassinstance.Declaration
Swift
public struct SnapshotClassRef : SnapshotClassProtocol
-
The
SeatReftype acts as a lightweight Swift reference to an underlyingGdkSeatinstance. It exposes methods that can operate on this data type throughSeatProtocolconformance. UseSeatRefonly as anunownedreference to an existingGdkSeatinstance.The
See moreGdkSeatobject represents a collection of input devices that belong to a user.Declaration
Swift
public struct SeatRef : SeatProtocol, GWeakCapturing
-
The
SnapshotReftype acts as a lightweight Swift reference to an underlyingGdkSnapshotinstance. It exposes methods that can operate on this data type throughSnapshotProtocolconformance. UseSnapshotRefonly as anunownedreference to an existingGdkSnapshotinstance.Base type for snapshot operations.
The subclass of
See moreGdkSnapshotused by GTK is [classGtk.Snapshot].Declaration
Swift
public struct SnapshotRef : SnapshotProtocol, GWeakCapturing
-
The
SurfaceReftype acts as a lightweight Swift reference to an underlyingGdkSurfaceinstance. It exposes methods that can operate on this data type throughSurfaceProtocolconformance. UseSurfaceRefonly as anunownedreference to an existingGdkSurfaceinstance.A
GdkSurfaceis a rectangular region on the screen.It’s a low-level object, used to implement high-level objects such as [class
Gtk.Window] or [classGtk.Dialog] in GTK.The surfaces you see in practice are either [class
See moreGdk.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.Declaration
Swift
public struct SurfaceRef : SurfaceProtocol, GWeakCapturing
-
The
TextureReftype acts as a lightweight Swift reference to an underlyingGdkTextureinstance. It exposes methods that can operate on this data type throughTextureProtocolconformance. UseTextureRefonly as anunownedreference to an existingGdkTextureinstance.GdkTextureis the basic element used to refer to pixel data.It is primarily meant for pixel data that will not change over multiple frames, and will be used for a long time.
There are various ways to create
GdkTextureobjects from aGdkPixbuf, or a Cairo surface, or other pixel data.The ownership of the pixel data is transferred to the
GdkTextureinstance; you can only make a copy of it, via [methodGdk.Texture.download].
See moreGdkTextureis an immutable object: That means you cannot change anything about it other than increasing the reference count viag_object_ref().Declaration
Swift
public struct TextureRef : TextureProtocol, GWeakCapturing
-
The
See moreSurfaceClassReftype acts as a lightweight Swift reference to an underlyingGdkSurfaceClassinstance. It exposes methods that can operate on this data type throughSurfaceClassProtocolconformance. UseSurfaceClassRefonly as anunownedreference to an existingGdkSurfaceClassinstance.Declaration
Swift
public struct SurfaceClassRef : SurfaceClassProtocol
-
The
See moreTextureClassReftype acts as a lightweight Swift reference to an underlyingGdkTextureClassinstance. It exposes methods that can operate on this data type throughTextureClassProtocolconformance. UseTextureClassRefonly as anunownedreference to an existingGdkTextureClassinstance.Declaration
Swift
public struct TextureClassRef : TextureClassProtocol
-
The
TimeCoordReftype acts as a lightweight Swift reference to an underlyingGdkTimeCoordinstance. It exposes methods that can operate on this data type throughTimeCoordProtocolconformance. UseTimeCoordRefonly as anunownedreference to an existingGdkTimeCoordinstance.A
See moreGdkTimeCoordstores a single event in a motion history.Declaration
Swift
public struct TimeCoordRef : TimeCoordProtocol
-
The
See moreToplevelInterfaceReftype acts as a lightweight Swift reference to an underlyingGdkToplevelInterfaceinstance. It exposes methods that can operate on this data type throughToplevelInterfaceProtocolconformance. UseToplevelInterfaceRefonly as anunownedreference to an existingGdkToplevelInterfaceinstance.Declaration
Swift
public struct ToplevelInterfaceRef : ToplevelInterfaceProtocol
-
The
ToplevelLayoutReftype acts as a lightweight Swift reference to an underlyingGdkToplevelLayoutinstance. It exposes methods that can operate on this data type throughToplevelLayoutProtocolconformance. UseToplevelLayoutRefonly as anunownedreference to an existingGdkToplevelLayoutinstance.The
GdkToplevelLayoutstruct contains information that is necessary to present a sovereign window on screen.The
GdkToplevelLayoutstruct is necessary for using [methodGdk.Toplevel.present].Toplevel surfaces are sovereign windows that can be presented to the user in various states (maximized, on all workspaces, etc).
See moreDeclaration
Swift
public struct ToplevelLayoutRef : ToplevelLayoutProtocol
-
The
ToplevelSizeReftype acts as a lightweight Swift reference to an underlyingGdkToplevelSizeinstance. It exposes methods that can operate on this data type throughToplevelSizeProtocolconformance. UseToplevelSizeRefonly as anunownedreference to an existingGdkToplevelSizeinstance.The
See moreGdkToplevelSizestruct contains information that is useful to compute the size of a toplevel.Declaration
Swift
public struct ToplevelSizeRef : ToplevelSizeProtocol
-
The
TouchEventReftype acts as a lightweight Swift reference to an underlyingGdkTouchEventinstance. It exposes methods that can operate on this data type throughTouchEventProtocolconformance. UseTouchEventRefonly as anunownedreference to an existingGdkTouchEventinstance.An event related to a touch-based device.
See moreDeclaration
Swift
public struct TouchEventRef : TouchEventProtocol
-
The
TouchpadEventReftype acts as a lightweight Swift reference to an underlyingGdkTouchpadEventinstance. It exposes methods that can operate on this data type throughTouchpadEventProtocolconformance. UseTouchpadEventRefonly as anunownedreference to an existingGdkTouchpadEventinstance.An event related to a gesture on a touchpad device.
Unlike touchscreens, where the windowing system sends basic sequences of begin, update, end events, and leaves gesture recognition to the clients, touchpad gestures are typically processed by the system, resulting in these events.
See moreDeclaration
Swift
public struct TouchpadEventRef : TouchpadEventProtocol
-
The
VulkanContextReftype acts as a lightweight Swift reference to an underlyingGdkVulkanContextinstance. It exposes methods that can operate on this data type throughVulkanContextProtocolconformance. UseVulkanContextRefonly as anunownedreference to an existingGdkVulkanContextinstance.GdkVulkanContextis an object representing the platform-specific Vulkan draw context.GdkVulkanContexts are created for a surface using [methodGdk.Surface.create_vulkan_context], and the context will match the the characteristics of the surface.Support for
See moreGdkVulkanContextis platform-specific and context creation can fail, returningnilcontext.Declaration
Swift
public struct VulkanContextRef : VulkanContextProtocol, GWeakCapturing -
Positioning hints for aligning a surface relative to a rectangle.
These hints determine how the surface should be positioned in the case that the surface would fall off-screen if placed in its ideal position.
For example,
GDK_ANCHOR_FLIP_Xwill replaceGDK_GRAVITY_NORTH_WESTwithGDK_GRAVITY_NORTH_EASTand vice versa if the surface extends beyond the left or right edges of the monitor.If
GDK_ANCHOR_SLIDE_Xis set, the surface can be shifted horizontally to fit on-screen. IfGDK_ANCHOR_RESIZE_Xis set, the surface can be shrunken horizontally to fit.In general, when multiple flags are set, flipping should take precedence over sliding, which should take precedence over resizing.
See moreDeclaration
Swift
public struct AnchorHints : OptionSet -
Flags describing the current capabilities of a device/tool.
See moreDeclaration
Swift
public struct AxisFlags : OptionSet -
Used in
See moreGdkDropandGdkDragto indicate the actions that the destination can and should do with the dropped data.Declaration
Swift
public struct DragAction : OptionSet -
Used to represent the different paint clock phases that can be requested.
The elements of the enumeration correspond to the signals of
See moreGdkFrameClock.Declaration
Swift
public struct FrameClockPhase : OptionSet -
Flags to indicate the state of modifier keys and mouse buttons in events.
Typical modifier keys are Shift, Control, Meta, Super, Hyper, Alt, Compose, Apple, CapsLock or ShiftLock.
Note that GDK may add internal values to events which include values outside of this enumeration. Your code should preserve and ignore them. You can use
See moreGDK_MODIFIER_MASKto remove all private values.Declaration
Swift
public struct ModifierType : OptionSet -
Flags about a paintable object.
Implementations use these for optimizations such as caching.
See moreDeclaration
Swift
public struct PaintableFlags : OptionSet -
Flags describing the seat capabilities.
See moreDeclaration
Swift
public struct SeatCapabilities : OptionSet -
Specifies the state of a toplevel surface.
On platforms that support information about individual edges, the
See moreGDK_TOPLEVEL_STATE_TILEDstate will be set whenever any of the individual tiled states is set. On platforms that lack that support, the tiled state will give an indication of tiledness without any of the per-edge states being set.Declaration
Swift
public struct ToplevelState : OptionSet
View on GitHub
Install in Dash
Structures Reference