|  |  |  | GDK 3 Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
#include <gdk/gdk.h> void gdk_init (gint *argc,gchar ***argv); gboolean gdk_init_check (gint *argc,gchar ***argv); void gdk_parse_args (gint *argc,gchar ***argv); const gchar * gdk_get_display_arg_name (void); void gdk_notify_startup_complete (void); void gdk_notify_startup_complete_with_id (const gchar *startup_id); const gchar * gdk_get_program_class (void); void gdk_set_program_class (const gchar *program_class); gchar * gdk_get_display (void); void gdk_flush (void); gint gdk_screen_width (void); gint gdk_screen_height (void); gint gdk_screen_width_mm (void); gint gdk_screen_height_mm (void); GdkGrabStatus gdk_pointer_grab (GdkWindow *window,gboolean owner_events,GdkEventMask event_mask,GdkWindow *confine_to,GdkCursor *cursor,guint32 time_); enum GdkGrabStatus; void gdk_pointer_ungrab (guint32 time_); gboolean gdk_pointer_is_grabbed (void); void gdk_set_double_click_time (guint msec); GdkGrabStatus gdk_keyboard_grab (GdkWindow *window,gboolean owner_events,guint32 time_); void gdk_keyboard_ungrab (guint32 time_); void gdk_beep (void); void gdk_error_trap_push (void); void gdk_error_trap_pop_ignored (void); #define GDK_WINDOWING_X11 #define GDK_WINDOWING_WIN32
This section describes the GDK initialization functions and miscellaneous utility functions.
void gdk_init (gint *argc,gchar ***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.
| 
 | the number of command line arguments. [inout] | 
| 
 | the array of command line arguments. [array length=argc][inout] | 
gboolean gdk_init_check (gint *argc,gchar ***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.
| 
 | the number of command line arguments. [inout] | 
| 
 | the array of command line arguments. [array length=argc][inout] | 
| Returns : | TRUEif initialization succeeded. | 
void gdk_parse_args (gint *argc,gchar ***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().
| 
 | the number of command line arguments. | 
| 
 | the array of command line arguments. [inout][array length=argc] | 
Since 2.2
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 explicitely, otherwise NULLthis string is owned by GTK+ and must not be modified or freed. | 
Since 2.2
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
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.
| 
 | a startup-notification identifier, for which notification process should be completed | 
Since 2.12
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. | 
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.
| 
 | a string. | 
gchar *             gdk_get_display                     (void);
Gets the name of the display, which usually comes from the
DISPLAY environment variable or the
--display command line option.
| Returns : | the name of the display. | 
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.
gint                gdk_screen_width                    (void);
Returns the width of the default screen in pixels.
| Returns : | the width of the default screen in pixels. | 
gint                gdk_screen_height                   (void);
Returns the height of the default screen in pixels.
| Returns : | the height of the default screen in pixels. | 
gint                gdk_screen_width_mm                 (void);
Returns the width of the default screen in millimeters. Note that on many X servers this value will not be correct.
| Returns : | the width of the default screen in millimeters, though it is not always correct. | 
gint                gdk_screen_height_mm                (void);
Returns the height of the default screen in millimeters. Note that on many X servers this value will not be correct.
| Returns : | the height of the default screen in millimeters, though it is not always correct. | 
GdkGrabStatus gdk_pointer_grab (GdkWindow *window,gboolean owner_events,GdkEventMask event_mask,GdkWindow *confine_to,GdkCursor *cursor,guint32 time_);
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.
| 
 | the GdkWindow which will own the grab (the grab window). | 
| 
 | if FALSEthen all pointer events are reported with respect towindowand are only reported if selected byevent_mask. IfTRUEthen pointer
events for this application are reported as normal, but pointer events outside
this application are reported with respect towindowand only if selected byevent_mask. In either mode, unreported events are discarded. | 
| 
 | specifies the event mask, which is used in accordance with owner_events. Note that only pointer events (i.e. button and motion events)
may be selected. | 
| 
 | If non- NULL, the pointer will be confined to this
window during the grab. If the pointer is outsideconfine_to, it will
automatically be moved to the closest edge ofconfine_toand enter
and leave events will be generated as necessary. [allow-none] | 
| 
 | the cursor to display while the grab is active. If this is NULLthen
the normal cursors are used forwindowand its descendants, and the cursor
forwindowis used for all other windows. [allow-none] | 
| 
 | the timestamp of the event which led to this pointer grab. This usually
comes from a GdkEventButton struct, though GDK_CURRENT_TIMEcan be used if
the time isn't known. | 
| Returns : | GDK_GRAB_SUCCESSif the grab was successful. | 
typedef enum {
  GDK_GRAB_SUCCESS         = 0,
  GDK_GRAB_ALREADY_GRABBED = 1,
  GDK_GRAB_INVALID_TIME    = 2,
  GDK_GRAB_NOT_VIEWABLE    = 3,
  GDK_GRAB_FROZEN          = 4
} GdkGrabStatus;
Returned by gdk_pointer_grab() and gdk_keyboard_grab() to indicate
success or the reason for the failure of the grab attempt.
| the resource was successfully grabbed. | |
| the resource is actively grabbed by another client. | |
| the resource was grabbed more recently than the specified time. | |
| the grab window or the confine_towindow are not
 viewable. | |
| the resource is frozen by an active grab of another client. | 
void                gdk_pointer_ungrab                  (guint32 time_);
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.
| 
 | a timestamp from a GdkEvent, or GDK_CURRENT_TIMEif no
timestamp is available. | 
gboolean            gdk_pointer_is_grabbed              (void);
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.
| Returns : | TRUEif the pointer is currently grabbed by this application. | 
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.
| 
 | double click time in milliseconds (thousandths of a second) | 
GdkGrabStatus gdk_keyboard_grab (GdkWindow *window,gboolean owner_events,guint32 time_);
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.
| 
 | the GdkWindow which will own the grab (the grab window). | 
| 
 | if FALSEthen all keyboard events are reported with respect towindow. IfTRUEthen keyboard events for this application are
reported as normal, but keyboard events outside this application
are reported with respect towindow. Both key press and key
release events are always reported, independant of the event mask
set by the application. | 
| 
 | a timestamp from a GdkEvent, or GDK_CURRENT_TIMEif no timestamp is
available. | 
| Returns : | GDK_GRAB_SUCCESSif the grab was successful. | 
void                gdk_keyboard_ungrab                 (guint32 time_);
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.
| 
 | a timestamp from a GdkEvent, or GDK_CURRENT_TIMEif no
timestamp is available. | 
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.
Example 1. 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 ... } | 
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
#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.
#define GDK_WINDOWING_WIN32
The GDK_WINDOWING_WIN32 macro is defined if the Win32 backend is supported.
Use this macro to guard code that is specific to the Win32 backend.