Expand description
§Rust GDK 3 bindings
Project site is here.
Rust bindings and wrappers for GDK 3, part of gtk3-rs.
GDK 3.22 is the lowest supported version for the underlying library.
§Minimum supported Rust version
Currently, the minimum supported Rust version is 1.70.0.
§Documentation
§Using
We recommend using crates from crates.io, as demonstrated here.
If you want to track the bleeding edge, use the git dependency instead:
[dependencies]
gdk = { git = "https://github.com/gtk-rs/gtk3-rs.git", package = "gdk" }Avoid mixing versioned and git crates like this:
# This will not compile
[dependencies]
gdk = "0.13"
gdk = { git = "https://github.com/gtk-rs/gtk3-rs.git", package = "gdk" }§See Also
§License
gdk is available under the MIT License, please refer to it.
Re-exports§
Modules§
Structs§
- Anchor
Hints - Positioning hints for aligning a window relative to a rectangle.
- AppLaunch
Context - GdkAppLaunchContext is an implementation of
gio::AppLaunchContextthat handles launching an application in a graphical context. It provides startup notification and allows to launch applications on a specific screen or workspace. - Atom
- An opaque type representing a string as an index into a table of strings on the X server.
- Axis
Flags - Flags describing the current capabilities of a device/tool.
- Color
- Cursor
- A
Cursorrepresents a cursor. Its contents are private. - Device
- The
Deviceobject represents a single input device, such as a keyboard, a mouse, a touchpad, etc. - Device
Manager - 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.
- Device
Pad DevicePadis an interface implemented by devices of typeInputSource::TabletPad, it allows querying the features provided by the pad device.- Device
Tool - Properties
- Display
Displayobjects purpose are two fold:- Display
Manager - The purpose of the
DisplayManagersingleton object is to offer notification when displays appear or disappear or the default display changes. - Drag
Action - Used in
DragContextto indicate what the destination should do with the dropped data. - Drag
Context - Signals
- Drawing
Context DrawingContextis an object that represents the current drawing state of aWindow.- Event
- A generic GDK event.
- Event
Button - Used for button press and button release events. The
typefield will be one ofEventType::ButtonPress, [EventType::_2buttonPress][crate::EventType::_2buttonPress], [EventType::_3buttonPress][crate::EventType::_3buttonPress] orEventType::ButtonRelease, - Event
Configure - Generated when a window size or position has changed.
- Event
Crossing - Generated when the pointer enters or leaves a window.
- EventDND
- Generated during DND operations.
- Event
Expose - Generated when all or part of a window becomes visible and needs to be redrawn.
- Event
Focus - Describes a change of keyboard focus.
- Event
Grab Broken - 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
EventGrabBrokenevents. - Event
Key - Describes a key press or key release event.
- Event
Mask - 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
EventTypeevent types above. - Event
Motion - Generated when the pointer moves.
- Event
Owner Change - Generated when the owner of a selection changes. On X11, this information is only available if the X server supports the XFIXES extension.
- Event
PadAxis - Generated during
InputSource::TabletPadinteraction with tactile sensors. - Event
PadButton - Generated during
InputSource::TabletPadbutton presses and releases. - Event
PadGroup Mode - Generated during
InputSource::TabletPadmode switches in a group. - Event
Property - Describes a property change on a window.
- Event
Proximity - 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.
- Event
Scroll - 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.
- Event
Selection - Generated when a selection is requested or ownership of a selection is taken over by another client application.
- Event
Sequence - Event
Setting - Generated when a setting is modified.
- Event
Touch - Used for touch events.
typefield will be one ofEventType::TouchBegin,EventType::TouchUpdate,EventType::TouchEndorEventType::TouchCancel. - Event
Touchpad Pinch - Generated during touchpad swipe gestures.
- Event
Touchpad Swipe - Generated during touchpad swipe gestures.
- Event
Visibility - Event
Window State - Generated when the state of a toplevel window changes.
- Frame
Clock - A
FrameClocktells 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. - Frame
Clock Phase FrameClockPhaseis used to represent the different paint clock phases that can be requested. The elements of the enumeration correspond to the signals ofFrameClock.- Frame
Timings - A
FrameTimingsobject holds timing information for a single frame of the application’s displays. To retrieveFrameTimingsobjects, useFrameClock::timings()orFrameClock::current_timings(). The information inFrameTimingsis 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. - GLContext
GLContextis an object representing the platform-specific OpenGL drawing context.- GRange
- Geometry
- The
Geometrystruct 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().GtkWindowthen sets the hints on theWindowit creates. - Keymap
- A
Keymapdefines 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. - Keymap
Key - A
KeymapKeyis a hardware key that can be mapped to a keyval. - Modifier
Type - 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.
- Monitor
- GdkMonitor objects represent the individual outputs that are
associated with a
Display. GdkDisplay has APIs to enumerate monitors withDisplay::n_monitors()andDisplay::monitor(), and to find particular monitors withDisplay::primary_monitor()orDisplay::monitor_at_window(). - RGBA
- A
RGBAis used to represent a (possibly translucent) color, in a way that is compatible with cairo’s notion of color. - Rectangle
- Defines the position and size of a rectangle. It is identical to
cairo_rectangle_int_t. - Screen
Screenobjects 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 singleScreenwhich combines several physical monitors (seegdk_screen_get_n_monitors()).- Seat
- The
Seatobject represents a collection of input devices that belong to a user. - Seat
Capabilities - Flags describing the seat capabilities.
- Time
Coord - A
TimeCoordstores a single event in a motion history. - Visual
- A
Visualcontains information about a particular visual. - WMDecoration
- 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.
- WMFunction
- 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.
- Window
- This is an Abstract Base Class, you cannot instantiate it.
- Window
Attr - Window
Hints - Used to indicate which fields of a
Geometrystruct should be paid attention to. Also, the presence/absence ofPOS,USER_POS, andUSER_SIZEis significant, though they don’t directly refer toGeometryfields.USER_POSwill be set automatically byGtkWindowif you callgtk_window_move().USER_POSandUSER_SIZEshould be set if the user specified a size/position using a –geometry command-line argument;gtk_window_parse_geometry()automatically sets these flags. - Window
State - Specifies the state of a toplevel window.
Enums§
- AxisUse
- An enumeration describing the way in which a device axis (valuator) maps onto the predefined valuator types that GTK+ understands.
- Backend
- Byte
Order - A set of values describing the possible byte-orders for storing pixel values in memory.
- Change
Data - Crossing
Mode - Specifies the crossing mode for
EventCrossing. - Cursor
Type - Predefined cursors.
- Device
PadFeature - A pad feature.
- Device
Tool Type - Indicates the specific type of tool being used being a tablet. Such as an airbrush, pencil, etc.
- Device
Type - Indicates the device type. See [above][GdkDeviceManager.description] for more information about the meaning of these device types.
- Drag
Cancel Reason - Used in
DragContextto the reason of a cancelled DND operation. - Drag
Protocol - Used in
DragContextto indicate the protocol according to which DND is done. - Event
Type - Specifies the type of the event.
- Fullscreen
Mode - Indicates which monitor (in a multi-head setup) a window should span over when in fullscreen mode.
- GLError
- Error enumeration for
GLContext. - Grab
Ownership - Defines how device grabs interact with other devices.
- Grab
Status - Returned by
gdk_device_grab(),gdk_pointer_grab()andgdk_keyboard_grab()to indicate success or the reason for the failure of the grab attempt. - Gravity
- Defines the reference point of a window and the meaning of coordinates
passed to
gtk_window_move(). Seegtk_window_move()and the “implementation notes” section of the Extended Window Manager Hints specification for more details. - Input
Mode - An enumeration that describes the mode of an input device.
- Input
Source - An enumeration describing the type of an input device in general terms.
- Modifier
Intent - This enum is used with
Keymap::modifier_mask()in order to determine what modifiers the currently used windowing system backend uses for particular purposes. For example, on X11/Windows, the Control key is used for invoking menu shortcuts (accelerators), whereas on Apple computers it’s the Command key (which correspond toModifierType::CONTROL_MASKandModifierType::MOD2_MASK, respectively). - Notify
Type - Specifies the kind of crossing for
EventCrossing. - Owner
Change - Specifies why a selection ownership was changed.
- Prop
Mode - Describes how existing data is combined with new data when
using
gdk_property_change(). - Property
State - Specifies the type of a property change for a
EventProperty. - Scroll
Direction - Specifies the direction for
EventScroll. - Setting
Action - Specifies the kind of modification applied to a setting in a
EventSetting. - Subpixel
Layout - This enumeration describes how the red, green and blue components of physical pixels on an output device are laid out.
- Visibility
State - Specifies the visiblity status of a window for a
EventVisibility. - Visual
Type - A set of values that describe the manner in which the pixel values for a visual are converted into RGB values for display.
- Window
Edge - Determines a window edge or corner.
- Window
Type - Describes the kind of window.
- Window
Type Hint - These are hints for the window manager that indicate what type of function the window has. The window manager can use this when determining decoration and behaviour of the window. The hint must be set before mapping the window.
- Window
Window Class InputOutputwindows are the standard kind of window you might expect. Such windows receive events and are also displayed on screen.InputOnlywindows are invisible; they are usually placed above other windows in order to trap or filter the events. You can’t draw onInputOnlywindows.
Constants§
- ATOM_
NONE - BUTTON_
MIDDLE - The middle button. The middle button.
- BUTTON_
PRIMARY - The primary button. This is typically the left mouse button, or the right button in a left-handed setup. The primary button. This is typically the left mouse button, or the right button in a left-handed setup.
- BUTTON_
SECONDARY - The secondary button. This is typically the right mouse button, or the left button in a left-handed setup. The secondary button. This is typically the right mouse button, or the left button in a left-handed setup.
- EVENT_
PROPAGATE - Use this macro as the return value for continuing the propagation of an event handler.
- EVENT_
STOP - Use this macro as the return value for stopping the propagation of an event handler.
- SELECTION_
CLIPBOARD - SELECTION_
PRIMARY - SELECTION_
SECONDARY - SELECTION_
TYPE_ ATOM - SELECTION_
TYPE_ BITMAP - SELECTION_
TYPE_ COLORMAP - SELECTION_
TYPE_ DRAWABLE - SELECTION_
TYPE_ INTEGER - SELECTION_
TYPE_ PIXMAP - SELECTION_
TYPE_ STRING - SELECTION_
TYPE_ WINDOW - TARGET_
BITMAP - TARGET_
COLORMAP - TARGET_
DRAWABLE - TARGET_
PIXMAP - TARGET_
STRING
Traits§
- From
Event - A helper trait implemented by all event subtypes.
Functions§
- beep
- Emits a short beep on the default display.
- display_
arg_ name - Gets the display name specified in the command line arguments passed
to
gdk_init()orgdk_parse_args(), if any. - error_
trap_ pop - Removes an error trap pushed with
error_trap_push(). May block until an error has been definitively received or not received from the X server.error_trap_pop_ignored()is preferred if you don’t need to know whether an error occurred, because it never has to block. If you don’t need the return value oferror_trap_pop(), useerror_trap_pop_ignored(). - error_
trap_ pop_ ignored - Removes an error trap pushed with
error_trap_push(), but without bothering to wait and see whether an error occurred. If an error arrives later asynchronously that was triggered while the trap was pushed, that error will be ignored. - error_
trap_ push - This function allows X errors to be trapped instead of the normal
behavior of exiting the application. It should only be used if it
is not possible to avoid the X error in any other way. Errors are
ignored on all
Displaycurrently known to theDisplayManager. If you don’t care which error happens and just want to ignore everything, pop witherror_trap_pop_ignored(). If you need the error code, useerror_trap_pop()which may have to block and wait for the error to arrive from the X server. - events_
get_ angle - If both events contain X/Y information, this function will return
trueand return inanglethe relative angle fromevent1toevent2. The rotation direction for positive angles is from the positive X axis towards the positive Y axis. - events_
get_ center - If both events contain X/Y information, the center of both coordinates
will be returned in
xandy. - events_
get_ distance - If both events have X/Y information, the distance between both coordinates
(as in a straight line going from
event1toevent2) will be returned. - events_
pending - Checks if any events are ready to be processed for any display.
- flush
- Flushes the output buffers of all display connections and waits until all requests have been processed. This is rarely needed by applications.
- init
- notify_
startup_ complete - Indicates to the GUI environment that the application has finished loading. If the applications opens windows, this function is normally called after opening the application’s initial set of windows.
- notify_
startup_ complete_ with_ id - Indicates to the GUI environment that the application has finished loading, using a given identifier.
- pango_
context_ get - Creates a
pango::Contextfor the default GDK screen. - pango_
context_ get_ for_ display - Creates a
pango::Contextfordisplay. - pango_
context_ get_ for_ screen - Creates a
pango::Contextforscreen. - pango_
layout_ get_ clip_ region - pango_
layout_ line_ get_ clip_ region - Obtains a clip region which contains the areas where the given
ranges of text would be drawn.
x_originandy_originare the top left position of the layout.index_rangesshould contain ranges of bytes in the layout’s text. The clip region will include space to the left or right of the line (to the layout bounding box) if you have indexes above or below the indexes contained inside the line. This is to draw the selection all the way to the side of the layout. However, the clip region is in line coordinates, not layout coordinates. - pixbuf_
get_ from_ surface - Transfers image data from a
cairo::Surfaceand converts it to an RGB(A) representation inside agdk_pixbuf::Pixbuf. This allows you to efficiently read individual pixels from cairo surfaces. ForGdkWindows, usegdk_pixbuf_get_from_window()instead. - program_
class - Gets the program class. Unless the program class has explicitly
been set with
set_program_class()or with the--classcommandline option, the default value is the program name (determined withg_get_prgname()) with the first character converted to uppercase. - property_
change - property_
delete - Deletes a property from a window.
- property_
get - Retrieves a portion of the contents of a property. If the
property does not exist, then the function returns
false, andGDK_NONEwill be stored inactual_property_type. - selection_
convert - Retrieves the contents of a selection in a given form.
- selection_
owner_ get - Determines the owner of the given selection.
- selection_
owner_ get_ for_ display - Determine the owner of the given selection.
- selection_
owner_ set - Sets the owner of the given selection.
- selection_
owner_ set_ for_ display - Sets the
Windowowneras the current owner of the selectionselection. - selection_
send_ notify - Sends a response to SelectionRequest event.
- selection_
send_ notify_ for_ display - Send a response to SelectionRequest event.
- set_
allowed_ backends - Sets a list of backends that GDK should try to use.
- set_
double_ click_ time - Set the double click time for the default display. See
Display::set_double_click_time(). See alsoDisplay::set_double_click_distance(). Applications should not set this, it is a global user-configured setting. - set_
initialized ⚠ - Informs this crate that GDK has been initialized and the current thread is the main one.
- set_
program_ class - Sets the program class. The X11 backend uses the program class to set
the class name part of the
WM_CLASSproperty on toplevel windows; see the ICCCM. - set_
show_ events - Sets whether a trace of received events is output.
Note that GTK+ must be compiled with debugging (that is,
configured using the
--enable-debugoption) to use this option. - setting_
get - shows_
events - Gets whether event debugging output is enabled.
- synthesize_
window_ state - test_
render_ sync - Retrieves a pixel from
windowto force the windowing system to carry out any pending rendering commands. - test_
simulate_ button - This function is intended to be used in GTK+ test programs.
It will warp the mouse pointer to the given (
x,y) coordinates withinwindowand simulate a button press or release event. Because the mouse pointer needs to be warped to the target location, use of this function outside of test programs that run in their own virtual windowing system (e.g. Xvfb) is not recommended. - test_
simulate_ key - This function is intended to be used in GTK+ test programs.
If (
x,y) are > (-1,-1), it will warp the mouse pointer to the given (x,y) coordinates withinwindowand simulate a key press or release event. - text_
property_ to_ utf8_ list_ for_ display - Converts a text property in the given encoding to a list of UTF-8 strings.
- utf8_
to_ string_ target - Converts an UTF-8 string into the best possible representation as a STRING. The representation of characters not in STRING is not specified; it may be as pseudo-escape sequences \x{ABCD}, or it may be in some other form of approximation.