Structures
The following structures are available globally.
-
The
AppLaunchContextRef
type acts as a lightweight Swift reference to an underlyingGdkAppLaunchContext
instance. It exposes methods that can operate on this data type throughAppLaunchContextProtocol
conformance. UseAppLaunchContextRef
only as anunowned
reference to an existingGdkAppLaunchContext
instance.GdkAppLaunchContext is an implementation of
GAppLaunchContext
that handles launching an application in a graphical context. It provides startup notification and allows to launch applications on a specific screen or workspace.Launching an application
(C Language Example):
See moreGdkAppLaunchContext *context; context = gdk_display_get_app_launch_context (display); gdk_app_launch_context_set_screen (screen); gdk_app_launch_context_set_timestamp (event->time); 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
CursorRef
type acts as a lightweight Swift reference to an underlyingGdkCursor
instance. It exposes methods that can operate on this data type throughCursorProtocol
conformance. UseCursorRef
only as anunowned
reference to an existingGdkCursor
instance.A
See moreGdkCursor
represents a cursor. Its contents are private.Declaration
Swift
public struct CursorRef : CursorProtocol, GWeakCapturing
-
The
AtomRef
type acts as a lightweight Swift reference to an underlyingGdkAtom
instance. It exposes methods that can operate on this data type throughAtomProtocol
conformance. UseAtomRef
only as anunowned
reference to an existingGdkAtom
instance.An opaque type representing a string as an index into a table of strings on the X server.
See moreDeclaration
Swift
public struct AtomRef : AtomProtocol
-
The
ColorRef
type acts as a lightweight Swift reference to an underlyingGdkColor
instance. It exposes methods that can operate on this data type throughColorProtocol
conformance. UseColorRef
only as anunowned
reference to an existingGdkColor
instance.A
See moreGdkColor
is used to describe a color, similar to the XColor struct used in the X11 drawing API.Declaration
Swift
public struct ColorRef : ColorProtocol
-
The
DeviceRef
type acts as a lightweight Swift reference to an underlyingGdkDevice
instance. It exposes methods that can operate on this data type throughDeviceProtocol
conformance. UseDeviceRef
only as anunowned
reference to an existingGdkDevice
instance.The
GdkDevice
object represents a single input device, such as a keyboard, a mouse, a touchpad, etc.See the
See moreGdkDeviceManager
documentation for more information about the various kinds of master and slave devices, and their relationships.Declaration
Swift
public struct DeviceRef : DeviceProtocol, GWeakCapturing
-
The
DeviceManagerRef
type acts as a lightweight Swift reference to an underlyingGdkDeviceManager
instance. It exposes methods that can operate on this data type throughDeviceManagerProtocol
conformance. UseDeviceManagerRef
only as anunowned
reference to an existingGdkDeviceManager
instance.In addition to a single pointer and keyboard for user interface input, GDK contains support for a variety of input devices, including graphics tablets, touchscreens and multiple pointers/keyboards interacting simultaneously with the user interface. Such input devices often have additional features, such as sub-pixel positioning information and additional device-dependent information.
In order to query the device hierarchy and be aware of changes in the device hierarchy (such as virtual devices being created or removed, or physical devices being plugged or unplugged), GDK provides
GdkDeviceManager
.By default, and if the platform supports it, GDK is aware of multiple keyboard/pointer pairs and multitouch devices. This behavior can be changed by calling
gdk_disable_multidevice()
beforegdk_display_open()
. There should rarely be a need to do that though, since GDK defaults to a compatibility mode in which it will emit just one enter/leave event pair for all devices on a window. To enable per-device enter/leave events and other multi-pointer interaction features,gdk_window_set_support_multidevice()
must be called onGdkWindows
(orgtk_widget_set_support_multidevice()
on widgets). window. See thegdk_window_set_support_multidevice()
documentation for more information.On X11, multi-device support is implemented through XInput 2. Unless
gdk_disable_multidevice()
is called, the XInput 2GdkDeviceManager
implementation will be used as the input source. Otherwise either the core or XInput 1 implementations will be used.For simple applications that don’t have any special interest in input devices, the so-called “client pointer” provides a reasonable approximation to a simple setup with a single pointer and keyboard. The device that has been set as the client pointer can be accessed via
gdk_device_manager_get_client_pointer()
.Conceptually, in multidevice mode there are 2 device types. Virtual devices (or master devices) are represented by the pointer cursors and keyboard foci that are seen on the screen. Physical devices (or slave devices) represent the hardware that is controlling the virtual devices, and thus have no visible cursor on the screen.
Virtual devices are always paired, so there is a keyboard device for every pointer device. Associations between devices may be inspected through
gdk_device_get_associated_device()
.There may be several virtual devices, and several physical devices could be controlling each of these virtual devices. Physical devices may also be “floating”, which means they are not attached to any virtual device.
Master and slave devices
carlos@sacarino:~$ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Wacom ISDv4 E6 Pen stylus id=10 [slave pointer (2)] ⎜ ↳ Wacom ISDv4 E6 Finger touch id=11 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=13 [slave pointer (2)] ⎜ ↳ TPPS/2 IBM TrackPoint id=14 [slave pointer (2)] ⎜ ↳ Wacom ISDv4 E6 Pen eraser id=16 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Sleep Button id=8 [slave keyboard (3)] ↳ Integrated Camera id=9 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)] ↳ ThinkPad Extra Buttons id=15 [slave keyboard (3)]
By default, GDK will automatically listen for events coming from all master devices, setting the
GdkDevice
for all events coming from input devices. Events containing device information areGDK_MOTION_NOTIFY
,GDK_BUTTON_PRESS
,GDK_2BUTTON_PRESS
,GDK_3BUTTON_PRESS
,GDK_BUTTON_RELEASE
,GDK_SCROLL
,GDK_KEY_PRESS
,GDK_KEY_RELEASE
,GDK_ENTER_NOTIFY
,GDK_LEAVE_NOTIFY
,GDK_FOCUS_CHANGE
,GDK_PROXIMITY_IN
,GDK_PROXIMITY_OUT
,GDK_DRAG_ENTER
,GDK_DRAG_LEAVE
,GDK_DRAG_MOTION
,GDK_DRAG_STATUS
,GDK_DROP_START
,GDK_DROP_FINISHED
andGDK_GRAB_BROKEN
. When dealing with an event on a master device, it is possible to get the source (slave) device that the event originated from viagdk_event_get_source_device()
.On a standard session, all physical devices are connected by default to the “Virtual Core Pointer/Keyboard” master devices, hence routing all events through these. This behavior is only modified by device grabs, where the slave device is temporarily detached for as long as the grab is held, and more permanently by user modifications to the device hierarchy.
On certain application specific setups, it may make sense to detach a physical device from its master pointer, and mapping it to an specific window. This can be achieved by the combination of
gdk_device_grab()
andgdk_device_set_mode()
.In order to listen for events coming from devices other than a virtual device,
gdk_window_set_device_events()
must be called. Generally, this function can be used to modify the event mask for any given device.Input devices may also provide additional information besides X/Y. For example, graphics tablets may also provide pressure and X/Y tilt information. This information is device-dependent, and may be queried through
gdk_device_get_axis()
. In multidevice mode, virtual devices will change axes in order to always represent the physical device that is routing events through it. Whenever the physical device changes, theGdkDevice:n-axes
property will be notified, andgdk_device_list_axes()
will return the new device axes.Devices may also have associated “keys” or macro buttons. Such keys can be globally set to map into normal X keyboard events. The mapping is set using
gdk_device_set_key()
.In GTK+ 3.20, a new
See moreGdkSeat
object has been introduced that supersedesGdkDeviceManager
and should be preferred in newly written code.Declaration
Swift
public struct DeviceManagerRef : DeviceManagerProtocol, GWeakCapturing
-
The
See moreDeviceToolRef
type acts as a lightweight Swift reference to an underlyingGdkDeviceTool
instance. It exposes methods that can operate on this data type throughDeviceToolProtocol
conformance. UseDeviceToolRef
only as anunowned
reference to an existingGdkDeviceTool
instance.Declaration
Swift
public struct DeviceToolRef : DeviceToolProtocol, GWeakCapturing
-
The
DisplayRef
type acts as a lightweight Swift reference to an underlyingGdkDisplay
instance. It exposes methods that can operate on this data type throughDisplayProtocol
conformance. UseDisplayRef
only as anunowned
reference to an existingGdkDisplay
instance.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 mousepointer(s)
of the display.Most of the input device handling has been factored out into the separate
See moreGdkDeviceManager
object. Every display has a device manager, which you can obtain usinggdk_display_get_device_manager()
.Declaration
Swift
public struct DisplayRef : DisplayProtocol, GWeakCapturing
-
The
DisplayManagerRef
type acts as a lightweight Swift reference to an underlyingGdkDisplayManager
instance. It exposes methods that can operate on this data type throughDisplayManagerProtocol
conformance. UseDisplayManagerRef
only as anunowned
reference to an existingGdkDisplayManager
instance.The purpose of the
GdkDisplayManager
singleton object is to offer notification when displays appear or disappear or the default display changes.You can use
gdk_display_manager_get()
to obtain theGdkDisplayManager
singleton, 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
GdkDisplayManager
object determines which backend is used at runtime.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_WIN32
macros, 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:Backend-specific code ##
(C Language Example):
See more#ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (display)) { // make X11-specific calls here } else #endif #ifdef GDK_WINDOWING_QUARTZ if (GDK_IS_QUARTZ_DISPLAY (display)) { // make Quartz-specific calls here } else #endif g_error ("Unsupported GDK backend");
Declaration
Swift
public struct DisplayManagerRef : DisplayManagerProtocol, GWeakCapturing
-
The
See moreDragContextRef
type acts as a lightweight Swift reference to an underlyingGdkDragContext
instance. It exposes methods that can operate on this data type throughDragContextProtocol
conformance. UseDragContextRef
only as anunowned
reference to an existingGdkDragContext
instance.Declaration
Swift
public struct DragContextRef : DragContextProtocol, GWeakCapturing
-
The
DrawingContextRef
type acts as a lightweight Swift reference to an underlyingGdkDrawingContext
instance. It exposes methods that can operate on this data type throughDrawingContextProtocol
conformance. UseDrawingContextRef
only as anunowned
reference to an existingGdkDrawingContext
instance.GdkDrawingContext
is an object that represents the current drawing state of aGdkWindow
.It’s possible to use a
GdkDrawingContext
to draw on aGdkWindow
via rendering API like Cairo or OpenGL.A
GdkDrawingContext
can only be created by callinggdk_window_begin_draw_frame()
and will be valid until a call togdk_window_end_draw_frame()
.
See moreGdkDrawingContext
is available since GDK 3.22Declaration
Swift
public struct DrawingContextRef : DrawingContextProtocol, GWeakCapturing
-
The
FrameClockRef
type acts as a lightweight Swift reference to an underlyingGdkFrameClock
instance. It exposes methods that can operate on this data type throughFrameClockProtocol
conformance. UseFrameClockRef
only as anunowned
reference to an existingGdkFrameClock
instance.A
GdkFrameClock
tells the application when to update and repaint a window. 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.GdkFrameClock
is 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
gdk_frame_clock_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 theGdkFrameClock
class for documentation of the phases.GDK_FRAME_CLOCK_PHASE_UPDATE
and theGdkFrameClock::update
signal are most interesting for application writers, and are used to update the animations, using the frame time given bygdk_frame_clock_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 togdk_frame_clock_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 fromgdk_frame_clock_get_frame_time()
and the value inside theGdkFrameClock::update
signal of the clock, they will stay exactly synchronized.Declaration
Swift
public struct FrameClockRef : FrameClockProtocol, GWeakCapturing
-
The
DevicePadRef
type acts as a lightweight Swift reference to an underlyingGdkDevicePad
instance. It exposes methods that can operate on this data type throughDevicePadProtocol
conformance. UseDevicePadRef
only as anunowned
reference to an existingGdkDevicePad
instance.GdkDevicePad
is an interface implemented by devices of typeGDK_SOURCE_TABLET_PAD
, it 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.
gdk_device_pad_get_n_groups()
can be used to obtain the number of groups,gdk_device_pad_get_n_features()
andgdk_device_pad_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
See moregdk_device_pad_get_group_n_modes()
, and the current mode for a given group will be notified through theGdkEventPadGroupMode
event.Declaration
Swift
public struct DevicePadRef : DevicePadProtocol, GWeakCapturing
-
The
See moreDevicePadInterfaceRef
type acts as a lightweight Swift reference to an underlyingGdkDevicePadInterface
instance. It exposes methods that can operate on this data type throughDevicePadInterfaceProtocol
conformance. UseDevicePadInterfaceRef
only as anunowned
reference to an existingGdkDevicePadInterface
instance.Declaration
Swift
public struct DevicePadInterfaceRef : DevicePadInterfaceProtocol
-
The
See moreDrawingContextClassRef
type acts as a lightweight Swift reference to an underlyingGdkDrawingContextClass
instance. It exposes methods that can operate on this data type throughDrawingContextClassProtocol
conformance. UseDrawingContextClassRef
only as anunowned
reference to an existingGdkDrawingContextClass
instance.Declaration
Swift
public struct DrawingContextClassRef : DrawingContextClassProtocol
-
The
EventAnyRef
type acts as a lightweight Swift reference to an underlyingGdkEventAny
instance. It exposes methods that can operate on this data type throughEventAnyProtocol
conformance. UseEventAnyRef
only as anunowned
reference to an existingGdkEventAny
instance.Contains the fields which are common to all event structs. Any event pointer can safely be cast to a pointer to a
See moreGdkEventAny
to access these fields.Declaration
Swift
public struct EventAnyRef : EventAnyProtocol
-
The
EventButtonRef
type acts as a lightweight Swift reference to an underlyingGdkEventButton
instance. It exposes methods that can operate on this data type throughEventButtonProtocol
conformance. UseEventButtonRef
only as anunowned
reference to an existingGdkEventButton
instance.Used for button press and button release events. The
type
field will be one ofGDK_BUTTON_PRESS
,GDK_2BUTTON_PRESS
,GDK_3BUTTON_PRESS
orGDK_BUTTON_RELEASE
,Double and triple-clicks result in a sequence of events being received. For double-clicks the order of events will be:
GDK_BUTTON_PRESS
GDK_BUTTON_RELEASE
GDK_BUTTON_PRESS
GDK_2BUTTON_PRESS
GDK_BUTTON_RELEASE
Note that the first click is received just like a normal button press, while the second click results in a
GDK_2BUTTON_PRESS
being received just after theGDK_BUTTON_PRESS
.Triple-clicks are very similar to double-clicks, except that
GDK_3BUTTON_PRESS
is inserted after the third click. The order of the events is:GDK_BUTTON_PRESS
GDK_BUTTON_RELEASE
GDK_BUTTON_PRESS
GDK_2BUTTON_PRESS
GDK_BUTTON_RELEASE
GDK_BUTTON_PRESS
GDK_3BUTTON_PRESS
GDK_BUTTON_RELEASE
For a double click to occur, the second button press must occur within ¼ of a second of the first. For a triple click to occur, the third button press must also occur within ½ second of the first button press.
See moreDeclaration
Swift
public struct EventButtonRef : EventButtonProtocol
-
The
EventConfigureRef
type acts as a lightweight Swift reference to an underlyingGdkEventConfigure
instance. It exposes methods that can operate on this data type throughEventConfigureProtocol
conformance. UseEventConfigureRef
only as anunowned
reference to an existingGdkEventConfigure
instance.Generated when a window size or position has changed.
See moreDeclaration
Swift
public struct EventConfigureRef : EventConfigureProtocol
-
The
EventCrossingRef
type acts as a lightweight Swift reference to an underlyingGdkEventCrossing
instance. It exposes methods that can operate on this data type throughEventCrossingProtocol
conformance. UseEventCrossingRef
only as anunowned
reference to an existingGdkEventCrossing
instance.Generated when the pointer enters or leaves a window.
See moreDeclaration
Swift
public struct EventCrossingRef : EventCrossingProtocol
-
The
EventDNDRef
type acts as a lightweight Swift reference to an underlyingGdkEventDND
instance. It exposes methods that can operate on this data type throughEventDNDProtocol
conformance. UseEventDNDRef
only as anunowned
reference to an existingGdkEventDND
instance.Generated during DND operations.
See moreDeclaration
Swift
public struct EventDNDRef : EventDNDProtocol
-
The
EventExposeRef
type acts as a lightweight Swift reference to an underlyingGdkEventExpose
instance. It exposes methods that can operate on this data type throughEventExposeProtocol
conformance. UseEventExposeRef
only as anunowned
reference to an existingGdkEventExpose
instance.Generated when all or part of a window becomes visible and needs to be redrawn.
See moreDeclaration
Swift
public struct EventExposeRef : EventExposeProtocol
-
The
EventFocusRef
type acts as a lightweight Swift reference to an underlyingGdkEventFocus
instance. It exposes methods that can operate on this data type throughEventFocusProtocol
conformance. UseEventFocusRef
only as anunowned
reference to an existingGdkEventFocus
instance.Describes a change of keyboard focus.
See moreDeclaration
Swift
public struct EventFocusRef : EventFocusProtocol
-
The
EventGrabBrokenRef
type acts as a lightweight Swift reference to an underlyingGdkEventGrabBroken
instance. It exposes methods that can operate on this data type throughEventGrabBrokenProtocol
conformance. UseEventGrabBrokenRef
only as anunowned
reference to an existingGdkEventGrabBroken
instance.Generated when a pointer or keyboard grab is broken. On X11, this happens when the grab window becomes unviewable (i.e. it or one of its ancestors is unmapped), or if the same application grabs the pointer or keyboard again. Note that implicit grabs (which are initiated by button presses) can also cause
See moreGdkEventGrabBroken
events.Declaration
Swift
public struct EventGrabBrokenRef : EventGrabBrokenProtocol
-
The
EventKeyRef
type acts as a lightweight Swift reference to an underlyingGdkEventKey
instance. It exposes methods that can operate on this data type throughEventKeyProtocol
conformance. UseEventKeyRef
only as anunowned
reference to an existingGdkEventKey
instance.Describes a key press or key release event.
See moreDeclaration
Swift
public struct EventKeyRef : EventKeyProtocol
-
The
EventMotionRef
type acts as a lightweight Swift reference to an underlyingGdkEventMotion
instance. It exposes methods that can operate on this data type throughEventMotionProtocol
conformance. UseEventMotionRef
only as anunowned
reference to an existingGdkEventMotion
instance.Generated when the pointer moves.
See moreDeclaration
Swift
public struct EventMotionRef : EventMotionProtocol
-
The
EventOwnerChangeRef
type acts as a lightweight Swift reference to an underlyingGdkEventOwnerChange
instance. It exposes methods that can operate on this data type throughEventOwnerChangeProtocol
conformance. UseEventOwnerChangeRef
only as anunowned
reference to an existingGdkEventOwnerChange
instance.Generated when the owner of a selection changes. On X11, this information is only available if the X server supports the XFIXES extension.
See moreDeclaration
Swift
public struct EventOwnerChangeRef : EventOwnerChangeProtocol
-
The
EventPadAxisRef
type acts as a lightweight Swift reference to an underlyingGdkEventPadAxis
instance. It exposes methods that can operate on this data type throughEventPadAxisProtocol
conformance. UseEventPadAxisRef
only as anunowned
reference to an existingGdkEventPadAxis
instance.Generated during
See moreGDK_SOURCE_TABLET_PAD
interaction with tactile sensors.Declaration
Swift
public struct EventPadAxisRef : EventPadAxisProtocol
-
The
EventPadButtonRef
type acts as a lightweight Swift reference to an underlyingGdkEventPadButton
instance. It exposes methods that can operate on this data type throughEventPadButtonProtocol
conformance. UseEventPadButtonRef
only as anunowned
reference to an existingGdkEventPadButton
instance.Generated during
See moreGDK_SOURCE_TABLET_PAD
button presses and releases.Declaration
Swift
public struct EventPadButtonRef : EventPadButtonProtocol
-
The
EventPadGroupModeRef
type acts as a lightweight Swift reference to an underlyingGdkEventPadGroupMode
instance. It exposes methods that can operate on this data type throughEventPadGroupModeProtocol
conformance. UseEventPadGroupModeRef
only as anunowned
reference to an existingGdkEventPadGroupMode
instance.Generated during
See moreGDK_SOURCE_TABLET_PAD
mode switches in a group.Declaration
Swift
public struct EventPadGroupModeRef : EventPadGroupModeProtocol
-
The
EventPropertyRef
type acts as a lightweight Swift reference to an underlyingGdkEventProperty
instance. It exposes methods that can operate on this data type throughEventPropertyProtocol
conformance. UseEventPropertyRef
only as anunowned
reference to an existingGdkEventProperty
instance.Describes a property change on a window.
See moreDeclaration
Swift
public struct EventPropertyRef : EventPropertyProtocol
-
The
EventProximityRef
type acts as a lightweight Swift reference to an underlyingGdkEventProximity
instance. It exposes methods that can operate on this data type throughEventProximityProtocol
conformance. UseEventProximityRef
only as anunowned
reference to an existingGdkEventProximity
instance.Proximity events are generated when using GDK’s wrapper for the XInput extension. The XInput extension is an add-on for standard X that allows you to use nonstandard devices such as graphics tablets. A proximity event indicates that the stylus has moved in or out of contact with the tablet, or perhaps that the user’s finger has moved in or out of contact with a touch screen.
This event type will be used pretty rarely. It only is important for XInput aware programs that are drawing their own cursor.
See moreDeclaration
Swift
public struct EventProximityRef : EventProximityProtocol
-
The
EventScrollRef
type acts as a lightweight Swift reference to an underlyingGdkEventScroll
instance. It exposes methods that can operate on this data type throughEventScrollProtocol
conformance. UseEventScrollRef
only as anunowned
reference to an existingGdkEventScroll
instance.Generated from button presses for the buttons 4 to 7. Wheel mice are usually configured to generate button press events for buttons 4 and 5 when the wheel is turned.
Some GDK backends can also generate “smooth” scroll events, which can be recognized by the
See moreGDK_SCROLL_SMOOTH
scroll direction. For these, the scroll deltas can be obtained withgdk_event_get_scroll_deltas()
.Declaration
Swift
public struct EventScrollRef : EventScrollProtocol
-
The
EventSelectionRef
type acts as a lightweight Swift reference to an underlyingGdkEventSelection
instance. It exposes methods that can operate on this data type throughEventSelectionProtocol
conformance. UseEventSelectionRef
only as anunowned
reference to an existingGdkEventSelection
instance.Generated when a selection is requested or ownership of a selection is taken over by another client application.
See moreDeclaration
Swift
public struct EventSelectionRef : EventSelectionProtocol
-
The
See moreEventSequenceRef
type acts as a lightweight Swift reference to an underlyingGdkEventSequence
instance. It exposes methods that can operate on this data type throughEventSequenceProtocol
conformance. UseEventSequenceRef
only as anunowned
reference to an existingGdkEventSequence
instance.Declaration
Swift
public struct EventSequenceRef : EventSequenceProtocol
-
The
EventSettingRef
type acts as a lightweight Swift reference to an underlyingGdkEventSetting
instance. It exposes methods that can operate on this data type throughEventSettingProtocol
conformance. UseEventSettingRef
only as anunowned
reference to an existingGdkEventSetting
instance.Generated when a setting is modified.
See moreDeclaration
Swift
public struct EventSettingRef : EventSettingProtocol
-
The
EventTouchRef
type acts as a lightweight Swift reference to an underlyingGdkEventTouch
instance. It exposes methods that can operate on this data type throughEventTouchProtocol
conformance. UseEventTouchRef
only as anunowned
reference to an existingGdkEventTouch
instance.Used for touch events.
type
field will be one ofGDK_TOUCH_BEGIN
,GDK_TOUCH_UPDATE
,GDK_TOUCH_END
orGDK_TOUCH_CANCEL
.Touch events are grouped into sequences by means of the
See moresequence
field, which can also be obtained withgdk_event_get_event_sequence()
. Each sequence begins with aGDK_TOUCH_BEGIN
event, followed by any number ofGDK_TOUCH_UPDATE
events, and ends with aGDK_TOUCH_END
(orGDK_TOUCH_CANCEL
) event. With multitouch devices, there may be several active sequences at the same time.Declaration
Swift
public struct EventTouchRef : EventTouchProtocol
-
The
EventTouchpadPinchRef
type acts as a lightweight Swift reference to an underlyingGdkEventTouchpadPinch
instance. It exposes methods that can operate on this data type throughEventTouchpadPinchProtocol
conformance. UseEventTouchpadPinchRef
only as anunowned
reference to an existingGdkEventTouchpadPinch
instance.Generated during touchpad swipe gestures.
See moreDeclaration
Swift
public struct EventTouchpadPinchRef : EventTouchpadPinchProtocol
-
The
EventTouchpadSwipeRef
type acts as a lightweight Swift reference to an underlyingGdkEventTouchpadSwipe
instance. It exposes methods that can operate on this data type throughEventTouchpadSwipeProtocol
conformance. UseEventTouchpadSwipeRef
only as anunowned
reference to an existingGdkEventTouchpadSwipe
instance.Generated during touchpad swipe gestures.
See moreDeclaration
Swift
public struct EventTouchpadSwipeRef : EventTouchpadSwipeProtocol
-
The
EventVisibilityRef
type acts as a lightweight Swift reference to an underlyingGdkEventVisibility
instance. It exposes methods that can operate on this data type throughEventVisibilityProtocol
conformance. UseEventVisibilityRef
only as anunowned
reference to an existingGdkEventVisibility
instance.Generated when the window visibility status has changed.
See moreDeclaration
Swift
public struct EventVisibilityRef : EventVisibilityProtocol
-
The
EventWindowStateRef
type acts as a lightweight Swift reference to an underlyingGdkEventWindowState
instance. It exposes methods that can operate on this data type throughEventWindowStateProtocol
conformance. UseEventWindowStateRef
only as anunowned
reference to an existingGdkEventWindowState
instance.Generated when the state of a toplevel window changes.
See moreDeclaration
Swift
public struct EventWindowStateRef : EventWindowStateProtocol
-
The
See moreFrameClockClassRef
type acts as a lightweight Swift reference to an underlyingGdkFrameClockClass
instance. It exposes methods that can operate on this data type throughFrameClockClassProtocol
conformance. UseFrameClockClassRef
only as anunowned
reference to an existingGdkFrameClockClass
instance.Declaration
Swift
public struct FrameClockClassRef : FrameClockClassProtocol
-
The
FrameTimingsRef
type acts as a lightweight Swift reference to an underlyingGdkFrameTimings
instance. It exposes methods that can operate on this data type throughFrameTimingsProtocol
conformance. UseFrameTimingsRef
only as anunowned
reference to an existingGdkFrameTimings
instance.A
See moreGdkFrameTimings
object holds timing information for a single frame of the application’s displays. To retrieveGdkFrameTimings
objects, usegdk_frame_clock_get_timings()
orgdk_frame_clock_get_current_timings()
. The information inGdkFrameTimings
is 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
GeometryRef
type acts as a lightweight Swift reference to an underlyingGdkGeometry
instance. It exposes methods that can operate on this data type throughGeometryProtocol
conformance. UseGeometryRef
only as anunowned
reference to an existingGdkGeometry
instance.The
GdkGeometry
struct gives the window manager information about a window’s geometry constraints. Normally you would set these on the GTK+ level usinggtk_window_set_geometry_hints()
.GtkWindow
then sets the hints on theGdkWindow
it creates.gdk_window_set_geometry_hints()
expects the hints to be fully valid already and simply passes them to the window manager; in contrast,gtk_window_set_geometry_hints()
performs some interpretation. For example,GtkWindow
will apply the hints to the geometry widget instead of the toplevel window, if you set a geometry widget. Also, themin_width
/min_height
/max_width
/max_height
fields may be set to -1, andGtkWindow
will substitute the size request of the window or geometry widget. If the minimum size hint is not provided,GtkWindow
will use its requisition as the minimum size. If the minimum size is provided and a geometry widget is set,GtkWindow
will take the minimum size as the minimum size of the geometry widget rather than the entire window. The base size is treated similarly.The canonical use-case for
gtk_window_set_geometry_hints()
is to get a terminal widget to resize properly. Here, the terminal text area should be the geometry widget;GtkWindow
will then automatically set the base size to the size of other widgets in the terminal window, such as the menubar and scrollbar. Then, thewidth_inc
andheight_inc
fields should be set to the size of one character in the terminal. Finally, the base size should be set to the size of one character. The net effect is that the minimum size of the terminal will have a 1x1 character terminal area, and only terminal sizes on the “character grid” will be allowed.Here’s an example of how the terminal example would be implemented, assuming a terminal area widget called “terminal” and a toplevel window “toplevel”:
(C Language Example):
GdkGeometry hints; hints.base_width = terminal->char_width; hints.base_height = terminal->char_height; hints.min_width = terminal->char_width; hints.min_height = terminal->char_height; hints.width_inc = terminal->char_width; hints.height_inc = terminal->char_height; gtk_window_set_geometry_hints (GTK_WINDOW (toplevel), GTK_WIDGET (terminal), &hints, GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
The other useful fields are the
See moremin_aspect
andmax_aspect
fields; these contain a width/height ratio as a floating point number. If a geometry widget is set, the aspect applies to the geometry widget rather than the entire window. The most common use of these hints is probably to setmin_aspect
andmax_aspect
to the same value, thus forcing the window to keep a constant aspect ratio.Declaration
Swift
public struct GeometryRef : GeometryProtocol
-
The
GLContextRef
type acts as a lightweight Swift reference to an underlyingGdkGLContext
instance. It exposes methods that can operate on this data type throughGLContextProtocol
conformance. UseGLContextRef
only as anunowned
reference to an existingGdkGLContext
instance.GdkGLContext
is an object representing the platform-specific OpenGL drawing context.GdkGLContexts
are created for aGdkWindow
usinggdk_window_create_gl_context()
, and the context will match theGdkVisual
of the window.A
GdkGLContext
is not tied to any particular normal framebuffer. For instance, it cannot draw to theGdkWindow
back buffer. The GDK repaint system is in full control of the painting to that. Instead, you can create render buffers or textures and usegdk_cairo_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
GdkGLContext
is platform-specific, context creation can fail, returningnil
context.A
GdkGLContext
has 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
GdkGLContext
instance you need aGdkWindow
, which you typically get during the realize call of a widget.A
GdkGLContext
is not realized until eithergdk_gl_context_make_current()
, or until it is realized usinggdk_gl_context_realize()
. 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 callinggdk_window_create_gl_context()
by callinggdk_gl_context_realize()
. If the realization fails you have the option to change the settings of theGdkGLContext
and try again.Using a GdkGLContext
You will need to make the
GdkGLContext
the 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:(C Language Example):
gdk_gl_context_make_current (context);
You can now perform your drawing using OpenGL commands.
You can check which
See moreGdkGLContext
is the current one by usinggdk_gl_context_get_current()
; you can also unset anyGdkGLContext
that is currently set by callinggdk_gl_context_clear_current()
.Declaration
Swift
public struct GLContextRef : GLContextProtocol, GWeakCapturing
-
The
KeymapRef
type acts as a lightweight Swift reference to an underlyingGdkKeymap
instance. It exposes methods that can operate on this data type throughKeymapProtocol
conformance. UseKeymapRef
only as anunowned
reference to an existingGdkKeymap
instance.A
See moreGdkKeymap
defines the translation from keyboard state (including a hardware key, a modifier mask, and active keyboard group) to a keyval. This translation has two phases. The first phase is to determine the effective keyboard group and level for the keyboard state; the second phase is to look up the keycode/group/level triplet in the keymap and see what keyval it corresponds to.Declaration
Swift
public struct KeymapRef : KeymapProtocol, GWeakCapturing
-
The
KeymapKeyRef
type acts as a lightweight Swift reference to an underlyingGdkKeymapKey
instance. It exposes methods that can operate on this data type throughKeymapKeyProtocol
conformance. UseKeymapKeyRef
only as anunowned
reference to an existingGdkKeymapKey
instance.A
See moreGdkKeymapKey
is a hardware key that can be mapped to a keyval.Declaration
Swift
public struct KeymapKeyRef : KeymapKeyProtocol
-
The
See moreMonitorClassRef
type acts as a lightweight Swift reference to an underlyingGdkMonitorClass
instance. It exposes methods that can operate on this data type throughMonitorClassProtocol
conformance. UseMonitorClassRef
only as anunowned
reference to an existingGdkMonitorClass
instance.Declaration
Swift
public struct MonitorClassRef : MonitorClassProtocol
-
The
MonitorRef
type acts as a lightweight Swift reference to an underlyingGdkMonitor
instance. It exposes methods that can operate on this data type throughMonitorProtocol
conformance. UseMonitorRef
only as anunowned
reference to an existingGdkMonitor
instance.GdkMonitor objects represent the individual outputs that are associated with a
GdkDisplay
. GdkDisplay has APIs to enumerate monitors withgdk_display_get_n_monitors()
andgdk_display_get_monitor()
, and to find particular monitors withgdk_display_get_primary_monitor()
orgdk_display_get_monitor_at_window()
.GdkMonitor was introduced in GTK+ 3.22 and supersedes earlier APIs in GdkScreen to obtain monitor-related information.
See moreDeclaration
Swift
public struct MonitorRef : MonitorProtocol, GWeakCapturing
-
The
ScreenRef
type acts as a lightweight Swift reference to an underlyingGdkScreen
instance. It exposes methods that can operate on this data type throughScreenProtocol
conformance. UseScreenRef
only as anunowned
reference to an existingGdkScreen
instance.GdkScreen
objects are the GDK representation of the screen on which windows can be displayed and on which the pointer moves. X originally identified screens with physical screens, but nowadays it is more common to have a singleGdkScreen
which combines several physical monitors (seegdk_screen_get_n_monitors()
).GdkScreen is used throughout GDK and GTK+ to specify which screen the top level windows are to be displayed on. it is also used to query the screen specification and default settings such as the default visual (
See moregdk_screen_get_system_visual()
), the dimensions of the physical monitors (gdk_screen_get_monitor_geometry()
), etc.Declaration
Swift
public struct ScreenRef : ScreenProtocol, GWeakCapturing
-
The
PointRef
type acts as a lightweight Swift reference to an underlyingGdkPoint
instance. It exposes methods that can operate on this data type throughPointProtocol
conformance. UsePointRef
only as anunowned
reference to an existingGdkPoint
instance.Defines the x and y coordinates of a point.
See moreDeclaration
Swift
public struct PointRef : PointProtocol
-
The
RGBARef
type acts as a lightweight Swift reference to an underlyingGdkRGBA
instance. It exposes methods that can operate on this data type throughRGBAProtocol
conformance. UseRGBARef
only as anunowned
reference to an existingGdkRGBA
instance.A
See moreGdkRGBA
is used to represent a (possibly translucent) color, in a way that is compatible with cairo’s notion of color.Declaration
Swift
public struct RGBARef : RGBAProtocol
-
The
RectangleRef
type acts as a lightweight Swift reference to an underlyingGdkRectangle
instance. It exposes methods that can operate on this data type throughRectangleProtocol
conformance. UseRectangleRef
only as anunowned
reference to an existingGdkRectangle
instance.Defines the position and size of a rectangle. It is identical to
See morecairo_rectangle_int_t
.Declaration
Swift
public struct RectangleRef : RectangleProtocol
-
The
TimeCoordRef
type acts as a lightweight Swift reference to an underlyingGdkTimeCoord
instance. It exposes methods that can operate on this data type throughTimeCoordProtocol
conformance. UseTimeCoordRef
only as anunowned
reference to an existingGdkTimeCoord
instance.A
See moreGdkTimeCoord
stores a single event in a motion history.Declaration
Swift
public struct TimeCoordRef : TimeCoordProtocol
-
The
SeatRef
type acts as a lightweight Swift reference to an underlyingGdkSeat
instance. It exposes methods that can operate on this data type throughSeatProtocol
conformance. UseSeatRef
only as anunowned
reference to an existingGdkSeat
instance.The
See moreGdkSeat
object represents a collection of input devices that belong to a user.Declaration
Swift
public struct SeatRef : SeatProtocol, GWeakCapturing
-
The
VisualRef
type acts as a lightweight Swift reference to an underlyingGdkVisual
instance. It exposes methods that can operate on this data type throughVisualProtocol
conformance. UseVisualRef
only as anunowned
reference to an existingGdkVisual
instance.A
See moreGdkVisual
contains information about a particular visual.Declaration
Swift
public struct VisualRef : VisualProtocol, GWeakCapturing
-
The
See moreWindowRef
type acts as a lightweight Swift reference to an underlyingGdkWindow
instance. It exposes methods that can operate on this data type throughWindowProtocol
conformance. UseWindowRef
only as anunowned
reference to an existingGdkWindow
instance.Declaration
Swift
public struct WindowRef : WindowProtocol, GWeakCapturing
-
The
WindowAttrRef
type acts as a lightweight Swift reference to an underlyingGdkWindowAttr
instance. It exposes methods that can operate on this data type throughWindowAttrProtocol
conformance. UseWindowAttrRef
only as anunowned
reference to an existingGdkWindowAttr
instance.Attributes to use for a newly-created window.
See moreDeclaration
Swift
public struct WindowAttrRef : WindowAttrProtocol
-
The
See moreWindowClassRef
type acts as a lightweight Swift reference to an underlyingGdkWindowClass
instance. It exposes methods that can operate on this data type throughWindowClassProtocol
conformance. UseWindowClassRef
only as anunowned
reference to an existingGdkWindowClass
instance.Declaration
Swift
public struct WindowClassRef : WindowClassProtocol
-
The
See moreWindowRedirectRef
type acts as a lightweight Swift reference to an underlyingGdkWindowRedirect
instance. It exposes methods that can operate on this data type throughWindowRedirectProtocol
conformance. UseWindowRedirectRef
only as anunowned
reference to an existingGdkWindowRedirect
instance.Declaration
Swift
public struct WindowRedirectRef : WindowRedirectProtocol
-
Positioning hints for aligning a window relative to a rectangle.
These hints determine how the window should be positioned in the case that the window would fall off-screen if placed in its ideal position.
For example,
GDK_ANCHOR_FLIP_X
will replaceGDK_GRAVITY_NORTH_WEST
withGDK_GRAVITY_NORTH_EAST
and vice versa if the window extends beyond the left or right edges of the monitor.If
GDK_ANCHOR_SLIDE_X
is set, the window can be shifted horizontally to fit on-screen. IfGDK_ANCHOR_RESIZE_X
is set, the window 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 moreGdkDragContext
to indicate what the destination should do with the dropped data.Declaration
Swift
public struct DragAction : OptionSet
-
A set of bit-flags to indicate which events a window is to receive. Most of these masks map onto one or more of the
GdkEventType
event types above.See the input handling overview for details of event masks and event propagation.
GDK_POINTER_MOTION_HINT_MASK
is deprecated. It is a special mask to reduce the number ofGDK_MOTION_NOTIFY
events received. When usingGDK_POINTER_MOTION_HINT_MASK
, fewerGDK_MOTION_NOTIFY
events will be sent, some of which are marked as a hint (the is_hint member istrue
). To receive more motion events after a motion hint event, the application needs to asks for more, by callinggdk_event_request_motions()
.Since GTK 3.8, motion events are already compressed by default, independent of this mechanism. This compression can be disabled with
gdk_window_set_event_compression()
. See the documentation of that function for details.If
See moreGDK_TOUCH_MASK
is enabled, the window will receive touch events from touch-enabled devices. Those will come as sequences ofGdkEventTouch
with typeGDK_TOUCH_UPDATE
, enclosed by two events with typeGDK_TOUCH_BEGIN
andGDK_TOUCH_END
(orGDK_TOUCH_CANCEL
).gdk_event_get_event_sequence()
returns the event sequence for these events, so different sequences may be distinguished.Declaration
Swift
public struct EventMask : OptionSet
-
See moreGdkFrameClockPhase
is used to represent the different paint clock phases that can be requested. The elements of the enumeration correspond to the signals ofGdkFrameClock
.Declaration
Swift
public struct FrameClockPhase : OptionSet
-
A set of bit-flags to indicate the state of modifier keys and mouse buttons in various event types. Typical modifier keys are Shift, Control, Meta, Super, Hyper, Alt, Compose, Apple, CapsLock or ShiftLock.
Like the X Window System, GDK supports 8 modifier keys and 5 mouse buttons.
Since 2.10, GDK recognizes which of the Meta, Super or Hyper keys are mapped to Mod2 - Mod5, and indicates this by setting
GDK_SUPER_MASK
,GDK_HYPER_MASK
orGDK_META_MASK
in the state field of key events.Note that GDK may add internal values to events which include reserved values such as
GDK_MODIFIER_RESERVED_13_MASK
. Your code should preserve and ignore them. You can useGDK_MODIFIER_MASK
to remove all reserved values.Also note that the GDK X backend interprets button press events for button 4-7 as scroll events, so
See moreGDK_BUTTON4_MASK
andGDK_BUTTON5_MASK
will never be set.Declaration
Swift
public struct ModifierType : OptionSet
-
Flags describing the seat capabilities.
See moreDeclaration
Swift
public struct SeatCapabilities : OptionSet
-
These are hints originally defined by the Motif toolkit. The window manager can use them when determining how to decorate the window. The hint must be set before mapping the window.
See moreDeclaration
Swift
public struct WMDecoration : OptionSet
-
These are hints originally defined by the Motif toolkit. The window manager can use them when determining the functions to offer for the window. The hint must be set before mapping the window.
See moreDeclaration
Swift
public struct WMFunction : OptionSet
-
Used to indicate which fields in the
See moreGdkWindowAttr
struct should be honored. For example, if you filled in the “cursor” and “x” fields ofGdkWindowAttr
, pass “GDK_WA_X
|GDK_WA_CURSOR
” togdk_window_new()
. Fields inGdkWindowAttr
not covered by a bit in this enum are required; for example, thewidth
/height
,wclass
, andwindow_type
fields are required, they have no corresponding flag inGdkWindowAttributesType
.Declaration
Swift
public struct WindowAttributesType : OptionSet
-
Used to indicate which fields of a
See moreGdkGeometry
struct should be paid attention to. Also, the presence/absence ofGDK_HINT_POS
,GDK_HINT_USER_POS
, andGDK_HINT_USER_SIZE
is significant, though they don’t directly refer toGdkGeometry
fields.GDK_HINT_USER_POS
will be set automatically byGtkWindow
if you callgtk_window_move()
.GDK_HINT_USER_POS
andGDK_HINT_USER_SIZE
should be set if the user specified a size/position using a –geometry command-line argument;gtk_window_parse_geometry()
automatically sets these flags.Declaration
Swift
public struct WindowHints : OptionSet
-
Specifies the state of a toplevel window.
See moreDeclaration
Swift
public struct WindowState : OptionSet
-
The
EventRef
type acts as a lightweight Swift reference to an underlyingGdkEvent
instance. It exposes methods that can operate on this data type throughEventProtocol
conformance. UseEventRef
only as anunowned
reference to an existingGdkEvent
instance.A
GdkEvent
contains a union of all of the event types, and allows access to the data fields in a number of ways.The event type is always the first field in all of the event types, and can always be accessed with the following code, no matter what type of event it is: (C Language Example):
GdkEvent *event; GdkEventType type; type = event->type;
To access other fields of the event, the pointer to the event can be cast to the appropriate event type, or the union member name can be used. For example if the event type is
GDK_BUTTON_PRESS
then the x coordinate of the button press can be accessed with: (C Language Example):GdkEvent *event; gdouble x; x = ((GdkEventButton*)event)->x;
or: (C Language Example):
See moreGdkEvent *event; gdouble x; x = event->button.x;
Declaration
Swift
public struct EventRef : EventProtocol