X11

The functions in this section are specific to the GDK X11 backend. To use them, you need to include the <gdk/gdkx.h> header and use the X11-specific pkg-config files to build your application (either gdk-x11-3.0 or gtk+-x11-3.0).

To make your code compile with other GDK backends, guard backend-specific calls by an ifdef as follows. Since GDK may be built with multiple backends, you should also check for the backend that is in use (e.g. by using the GDK_IS_X11_DISPLAY() macro).

class X11 {}

Members

Static functions

deviceGetId
int deviceGetId(Device device)

Returns the device ID as seen by XInput2. Note If gdk_disable_multidevice() has been called, this function will respectively return 2/3 for the core pointer and keyboard, (matching the IDs for the Virtual Core Pointer and Keyboard in XInput 2), but calling this function on any slave devices (i.e. those managed via XInput 1.x), will return 0.

deviceManagerLookup
Device deviceManagerLookup(DeviceManager deviceManager, int deviceId)

Returns the GdkDevice that wraps the given device ID.

displayErrorTrapPop
int displayErrorTrapPop(Display display)

Pops the error trap pushed by gdk_x11_display_error_trap_push(). Will XSync() if necessary and will always block until the error is known to have occurred or not occurred, so the error code can be returned. If you don't need to use the return value, gdk_x11_display_error_trap_pop_ignored() would be more efficient. See gdk_error_trap_pop() for the all-displays-at-once equivalent.

displayErrorTrapPopIgnored
void displayErrorTrapPopIgnored(Display display)

Pops the error trap pushed by gdk_x11_display_error_trap_push(). Does not block to see if an error occurred; merely records the range of requests to ignore errors for, and ignores those errors if they arrive asynchronously. See gdk_error_trap_pop_ignored() for the all-displays-at-once equivalent.

displayErrorTrapPush
void displayErrorTrapPush(Display display)

Begins a range of X requests on display for which X error events will be ignored. Unignored errors (when no trap is pushed) will abort the application. Use gdk_x11_display_error_trap_pop() or gdk_x11_display_error_trap_pop_ignored()to lift a trap pushed with this function. See also gdk_error_trap_push() to push a trap on all displays.

displayGetStartupNotificationId
string displayGetStartupNotificationId(Display display)

Gets the startup notification ID for a display. Since 2.12

displaySetStartupNotificationId
void displaySetStartupNotificationId(Display display, string startupId)

Sets the startup notification ID for a display. This is usually taken from the value of the DESKTOP_STARTUP_ID environment variable, but in some cases (such as the application not being launched using exec()) it can come from other sources. If the ID contains the string "_TIME" then the portion following that string is taken to be the X11 timestamp of the event that triggered the application to be launched and the GDK current event time is set accordingly. The startup ID is also what is used to signal that the startup is complete (for example, when opening a window or when calling gdk_notify_startup_complete()).

displaySetWindowScale
void displaySetWindowScale(Display display, int scale)

Forces a specific window scale for all windows on this display, instead of using the default or user configured scale. This is can be used to disable scaling support by setting scale to 1, or to programmatically set the window scale. Once the scale is set by this call it will not change in response to later user configuration changes.

displayStringToCompoundText
int displayStringToCompoundText(Display display, string str, GdkAtom encoding, int format, char[] ctext)

Convert a string from the encoding of the current locale into a form suitable for storing in a window property. Since 2.24

displayTextPropertyToTextList
int displayTextPropertyToTextList(Display display, GdkAtom encoding, int format, char[] text, string[] list)

Convert a text string from the encoding as it is stored in a property into an array of strings in the encoding of the current locale. (The elements of the array represent the nul-separated elements of the original text string.) Since 2.24

displayUtf8_ToCompoundText
int displayUtf8_ToCompoundText(Display display, string str, GdkAtom encoding, int format, char[] ctext)

Converts from UTF-8 to compound text. Since 2.24

freeCompoundText
void freeCompoundText(char ctext)

Frees the data returned from gdk_x11_display_string_to_compound_text(). Since 2.24

freeTextList
void freeTextList(string list)

Frees the array of strings created by gdk_x11_display_text_property_to_text_list(). Since 2.24

getDefaultScreen
int getDefaultScreen()

Gets the default GTK+ screen number.

getServerTime
uint getServerTime(Window window)

Routine to get the current X server time stamp.

grabServer
void grabServer()

Call gdk_x11_display_grab() on the default display. To ungrab the server again, use gdk_x11_ungrab_server(). gdk_x11_grab_server()/gdk_x11_ungrab_server() calls can be nested.

keymapGetGroupForState
int keymapGetGroupForState(Keymap keymap, uint state)

