General

General — Library initialization and miscellaneous functions

Functions

Types and Values

Includes

#include <gdk/gdk.h>

Description

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.

Functions

gdk_get_display_arg_name ()

const gchar *
gdk_get_display_arg_name (void);

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

Returns

the display name, if specified explicitly, otherwise NULL this string is owned by GTK+ and must not be modified or freed.

[nullable]

Since: 2.2


gdk_notify_startup_complete ()

void
gdk_notify_startup_complete (void);

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


gdk_notify_startup_complete_with_id ()

void
gdk_notify_startup_complete_with_id (const gchar *startup_id);

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.

Parameters

startup_id

a startup-notification identifier, for which notification process should be completed

 

Since: 2.12


gdk_set_allowed_backends ()

void
gdk_set_allowed_backends (const gchar *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,

1
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(), or gtk_init_check() in order to take effect.

Parameters

backends

a comma-separated list of backends

 

Since: 3.10


gdk_get_program_class ()

const gchar *
gdk_get_program_class (void);

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.

Returns

the program class.


gdk_set_program_class ()

void
gdk_set_program_class (const gchar *program_class);

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.

The program class can still be overridden with the --class command line option.

Parameters

program_class

a string.

 

gdk_flush ()

void
gdk_flush (void);

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


gdk_set_double_click_time ()

void
gdk_set_double_click_time (guint 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.

Parameters

msec

double click time in milliseconds (thousandths of a second)

 

gdk_beep ()

void
gdk_beep (void);

Emits a short beep on the default display.


gdk_error_trap_push ()

void
gdk_error_trap_push (void);

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.

Trapping an X error

1
2
3
4
5
6
7
8
9
gdk_error_trap_push ();

 // ... Call the X function which may cause an error here ...


if (gdk_error_trap_pop ())
 {
   // ... Handle the error here ...
 }


gdk_error_trap_pop ()

gint
gdk_error_trap_pop (void);

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.

Returns

X error code or 0 on success


gdk_error_trap_pop_ignored ()

void
gdk_error_trap_pop_ignored (void);

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

Types and Values

enum GdkGrabStatus

Returned by gdk_device_grab() to indicate success or the reason for the failure of the grab attempt.

Members

GDK_GRAB_SUCCESS

the resource was successfully grabbed.

 

GDK_GRAB_ALREADY_GRABBED

the resource is actively grabbed by another client.

 

GDK_GRAB_INVALID_TIME

the resource was grabbed more recently than the specified time.

 

GDK_GRAB_NOT_VIEWABLE

the grab window or the confine_to window are not viewable.

 

GDK_GRAB_FROZEN

the resource is frozen by an active grab of another client.

 

GDK_GRAB_FAILED

the grab failed for some other reason. Since 3.16

 

GDK_WINDOWING_X11

#define GDK_WINDOWING_X11

The GDK_WINDOWING_X11 macro is defined if the X11 backend is supported.

Use this macro to guard code that is specific to the X11 backend.


GDK_WINDOWING_WAYLAND

#define GDK_WINDOWING_WAYLAND

The GDK_WINDOWING_WAYLAND macro is defined if the Wayland backend is supported.

Use this macro to guard code that is specific to the Wayland backend.


GDK_VERSION_3_0

#define GDK_VERSION_3_0         (G_ENCODE_VERSION (3, 0))

A macro that evaluates to the 3.0 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.4


GDK_VERSION_3_2

#define GDK_VERSION_3_2         (G_ENCODE_VERSION (3, 2))

A macro that evaluates to the 3.2 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.4


GDK_VERSION_3_4

#define GDK_VERSION_3_4         (G_ENCODE_VERSION (3, 4))

A macro that evaluates to the 3.4 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.4


GDK_VERSION_3_6

#define GDK_VERSION_3_6         (G_ENCODE_VERSION (3, 6))

A macro that evaluates to the 3.6 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.6


GDK_VERSION_3_8

#define GDK_VERSION_3_8         (G_ENCODE_VERSION (3, 8))

A macro that evaluates to the 3.8 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.8


GDK_VERSION_3_10

#define GDK_VERSION_3_10        (G_ENCODE_VERSION (3, 10))

A macro that evaluates to the 3.10 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.10


GDK_VERSION_3_12

#define GDK_VERSION_3_12        (G_ENCODE_VERSION (3, 12))

A macro that evaluates to the 3.12 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.12


GDK_VERSION_3_14

#define GDK_VERSION_3_14        (G_ENCODE_VERSION (3, 14))

A macro that evaluates to the 3.14 version of GDK, in a format that can be used by the C pre-processor.

Since: 3.14


GDK_VERSION_MIN_REQUIRED

# define GDK_VERSION_MIN_REQUIRED      (GDK_VERSION_CUR_STABLE)

A macro that should be defined by the user prior to including the gdk.h header. The definition should be one of the predefined GDK version macros: GDK_VERSION_3_0, GDK_VERSION_3_2,...

This macro defines the lower bound for the GDK API to use.

If a function has been deprecated in a newer version of GDK, it is possible to use this symbol to avoid the compiler warnings without disabling warning for every deprecated function.

Since: 3.4


GDK_VERSION_MAX_ALLOWED

#  define GDK_VERSION_MAX_ALLOWED      GDK_VERSION_MIN_REQUIRED

A macro that should be defined by the user prior to including the gdk.h header. The definition should be one of the predefined GDK version macros: GDK_VERSION_3_0, GDK_VERSION_3_2,...

This macro defines the upper bound for the GDK API to use.

If a function has been introduced in a newer version of GDK, it is possible to use this symbol to get compiler warnings when trying to use that function.

Since: 3.4