Library initialization and miscellaneous functions
This section describes the GDK initialization functions and miscellaneous utility functions.
mchars
)Gets the display name specified in the command line arguments passed to
gdk-init
orgdk-parse-args
, if any.
- ret
- the display name, if specified explicitely, otherwise ‘
#f
’ this string is owned by GTK+ and must not be modified or freed.Since 2.2
mchars
)Initializes the support for internationalization by calling the
setlocale
system call. This function is called bygtk-set-locale
and so GTK+ applications should use that instead.The locale to use is determined by the LANG environment variable, so to run an application in a certain locale you can do something like this:
export LANG="fr" ... run application ...If the locale is not supported by X then it is reset to the standard "C" locale.
- ret
- the resulting locale.
mchars
)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 (ICCCM) for information on the ‘WM_CLIENT_LEADER’ property. (Both documents are part of the X Window System distribution.)
- sm-client-id
- the client id assigned by the session manager when the connection was opened, or ‘
#f
’ to remove the property.
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
<gtk-window>
unlessgtk-window-set-auto-startup-notification
is called to disable that feature.Since 2.2
mchars
)Gets the program class. Unless the program class has explicitly been set with
gdk-set-program-class
or with the option, the default value is the program name (determined withg-get-prgname
) with the first character converted to uppercase.
- ret
- the program class.
mchars
)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.
- program-class
- a string.
mchars
)Gets the name of the display, which usually comes from the DISPLAY environment variable or the
- ret
- the name of the display.
Flushes the X output buffer and waits until all requests have been processed by the server. This is rarely needed by applications. It's main use is for trapping X errors with
gdk-error-trap-push
andgdk-error-trap-pop
.
int
)Returns the width of the default screen in pixels.
- ret
- the width of the default screen in pixels.
int
)Returns the height of the default screen in pixels.
- ret
- the height of the default screen in pixels.
int
)Returns the width of the default screen in millimeters. Note that on many X servers this value will not be correct.
- ret
- the width of the default screen in millimeters, though it is not always correct.
int
)Returns the height of the default screen in millimeters. Note that on many X servers this value will not be correct.
- ret
- the height of the default screen in millimeters, though it is not always correct.
<gdk-window>
) (owner_events bool
) (event_mask <gdk-event-mask>
) (confine_to <gdk-window>
) (cursor <gdk-cursor>
) (time_ unsigned-int32
) ⇒ (ret <gdk-grab-status>
)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
<gtk-hpaned>
and<gtk-vpaned>
widgets, and for resizing columns in<gtk-clist>
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 ‘
#t
’.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
<gdk-event-grab-broken>
events that are emitted when the grab ends unvoluntarily.
- window
- the
<gdk-window>
which will own the grab (the grab window).- owner-events
- if ‘
#f
’ then all pointer events are reported with respect to window and are only reported if selected by event-mask. If ‘#t
’ then pointer events for this application are reported as normal, but pointer events outside this application are reported with respect to window and only if selected by event-mask. In either mode, unreported events are discarded.- event-mask
- 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.
- confine-to
- If non-‘
#f
’, the pointer will be confined to this window during the grab. If the pointer is outside confine-to, it will automatically be moved to the closest edge of confine-to and enter and leave events will be generated as necessary.- cursor
- the cursor to display while the grab is active. If this is ‘
#f
’ then the normal cursors are used for window and its descendants, and the cursor for window is used for all other windows.- time
- the timestamp of the event which led to this pointer grab. This usually comes from a
<gdk-event-button>
struct, though ‘GDK_CURRENT_TIME’ can be used if the time isn't known.- ret
- ‘GDK_GRAB_SUCCESS’ if the grab was successful.
unsigned-int32
)Ungrabs the pointer, if it is grabbed by this application.
- time
- a timestamp from a
<gdk-event>
, or ‘GDK_CURRENT_TIME’ if no timestamp is available.
bool
)Returns ‘
#t
’ if the pointer is currently grabbed by this application.Note that this does not take the inmplicit pointer grab on button presses into account.
- ret
- ‘
#t
’ if the pointer is currently grabbed by this application.*
unsigned-int
)Set the double click time for the default display. See
gdk-display-set-double-click-time
. See alsogdk-display-set-double-click-distance
. Applications should not set this, it is a global user-configured setting.
- msec
- double click time in milliseconds (thousandths of a second)
<gdk-window>
) (owner_events bool
) (time_ unsigned-int32
) ⇒ (ret <gdk-grab-status>
)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
<gdk-event-grab-broken>
events that are emitted when the grab ends unvoluntarily.
- window
- the
<gdk-window>
which will own the grab (the grab window).- owner-events
- if ‘
#f
’ then all keyboard events are reported with respect to window. If ‘#t
’ then keyboard events for this application are reported as normal, but keyboard events outside this application are reported with respect to window. Both key press and key release events are always reported, independant of the event mask set by the application.- time
- a timestamp from a
<gdk-event>
, or ‘GDK_CURRENT_TIME’ if no timestamp is available.- ret
- ‘GDK_GRAB_SUCCESS’ if the grab was successful.
unsigned-int32
)Ungrabs the keyboard, if it is grabbed by this application.
- time
- a timestamp from a
<gdk-event>
, or ‘GDK_CURRENT_TIME’ if no timestamp is available.
bool
)‘gdk_get_use_xshm’ is deprecated and should not be used in newly-written code.
Returns ‘
#t
’ if GDK will attempt to use the MIT-SHM shared memory extension.The shared memory extension is used for
<gdk-image>
, and consequently for GdkRGB. It enables much faster drawing by communicating with the X server through SYSV shared memory calls. However, it can only be used if the X client and server are on the same machine and the server supports it.
- ret
- ‘
#t
’ if use of the MIT shared memory extension will be attempted.
bool
)‘gdk_set_use_xshm’ is deprecated and should not be used in newly-written code.
Sets whether the use of the MIT shared memory extension should be attempted. This function is mainly for internal use. It is only safe for an application to set this to ‘
#f
’, since if it is set to ‘#t
’ and the server does not support the extension it may cause warning messages to be output.
- use-xshm
- ‘
#t
’ if use of the MIT shared memory extension should be attempted.
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.
gdk_error_trap_push (); /* ... Call the X function which may cause an error here ... */ /* Flush the X queue to catch errors now. */ gdk_flush (); if (gdk_error_trap_pop ()) { /* ... Handle the error here ... */ }