Gdk

This section describes the GDK initialization functions and miscellaneous utility functions, as well as deprecation facilities.

The GDK and GTK+ headers annotate deprecated APIs in a way that produces compiler warnings if these deprecated APIs are used. The warnings can be turned off by defining the macro GDK_DISABLE_DEPRECATION_WARNINGS before including the glib.h header.

GDK and GTK+ also provide support for building applications against defined subsets of deprecated or new APIs. Define the macro GDK_VERSION_MIN_REQUIRED to specify up to what version you want to receive warnings about deprecated APIs. Define the macro GDK_VERSION_MAX_ALLOWED to specify the newest version whose API you want to use.

Members

Static functions

beep
void beep()

Emits a short beep on the default display.

errorTrapPop
int errorTrapPop()

Removes an error trap pushed with gdk_error_trap_push(). May block until an error has been definitively received or not received from the X server. gdk_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 of gdk_error_trap_pop(), use gdk_error_trap_pop_ignored(). Prior to GDK 3.0, this function would not automatically sync for you, so you had to gdk_flush() if your last call to Xlib was not a blocking round trip.

errorTrapPopIgnored
void errorTrapPopIgnored()

Removes an error trap pushed with gdk_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. Since 3.0

errorTrapPush
void errorTrapPush()

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 GdkDisplay currently known to the GdkDisplayManager. If you don't care which error happens and just want to ignore everything, pop with gdk_error_trap_pop_ignored(). If you need the error code, use gdk_error_trap_pop() which may have to block and wait for the error to arrive from the X server. This API exists on all platforms but only does anything on X. You can use gdk_x11_display_error_trap_push() to ignore errors on only a single display.

flush
void flush()

Flushes the output buffers of all display connections and waits until all requests have been processed. This is rarely needed by applications.

getDisplay
string getDisplay()

Warning gdk_get_display has been deprecated since version 3.8 and should not be used in newly-written code. Call gdk_display_get_name (gdk_display_get_default())) instead. Gets the name of the display, which usually comes from the DISPLAY environment variable or the --display command line option.

getDisplayArgName
string getDisplayArgName()

Gets the display name specified in the command line arguments passed to gdk_init() or gdk_parse_args(), if any. Since 2.2

getProgramClass
string getProgramClass()

Gets the program class. Unless the program class has explicitly been set with gdk_set_program_class() or with the --class commandline option, the default value is the program name (determined with g_get_prgname()) with the first character converted to uppercase.

init
void init(string[] argv)

Initializes the GDK library and connects to the windowing system. If initialization fails, a warning message is output and the application terminates with a call to exit(1). Any arguments used by GDK are removed from the array and argc and argv are updated accordingly. GTK+ initializes GDK in gtk_init() and so this function is not usually needed by GTK+ applications.

initCheck
int initCheck(string[] argv)

Initializes the GDK library and connects to the windowing system, returning TRUE on success. Any arguments used by GDK are removed from the array and argc and argv are updated accordingly. GTK+ initializes GDK in gtk_init() and so this function is not usually needed by GTK+ applications.

keyboardGrab
GdkGrabStatus keyboardGrab(Window window, int ownerEvents, uint time)

Warning gdk_keyboard_grab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_grab() instead. Grabs the keyboard so that all events are passed to this application until the keyboard is ungrabbed with gdk_keyboard_ungrab(). This overrides any previous keyboard grab by this client. If you set up anything at the time you take the grab that needs to be cleaned up when the grab ends, you should handle the GdkEventGrabBroken events that are emitted when the grab ends unvoluntarily.

keyboardUngrab
void keyboardUngrab(uint time)

Warning gdk_keyboard_ungrab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_ungrab(), together with gdk_device_grab() instead. Ungrabs the keyboard on the default display, if it is grabbed by this application.

notifyStartupComplete
void notifyStartupComplete()

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. GTK+ will call this function automatically after opening the first GtkWindow unless gtk_window_set_auto_startup_notification() is called to disable that feature. Since 2.2

notifyStartupCompleteWithId
void notifyStartupCompleteWithId(string startupId)

Indicates to the GUI environment that the application has finished loading, using a given identifier. GTK+ will call this function automatically for GtkWindow with custom startup-notification identifier unless gtk_window_set_auto_startup_notification() is called to disable that feature. Since 2.12

parseArgs
void parseArgs(string[] argv)

Parse command line arguments, and store for future use by calls to gdk_display_open(). Any arguments used by GDK are removed from the array and argc and argv are updated accordingly. You shouldn't call this function explicitely if you are using gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check(). Since 2.2

pointerGrab
GdkGrabStatus pointerGrab(Window window, int ownerEvents, GdkEventMask eventMask, Window confineTo, Cursor cursor, uint time)

Warning gdk_pointer_grab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_grab() instead. Grabs the pointer (usually a mouse) so that all events are passed to this application until the pointer is ungrabbed with gdk_pointer_ungrab(), or the grab window becomes unviewable. This overrides any previous pointer grab by this client. Pointer grabs are used for operations which need complete control over mouse events, even if the mouse leaves the application. For example in GTK+ it is used for Drag and Drop, for dragging the handle in the GtkHPaned and GtkVPaned widgets. Note that if the event mask of an X window has selected both button press and button release events, then a button press event will cause an automatic pointer grab until the button is released. X does this automatically since most applications expect to receive button press and release events in pairs. It is equivalent to a pointer grab on the window with owner_events set to TRUE. If you set up anything at the time you take the grab that needs to be cleaned up when the grab ends, you should handle the GdkEventGrabBroken events that are emitted when the grab ends unvoluntarily.

pointerIsGrabbed
int pointerIsGrabbed()

Warning gdk_pointer_is_grabbed has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_display_device_is_grabbed() instead. Returns TRUE if the pointer on the default display is currently grabbed by this application. Note that this does not take the inmplicit pointer grab on button presses into account.

pointerUngrab
void pointerUngrab(uint time)

Warning gdk_pointer_ungrab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_ungrab(), together with gdk_device_grab() instead. Ungrabs the pointer on the default display, if it is grabbed by this application.

screenHeight
int screenHeight()

Returns the height of the default screen in pixels.

screenHeightMm
int screenHeightMm()

Returns the height of the default screen in millimeters. Note that on many X servers this value will not be correct.

screenWidth
int screenWidth()

Returns the width of the default screen in pixels.

screenWidthMm
int screenWidthMm()

Returns the width of the default screen in millimeters. Note that on many X servers this value will not be correct.

setAllowedBackends
void setAllowedBackends(string backends)

Sets a list of backends that GDK should try to use. This can be be useful if your application does not work with certain GDK backends. By default, GDK tries all included backends. For example, gdk_set_allowed_backends ("wayland,quartz,*"); instructs GDK to try the Wayland backend first, followed by the Quartz backend, and then all others. If the GDK_BACKEND environment variable is set, it determines what backends are tried in what order, while still respecting the set of allowed backends that are specified by this function. The possible backend names are x11, win32, quartz, broadway, wayland. You can also include a * in the list to try all remaining backends. This call must happen prior to gdk_display_open(), gtk_init(), gtk_init_with_args() or gtk_init_check() in order to take effect.

setDoubleClickTime
void setDoubleClickTime(uint msec)

Set the double click time for the default display. See gdk_display_set_double_click_time(). See also gdk_display_set_double_click_distance(). Applications should not set this, it is a global user-configured setting.

setProgramClass
void setProgramClass(string programClass)

Sets the program class. The X11 backend uses the program class to set the class name part of the WM_CLASS property on toplevel windows; see the ICCCM.

Meta