1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 library initialization and miscellaneous functions.
7 <!-- ##### SECTION Long_Description ##### -->
9 This section describes the GDK initialization functions and miscellaneous
13 <!-- ##### SECTION See_Also ##### -->
18 <!-- ##### FUNCTION gdk_init ##### -->
20 Initializes the GDK library and connects to the X server.
21 If initialization fails, a warning message is output and the application
22 terminates with a call to <literal>exit(1)</literal>.
25 Any arguments used by GDK are removed from the array and @argc and @argv are
29 GTK+ initializes GDK in gtk_init() and so this function is not usually needed
33 @argc: the number of command line arguments.
34 @argv: the array of command line arguments.
37 <!-- ##### FUNCTION gdk_init_check ##### -->
39 Initializes the GDK library and connects to the X server, returning %TRUE on
43 Any arguments used by GDK are removed from the array and @argc and @argv are
47 GTK+ initializes GDK in gtk_init() and so this function is not usually needed
51 @argc: the number of command line arguments.
52 @argv: the array of command line arguments.
53 @Returns: %TRUE if initialization succeeded.
56 <!-- ##### FUNCTION gdk_parse_args ##### -->
65 <!-- ##### FUNCTION gdk_get_display_arg_name ##### -->
73 <!-- ##### FUNCTION gdk_set_locale ##### -->
75 Initializes the support for internationalization by calling the <function>setlocale()</function>
76 system call. This function is called by gtk_set_locale() and so GTK+
77 applications should use that instead.
80 The locale to use is determined by the <envar>LANG</envar> environment variable,
81 so to run an application in a certain locale you can do something like this:
85 ... run application ...
90 If the locale is not supported by X then it is reset to the standard "C"
94 @Returns: the resulting locale.
97 <!-- ##### FUNCTION gdk_set_sm_client_id ##### -->
104 <!-- ##### FUNCTION gdk_exit ##### -->
106 Exits the application using the <function>exit()</function> system call.
109 This routine is provided mainly for backwards compatibility, since it used to
110 perform tasks necessary to exit the application cleanly. Those tasks are now
111 performed in a function which is automatically called on exit (via the use
115 @error_code: the error code to pass to the <function>exit()</function> call.
118 <!-- ##### FUNCTION gdk_get_program_class ##### -->
120 Gets the program class. Unless the program class has explicitly
121 been set with gdk_set_program_class() or with the <option>--class</option>
122 commandline option, the default value is the program name (determined
123 with g_get_prgname()) with the first character converted to uppercase.
126 @Returns: the program class.
129 <!-- ##### FUNCTION gdk_set_program_class ##### -->
131 Sets the program class. The X11 backend uses the program class to set
132 the class name part of the <literal>WM_CLASS</literal> property on
133 toplevel windows; see the ICCCM.
136 @program_class: a string.
139 <!-- ##### FUNCTION gdk_get_display ##### -->
141 Gets the name of the display, which usually comes from the <envar>DISPLAY</envar>
142 environment variable or the <option>--display</option> command line option.
145 @Returns: the name of the display.
148 <!-- ##### FUNCTION gdk_flush ##### -->
150 Flushes the X output buffer and waits until all requests have been processed
151 by the server. This is rarely needed by applications. It's main use is for
152 trapping X errors with gdk_error_trap_push() and gdk_error_trap_pop().
157 <!-- ##### FUNCTION gdk_screen_width ##### -->
164 <!-- ##### FUNCTION gdk_screen_height ##### -->
171 <!-- ##### FUNCTION gdk_screen_width_mm ##### -->
178 <!-- ##### FUNCTION gdk_screen_height_mm ##### -->
185 <!-- ##### FUNCTION gdk_pointer_grab ##### -->
187 Grabs the pointer (usually a mouse) so that all events are passed to this
188 application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
189 the grab window becomes unviewable.
190 This overrides any previous pointer grab by this client.
193 Pointer grabs are used for operations which need complete control over mouse
194 events, even if the mouse leaves the application.
195 For example in GTK+ it is used for Drag and Drop, for dragging the handle in
196 the #GtkHPaned and #GtkVPaned widgets, and for resizing columns in #GtkCList
200 Note that if the event mask of an X window has selected both button press and
201 button release events, then a button press event will cause an automatic
202 pointer grab until the button is released.
203 X does this automatically since most applications expect to receive button
204 press and release events in pairs.
205 It is equivalent to a pointer grab on the window with @owner_events set to
209 @window: the #GdkWindow which will own the grab (the grab window).
210 @owner_events: if %FALSE then all pointer events are reported with respect to
211 @window and are only reported if selected by @event_mask. If %TRUE then pointer
212 events for this application are reported as normal, but pointer events outside
213 this application are reported with respect to @window and only if selected by
214 @event_mask. In either mode, unreported events are discarded.
215 @event_mask: specifies the event mask, which is used in accordance with
217 @confine_to: If non-%NULL, the pointer will be confined to this
218 window during the grab. If the pointer is outside @confine_to, it will
219 automatically be moved to the closest edge of @confine_to and enter
220 and leave events will be generated as necessary.
221 @cursor: the cursor to display while the grab is active. If this is %NULL then
222 the normal cursors are used for @window and its descendants, and the cursor
223 for @window is used for all other windows.
224 @time: the timestamp of the event which led to this pointer grab. This usually
225 comes from a #GdkEventButton struct, though %GDK_CURRENT_TIME can be used if
226 the time isn't known.
227 @Returns: %GDK_GRAB_SUCCESS if the grab was successful.
230 <!-- ##### ENUM GdkGrabStatus ##### -->
232 Returned by gdk_pointer_grab() and gdk_keyboard_grab() to indicate
233 success or the reason for the failure of the grab attempt.
236 @GDK_GRAB_SUCCESS: the resource was successfully grabbed.
237 @GDK_GRAB_ALREADY_GRABBED: the resource is actively grabbed by another client.
238 @GDK_GRAB_INVALID_TIME: the resource was grabbed more recently than the
240 @GDK_GRAB_NOT_VIEWABLE: the grab window or the @confine_to window are not
242 @GDK_GRAB_FROZEN: the resource is frozen by an active grab of another client.
244 <!-- ##### FUNCTION gdk_pointer_ungrab ##### -->
252 <!-- ##### FUNCTION gdk_pointer_is_grabbed ##### -->
261 <!-- ##### FUNCTION gdk_set_double_click_time ##### -->
269 <!-- ##### FUNCTION gdk_keyboard_grab ##### -->
271 Grabs the keyboard so that all events are passed to this
272 application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
273 This overrides any previous keyboard grab by this client.
276 @window: the #GdkWindow which will own the grab (the grab window).
277 @owner_events: if %FALSE then all keyboard events are reported with respect to
278 @window. If %TRUE then keyboard events for this application are reported as
279 normal, but keyboard events outside this application are reported with respect
280 to @window. Both key press and key release events are always reported,
281 independant of the event mask set by the application.
282 @time: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no timestamp is
284 @Returns: %GDK_GRAB_SUCCESS if the grab was successful.
287 <!-- ##### FUNCTION gdk_keyboard_ungrab ##### -->
294 <!-- ##### FUNCTION gdk_beep ##### -->
300 <!-- ##### FUNCTION gdk_get_use_xshm ##### -->
302 Returns %TRUE if GDK will attempt to use the MIT-SHM shared memory extension.
305 The shared memory extension is used for #GdkImage, and consequently for
306 <link linkend="gdk-GdkRGB">GdkRGB</link>.
307 It enables much faster drawing by communicating with the X server through
308 SYSV shared memory calls. However, it can only be used if the X client and
309 server are on the same machine and the server supports it.
312 @Returns: %TRUE if use of the MIT shared memory extension will be attempted.
315 <!-- ##### FUNCTION gdk_set_use_xshm ##### -->
317 Sets whether the use of the MIT shared memory extension should be attempted.
318 This function is mainly for internal use. It is only safe for an application
319 to set this to %FALSE, since if it is set to %TRUE and the server does not
320 support the extension it may cause warning messages to be output.
323 @use_xshm: %TRUE if use of the MIT shared memory extension should be attempted.
326 <!-- ##### FUNCTION gdk_error_trap_push ##### -->
328 This function allows X errors to be trapped instead of the normal behavior
329 of exiting the application. It should only be used if it is not possible to
330 avoid the X error in any other way.
333 <title>Trapping an X error.</title>
335 gdk_error_trap_push (<!-- -->);
337 /* ... Call the X function which may cause an error here ... */
339 /* Flush the X queue to catch errors now. */
340 gdk_flush (<!-- -->);
342 if (gdk_error_trap_pop (<!-- -->))
344 /* ... Handle the error here ... */
351 <!-- ##### FUNCTION gdk_error_trap_pop ##### -->
353 Removes the X error trap installed with gdk_error_trap_push().
356 @Returns: the X error code, or 0 if no error occurred.
359 <!-- ##### MACRO GDK_WINDOWING_X11 ##### -->
361 This macro is defined if GDK is configured to use the X backend.
366 <!-- ##### MACRO GDK_WINDOWING_WIN32 ##### -->
368 This macro is defined if GDK is configured to use the Win32 backend.
373 <!-- ##### MACRO GDK_WINDOWING_FB ##### -->
375 This macro is defined if GDK is configured to use the Linux framebuffer backend.