Extracts the group from the state field sent in an X Key event. This is only needed for code processing raw X events, since GdkEventKey directly includes an is_modifier field.

keymapKeyIsModifier
int keymapKeyIsModifier(Keymap keymap, uint keycode)

Determines whether a particular key code represents a key that is a modifier. That is, it's a key that normally just affects the keyboard state and the behavior of other keys rather than producing a direct effect itself. This is only needed for code processing raw X events, since GdkEventKey directly includes an is_modifier field.

screenGetCurrentDesktop
uint screenGetCurrentDesktop(Screen screen)

Returns the current workspace for screen when running under a window manager that supports multiple workspaces, as described in the Extended Window Manager Hints.

screenGetMonitorOutput
uint screenGetMonitorOutput(Screen screen, int monitorNum)

Gets the XID of the specified output/monitor. If the X server does not support version 1.2 of the RANDR extension, 0 is returned. Since 2.14

screenGetNumberOfDesktops
uint screenGetNumberOfDesktops(Screen screen)

Returns the number of workspaces for screen when running under a window manager that supports multiple workspaces, as described in the Extended Window Manager Hints.

setSmClientId
void setSmClientId(string smClientId)

Sets the SM_CLIENT_ID property on the application's leader window so that the window manager can save the application's state using the X11R6 ICCCM session management protocol. See the X Session Management Library documentation for more information on session management and the Inter-Client Communication Conventions Manual Since 2.24

ungrabServer
void ungrabServer()

Ungrab the default display after it has been grabbed with gdk_x11_grab_server().

windowGetDesktop
uint windowGetDesktop(Window window)

Gets the number of the workspace window is on.

windowGetXid
gulong windowGetXid(Window window)

Returns the X resource (window) belonging to a GdkWindow.

windowMoveToCurrentDesktop
void windowMoveToCurrentDesktop(Window window)

Moves the window to the correct workspace when running under a window manager that supports multiple workspaces, as described in the Extended Window Manager Hints. Will not do anything if the window is already on all workspaces. Since 2.8

windowMoveToDesktop
void windowMoveToDesktop(Window window, uint desktop)

Moves the window to the given workspace when running unde a window manager that supports multiple workspaces, as described in the Extended Window Manager Hints.

windowSetFrameExtents
void windowSetFrameExtents(Window window, int left, int right, int top, int bottom)

Newer GTK+ windows using client-side decorations use extra geometry around their frames for effects like shadows and invisible borders. Window managers that want to maximize windows or snap to edges need to know where the extents of the actual frame lie, so that users don't feel like windows are snapping against random invisible edges. Note that this property is automatically updated by GTK+, so this function should only be used by applications which do not use GTK+ to create toplevel windows.

windowSetFrameSyncEnabled
void windowSetFrameSyncEnabled(Window window, int frameSyncEnabled)

This function can be used to disable frame synchronization for a window. Normally frame synchronziation will be enabled or disabled based on whether the system has a compositor that supports frame synchronization, but if the window is not directly managed by the window manager, then frame synchronziation may need to be disabled. This is the case for a window embedded via the XEMBED protocol.

windowSetHideTitlebarWhenMaximized
void windowSetHideTitlebarWhenMaximized(Window window, int hideTitlebarWhenMaximized)

Set a hint for the window manager, requesting that the titlebar should be hidden when the window is maximized. Note that this property is automatically updated by GTK+, so this function should only be used by applications which do not use GTK+ to create toplevel windows.

windowSetThemeVariant
void windowSetThemeVariant(Window window, string variant)

GTK+ applications can request a dark theme variant. In order to make other applications - namely window managers using GTK+ for themeing - aware of this choice, GTK+ uses this function to export the requested theme variant as _GTK_THEME_VARIANT property on toplevel windows. Note that this property is automatically updated by GTK+, so this function should only be used by applications which do not use GTK+ to create toplevel windows.

windowSetUserTime
void windowSetUserTime(Window window, uint timestamp)

The application can use this call to update the _NET_WM_USER_TIME property on a toplevel window. This property stores an Xserver time which represents the time of the last user input event received for this window. This property may be used by the window manager to alter the focus, stacking, and/or placement behavior of windows when they are mapped depending on whether the new window was created by a user action or is a "pop-up" window activated by a timer or some other event. Note that this property is automatically updated by GDK, so this function should only be used by applications which handle input events bypassing GDK. Since 2.6

windowSetUtf8_Property
void windowSetUtf8_Property(Window window, string name, string value)

This function modifies or removes an arbitrary X11 window property of type UTF8_STRING. If the given window is not a toplevel window, it is ignored.

Meta