forked from AuroraMiddleware/gtk
95b3f3e460
Wed Sep 8 07:13:29 1999 Tim Janik <timj@gtk.org> * configure.in: fixed "GNU Make" check to pass with new make version 3.77.95. Fri Sep 3 16:04:41 1999 Tim Janik <timj@gtk.org> * gtk-config.in (--version): don't echo @GTK_VERSION@, but @GTK_MAJOR_VERSION@.@GTK_MINOR_VERSION@.@GTK_MICRO_VERSION@, so the AM_PATH_GTK() macros don't get confused by the -pre1. Thu Sep 2 19:02:37 1999 Owen Taylor <otaylor@redhat.com> * configure.in (REBUILD): Change check for perl5 to check explicitely for v >= 5.002. (5.001 does not work with our scripts.) Wed Aug 25 15:45:46 1999 Tim Janik <timj@gtk.org> * configure.in: evaluate $PERL for the perl version check. added --disable-rebuilds to give the user an option to completely disable any source autogeneration rules. Mon Aug 23 23:16:14 1999 Tim Janik <timj@gtk.org> * configure.in: evaluate $ac_make when checking for GNU Make. Mon Aug 23 19:11:17 1999 Tim Janik <timj@gtk.org> * docs/Makefile.am: added generation.txt. * Makefile.am: require automake 1.4, build README from README.in and INSTALL from INSTALL.in in dist-hook. * README.in: * INSTALL.in: new files to autogenerate README and INSTALL from. * configure.in: figure whether we have GNU Make * docs/generation.txt: minor additions/corrections. Wed Aug 11 13:38:26 BST 1999 Tony Gale <gale@gtk.org> * docs/gtkfaq.sgml: FAQ Update July 30, 1999 Elliot Lee <sopwith@redhat.com> * configure.in: Fix autoconf warnings about cross compilation by trying to provide sane defaults for AC_TRY_RUN. Fri Jul 16 22:20:21 PDT 1999 Manish Singh <yosh@gimp.org> * ltconfig * ltmain.sh: upgrade to libtool 1.3.3 Thu Jul 8 11:30:18 1999 Owen Taylor <otaylor@redhat.com> * INSTALL: Indicate that the --with-glib= configure time flag is unsupported. Mon Jul 5 20:36:03 1999 Owen Taylor <otaylor@redhat.com> * docs/generation.txt: Added a file that gives documenation about the autogeneration process for various autogenerated files. Tue Jun 29 15:59:25 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LIBS): Look for libgmodule in the right location. Thu Jun 17 13:57:31 1999 Owen Taylor <otaylor@redhat.com> * docs/gtk_tut.sgml: Removed references to code examples in my directory on gtk.org as they should all be in the tutorial now. * docs/gtk_tut.sgml: Added sources for dial-test and scribble-xinput programs that were previously missing. Fri Jun 4 00:08:59 1999 Owen Taylor <otaylor@redhat.com> * TODO: Added entry about menu keyboard navigation, removed some finished items. Mon May 31 00:11:24 1999 Owen Taylor <otaylor@redhat.com> * acinclude.m4: Standardize on func_dgettext not func_gettext, so that the checks for dgettext actually are paid attention to. Wed May 5 10:47:54 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LIBS): Add $INTLLIBS into $LIBS directly, rather than repeating the checks for gettext. * INSTALL: Added information about gettext and NLS support. * acinclude.m4 (LIBM): Check for dgettext, not just gettext. This should hopefully fix things wrt systems with old versions of GNU gettext installed. Tue Jun 29 15:59:25 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LIBS): Look for libgmodule in the right location. Thu Apr 1 16:58:10 PST 1999 Manish Singh <yosh@gimp.org> * autogen.sh: add --enable-maintainer-mode * configure.in: set ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" Wed Mar 24 23:03:49 CST 1999 Shawn T. Amundson <amundson@gtk.org> * docs/gtk-config.1.in: docs/Makefile.am: configure.in: gtk-config is now generated. * docs/gtk-config.1: Removed, now generated. Thu Sep 23 17:59:59 1999 Tim Janik <timj@gtk.org> * gdk/gdkevents.c (gdk_event_translate): grr, even if Gdk doesn't handle CreateNotify itself, still put out a debuging message for --gdk-debug=events. made the ReparentNotify debugging message more verbose. wrap xcoords translation for ConfigureEvents into an error trap, a destroy event may already be pending, and in that case, the actuall coordinate values are not at all critical. Sat Sep 18 22:24:15 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkcc.c: Stop leaking the color_hash all over the place. Simplify and improve the logic. Fri Sep 17 09:57:15 1999 Tim Janik <timj@gtk.org> * gdk/gdk.h, gdk/gdkcolor.c: make return types (gint or gboolean) for prototypes and function implementations consistent (reported by Tomas Ogren). Tue Sep 14 18:23:01 1999 Tim Janik <timj@gtk.org> * gdk/gdkevents.c (gdk_event_translate): tell if expose events have send_event set in debugging output. (gdk_compress_exposures): default initialize the event so we don't operate on bogus values (namely send_event). Thu Sep 2 16:33:59 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.c: When we receive an unexpected destroy notify on one of our windows, don't just warn about it, also mark our windows as destroyed. Sun Sep 5 08:10:53 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkfont.c (gdk_font_hash_insert): Add name => font and name => fontset hashes. The name => fontset hash is a _big_ win since we weren't previously caching fontsets at all and loading fontsets is expensive. The name => font hash is less of a win, but it does save us from doing repeated XQueryFont calls on the same font. * gdk/gdkprivate.h (struct _GdkFontPrivate): Add a names list so we can remove font/fontset from hash. Thu Sep 2 19:02:37 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkproperty.c (gdk_atom_intern): Remove useless and slightly confusing test. [ XInternAtom (,,TRUE) will never return None ]. Sat Sep 4 08:39:26 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.c (gdk_window_set_geometry_hints) gdk/gdkwindow.c (gdk_window_set_hints): Don't omit setting the properties if flags == 0 - there may be an existing set of properties there already. (Very old bug. Would it be better to delete the property instead?) * gdk/gdkselection.c (gdk_selection_property_get): Fix spelling error in comment. Wed Sep 1 14:05:30 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkimage.c (gdk_image_new): Use gdk_error_trap_push() to avoid stomping over gdk_error_warnings. * gdk/gdkimage.c (gdk_image_new): compute image->bpp as (bits_per_pixel + 7) / 8. This gives the same result as before for multiples of 8, but actually a "reasonable" value for 1bit or 4bit displays. Mon Aug 23 19:11:17 1999 Tim Janik <timj@gtk.org> * gdk/Makefile.am: minor cleanups, strip spaces on build rules for GNU Make. Tue Aug 17 07:43:04 1999 Tim Janik <timj@gtk.org> * gdk/gdkevents.c (gdk_event_translate): give a debugging note when discarding configure events. 1999-08-18 Federico Mena Quintero <federico@redhat.com> * gdk/gdkpixmap.c (gdk_pixmap_unref): g_return_if_fail() the refcount is greater than zero. * gdk/gdkwindow.c (gdk_window_unref): Likewise. * gdk/gdkfont.c (gdk_font_unref): Likewise. * gdk/gdkgc.c (gdk_gc_unref): Likewise. * gdk/gdkdnd.c (gdk_drag_context_unref): Likewise. Wed Aug 11 01:04:57 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkproperty.c (gdk_property_get): Fix assumption that format 32 => sizeof(item) == 4. It really is sizeof(long). Tue Jun 29 23:02:42 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdk.c (gdk_x_error / gdk_x_io_error): Don't core dump at all on X IO errors, only core dump if --enable-debug for X errors. Thu Jun 24 17:06:23 1999 Tim Janik <timj@gtk.org> * gdk/gdkevents.c (gdk_event_translate): removed old ""Got event for unknown window:" message. disabled ConfigureNotify discarding code, because it led to events being processed out of order. Thu Jun 24 12:22:02 1999 Tim Janik <timj@gtk.org> * gdk/gdkglobals.c: preinitialize gdk_error_code to 0. * gdk/gdkevents.c (gdk_event_send_client_message_to_all_recurse): since we export this function, supress error warnings and don't reset the error code in the first half of this function. * gdk/gdk.c (gdk_x_error): set gdk_error_code to the actuall X error code (instead of just -1) so gdk_error_trap_pop() reveals something actually informative about the error that happened. * gdk/*.c: don't rely on gdk_error_code being -1 if an error occoured, but just gdk_error_code != 0. Thu Jun 24 11:50:07 1999 Tim Janik <timj@gtk.org> * gdk/gdkevents.c (gdk_event_apply_filters): advance the filter list pointer *before* invoking the filter function, so we at least don't crash if a filter is removed that is currently executed. window filters *really* need to be made truely reentrant at some point. Mon Jun 14 11:10:15 1999 Tim Janik <timj@gtk.org> * gdk/gdkevents.c (gdk_event_translate): print the atom name in the PropertyNotify debug messages. Wed May 5 22:51:06 1999 Owen Taylor <otaylor@redhat.com> Patch from Sung-Hyun Nam <namsh@lgic.co.kr> * gdk/gdkim.c: Fix cut-and-paste errors for x/y and PreeditAttributes/StatusAttributes. Wed May 5 22:24:21 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.c (gdk_window_set_geometry_hints): Change G_MAXINT to 2^16 to alleviate overflow problems in various window managers. Wed Apr 21 00:42:08 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkfont.c (gdk_text_measure): Fix the return value for fontsets. Wed May 5 12:42:01 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.c (gdk_window_set_geometry_hints): Initialize size_hints.x and size_hints.y because kwm brokenly pays attention to them. (Bug #1181 - Lars Heete <hel@admin.de>) Wed May 5 11:38:56 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkrgb.c (gdk_rgb_choose_visual): Free the return value of gdk_list_visuals(). (Bug #1193 - Morten Welinder <terra@diku.dk>) Tue May 4 11:12:56 PDT 1999 Manish Singh <yosh@gimp.org> * gdk/gdkim.c (gdk_im_real_open): cast the return value of XSetIMValues to (void *) when comparing to NULL, to workaround the problem of some compilers barfing since older X headers don't have the prototype for it. Mon Apr 19 10:11:12 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkcolor.c (gdk_colormap_new): Fix memory leak for pseudocolor where colormap->colors was double allocated. * gdk/gdkcolor.c (gdk_colormap_alloc1): Store the color value in the hash table with the pixel filled in so when we do later hash table lookups, the color value is correct. Sun May 2 15:29:45 PDT 1999 Manish Singh <yosh@gimp.org> * gdk/gdkdraw.c (gdk_draw_lines): check private->destroyed before making the call Tue Apr 27 11:17:35 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkdnd.c (xdnd_set_{targets,actions}): Fix leak pointed out by Morten Welinder <terra@diku.dk>. Wed Apr 21 14:20:22 1999 George Lebl <jirka@5z.com> * gdk/gdkwindow.c: (gdk_window_remove_filter) correctly remove the default filter from the list Wed Apr 21 14:20:22 1999 George Lebl <jirka@5z.com> * gdk/gdkwindow.c: (gdk_window_remove_filter) correctly remove the default filter from the list Fri Apr 16 20:41:43 PDT 1999 Manish Singh <yosh@gimp.org> * gdk/gdk.c: #include "gdkkeysyms.h" for gdk_XConvertCase #defines * gtk/gtkfontsel.c (gtk_font_selection_create_xlfd): use g_strdup_printf instead of calcing the length separately Tue Apr 13 02:49:33 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.c: removed some silly #ifdef HAVE_CONFIG that we don't do in many other places. (Fixing duplicate #include of config.h) * gdk/gdkevents.c: include gdkinput.h _after_ config.h. Otherwise, #ifndef XINPUT_NONE check in the latter doesn't work. (Bug #546) Sun Apr 11 14:38:03 1999 Tim Janik <timj@gtk.org> * gdk/gdkpixmap.c (_gdk_pixmap_create_from_xpm): check for color "None" case insensitive. Tue Apr 6 16:38:51 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkselection.c: Add error traps so if the other end of the connection dies, we survive. Tue Apr 6 12:24:21 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkdnd.c (gdk_drag_motion): Separate out the dest_xid field into two fields - one for the window to send in messages, one to indicate the last looked up window for caching purposes. This is needed, so that Leave messages get the correct window. Mon Apr 5 13:21:30 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkevents.c (gdk_event_check, gdk_event_prepare): Fix warning created by people mucking around with the gsource API. * gdk/gdkevents.c (gdk_io_invoke, gdk_input_add_full): Change mapping between GIOCondition and GdkInputCondition to match the way the Linux kernel does it. This should fix problems where closed pipes were no longer signalling GDK_INPUT_READ on systems with a native poll(). Mon Apr 5 17:11:57 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkpixmap.c (_gdk_pixmap_create_from_xpm): Check explicitly for the string "None" - it is in the XPM spec and some servers treat unknown colors in odd ways (like asking the user!) Thu Apr 1 16:58:10 PST 1999 Manish Singh <yosh@gimp.org> * gdk/gdkevents.c: made "->" into a "." of previous change so it compiles Thu Apr 1 18:41:25 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkevents.c (gdk_compress_exposures): Set the window field of the event structure before calling user filters. 1999-03-31 Federico Mena Quintero <federico@nuclecu.unam.mx> * gdk/gdk.c (gdk_init_check): Use False as the last argument to XInternAtom() here. This is a particularly Old And Nasty(tm) bug. Mon Mar 29 17:31:52 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkim.c (gdk_mbstowcs): Free the value of the intermediate text property - prevents major memory leak when gdk_use_mb. gtk-d3august-990311-0: Bj|rn Augustsson <d3august@dtek.chalmers.se> Mon Mar 29 17:02:58 1999 Owen Taylor <otaylor@redhat.com> Patches from Akira Higuchi <a-higuti@math.sci.hokudai.ac.jp> gtk-a-higuti-990322-[0-3] * gdk/gdkfont.c (gdk_text_extents_wc): Make work when sizeof(wchar_t) != sizeof (GdkWChar) * configure.in: Fix confusion between GTK_LOCALE_[C]FLAGS that was causing -DX_LOCALE not to work. * gtk/gtkrc.c (gtk_rc_init): X_LOCALE will never have LC_MESSAGES defined * gdk/gdk.c (gdk_init_check): Remove --xim-preedit and --xim-status from argv properly. * gdk/gdkim.c (gdk_ic_real_new): Add a gdk_flush() so that the client window is present on the X server before we pass it to the input method. Tue Mar 9 10:46:49 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkdnd.c (motif_find_drag_window): Fix bug where if --display is specified on the command line, than the drag window will not be created on that display. Tue Mar 9 10:38:24 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkproperty.c (gdk_atom_intern): Fixed bug where lookups with only_if_exists == TRUE were inserting bogus values into the atom cache. Wed Mar 17 09:00:00 1999 Tim Janik <timj@gtk.org> * gdk/gdkselection.c (gdk_selection_property_get): first XFree(t), then reset it to NULL. * gdk/gdkcolor.c: (gdk_colors_free): (gdk_colormap_free_colors): use colormap->colors[in_pixels[i]] as the key for g_hash_table_remove() in both functions, this prevents us from accessing possibly uninitialized portions of a GdkColor structure where we are only interested in its pixel value. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. 1999-09-21 Tor Lillqvist <tml@iki.fi>
1424 lines
34 KiB
C
1424 lines
34 KiB
C
/* GDK - The GIMP Drawing Kit
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/*
|
|
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
* files for a list of changes. These files are distributed with
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <limits.h>
|
|
#include <errno.h>
|
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
#include <sys/select.h>
|
|
#endif /* HAVE_SYS_SELECT_H_ */
|
|
|
|
#define XLIB_ILLEGAL_ACCESS
|
|
#include <X11/Xatom.h>
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xos.h>
|
|
#include <X11/Xutil.h>
|
|
#include <X11/Xmu/WinUtil.h>
|
|
#include <X11/cursorfont.h>
|
|
#include "gdk.h"
|
|
#include "gdkprivate.h"
|
|
#include "gdkinput.h"
|
|
#include "gdkx.h"
|
|
#include "gdki18n.h"
|
|
#include "gdkkeysyms.h"
|
|
|
|
#ifndef X_GETTIMEOFDAY
|
|
#define X_GETTIMEOFDAY(tv) gettimeofday (tv, NULL)
|
|
#endif /* X_GETTIMEOFDAY */
|
|
|
|
|
|
typedef struct _GdkPredicate GdkPredicate;
|
|
typedef struct _GdkErrorTrap GdkErrorTrap;
|
|
|
|
struct _GdkPredicate
|
|
{
|
|
GdkEventFunc func;
|
|
gpointer data;
|
|
};
|
|
|
|
struct _GdkErrorTrap
|
|
{
|
|
gint error_warnings;
|
|
gint error_code;
|
|
};
|
|
|
|
/*
|
|
* Private function declarations
|
|
*/
|
|
|
|
#ifndef HAVE_XCONVERTCASE
|
|
static void gdkx_XConvertCase (KeySym symbol,
|
|
KeySym *lower,
|
|
KeySym *upper);
|
|
#define XConvertCase gdkx_XConvertCase
|
|
#endif
|
|
|
|
static void gdk_exit_func (void);
|
|
static int gdk_x_error (Display *display,
|
|
XErrorEvent *error);
|
|
static int gdk_x_io_error (Display *display);
|
|
|
|
GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
|
|
GdkEvent *event,
|
|
gpointer data);
|
|
|
|
/* Private variable declarations
|
|
*/
|
|
static int gdk_initialized = 0; /* 1 if the library is initialized,
|
|
* 0 otherwise.
|
|
*/
|
|
|
|
static struct timeval start; /* The time at which the library was
|
|
* last initialized.
|
|
*/
|
|
static struct timeval timer; /* Timeout interval to use in the call
|
|
* to "select". This is used in
|
|
* conjunction with "timerp" to create
|
|
* a maximum time to wait for an event
|
|
* to arrive.
|
|
*/
|
|
static struct timeval *timerp; /* The actual timer passed to "select"
|
|
* This may be NULL, in which case
|
|
* "select" will block until an event
|
|
* arrives.
|
|
*/
|
|
static guint32 timer_val; /* The timeout length as specified by
|
|
* the user in milliseconds.
|
|
*/
|
|
static gint autorepeat;
|
|
|
|
static GSList *gdk_error_traps = NULL; /* List of error traps */
|
|
static GSList *gdk_error_trap_free_list = NULL; /* Free list */
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
static const GDebugKey gdk_debug_keys[] = {
|
|
{"events", GDK_DEBUG_EVENTS},
|
|
{"misc", GDK_DEBUG_MISC},
|
|
{"dnd", GDK_DEBUG_DND},
|
|
{"color-context", GDK_DEBUG_COLOR_CONTEXT},
|
|
{"xim", GDK_DEBUG_XIM}
|
|
};
|
|
|
|
static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
|
|
|
|
#endif /* G_ENABLE_DEBUG */
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_init_heck
|
|
*
|
|
* Initialize the library for use.
|
|
*
|
|
* Arguments:
|
|
* "argc" is the number of arguments.
|
|
* "argv" is an array of strings.
|
|
*
|
|
* Results:
|
|
* "argc" and "argv" are modified to reflect any arguments
|
|
* which were not handled. (Such arguments should either
|
|
* be handled by the application or dismissed). If initialization
|
|
* fails, returns FALSE, otherwise TRUE.
|
|
*
|
|
* Side effects:
|
|
* The library is initialized.
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gboolean
|
|
gdk_init_check (int *argc,
|
|
char ***argv)
|
|
{
|
|
XKeyboardState keyboard_state;
|
|
gint synchronize;
|
|
gint i, j, k;
|
|
XClassHint *class_hint;
|
|
gchar **argv_orig = NULL;
|
|
gint argc_orig = 0;
|
|
|
|
if (gdk_initialized)
|
|
return TRUE;
|
|
|
|
if (g_thread_supported ())
|
|
gdk_threads_mutex = g_mutex_new ();
|
|
|
|
if (argc && argv)
|
|
{
|
|
argc_orig = *argc;
|
|
|
|
argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
|
|
for (i = 0; i < argc_orig; i++)
|
|
argv_orig[i] = g_strdup ((*argv)[i]);
|
|
argv_orig[argc_orig] = NULL;
|
|
}
|
|
|
|
X_GETTIMEOFDAY (&start);
|
|
|
|
gdk_display_name = NULL;
|
|
|
|
XSetErrorHandler (gdk_x_error);
|
|
XSetIOErrorHandler (gdk_x_io_error);
|
|
|
|
synchronize = FALSE;
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
{
|
|
gchar *debug_string = getenv("GDK_DEBUG");
|
|
if (debug_string != NULL)
|
|
gdk_debug_flags = g_parse_debug_string (debug_string,
|
|
(GDebugKey *) gdk_debug_keys,
|
|
gdk_ndebug_keys);
|
|
}
|
|
#endif /* G_ENABLE_DEBUG */
|
|
|
|
if (argc && argv)
|
|
{
|
|
if (*argc > 0)
|
|
{
|
|
gchar *d;
|
|
|
|
d = strrchr((*argv)[0],'/');
|
|
if (d != NULL)
|
|
g_set_prgname (d + 1);
|
|
else
|
|
g_set_prgname ((*argv)[0]);
|
|
}
|
|
|
|
for (i = 1; i < *argc;)
|
|
{
|
|
#ifdef G_ENABLE_DEBUG
|
|
if ((strcmp ("--gdk-debug", (*argv)[i]) == 0) ||
|
|
(strncmp ("--gdk-debug=", (*argv)[i], 12) == 0))
|
|
{
|
|
gchar *equal_pos = strchr ((*argv)[i], '=');
|
|
|
|
if (equal_pos != NULL)
|
|
{
|
|
gdk_debug_flags |= g_parse_debug_string (equal_pos+1,
|
|
(GDebugKey *) gdk_debug_keys,
|
|
gdk_ndebug_keys);
|
|
}
|
|
else if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
|
|
(GDebugKey *) gdk_debug_keys,
|
|
gdk_ndebug_keys);
|
|
(*argv)[i] = NULL;
|
|
i += 1;
|
|
}
|
|
(*argv)[i] = NULL;
|
|
}
|
|
else if ((strcmp ("--gdk-no-debug", (*argv)[i]) == 0) ||
|
|
(strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0))
|
|
{
|
|
gchar *equal_pos = strchr ((*argv)[i], '=');
|
|
|
|
if (equal_pos != NULL)
|
|
{
|
|
gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1,
|
|
(GDebugKey *) gdk_debug_keys,
|
|
gdk_ndebug_keys);
|
|
}
|
|
else if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
|
|
(GDebugKey *) gdk_debug_keys,
|
|
gdk_ndebug_keys);
|
|
(*argv)[i] = NULL;
|
|
i += 1;
|
|
}
|
|
(*argv)[i] = NULL;
|
|
}
|
|
else
|
|
#endif /* G_ENABLE_DEBUG */
|
|
if (strcmp ("--display", (*argv)[i]) == 0)
|
|
{
|
|
(*argv)[i] = NULL;
|
|
|
|
if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
gdk_display_name = g_strdup ((*argv)[i + 1]);
|
|
(*argv)[i + 1] = NULL;
|
|
i += 1;
|
|
}
|
|
}
|
|
else if (strcmp ("--sync", (*argv)[i]) == 0)
|
|
{
|
|
(*argv)[i] = NULL;
|
|
synchronize = TRUE;
|
|
}
|
|
else if (strcmp ("--no-xshm", (*argv)[i]) == 0)
|
|
{
|
|
(*argv)[i] = NULL;
|
|
gdk_use_xshm = FALSE;
|
|
}
|
|
else if (strcmp ("--name", (*argv)[i]) == 0)
|
|
{
|
|
if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
(*argv)[i++] = NULL;
|
|
g_set_prgname ((*argv)[i]);
|
|
(*argv)[i] = NULL;
|
|
}
|
|
}
|
|
else if (strcmp ("--class", (*argv)[i]) == 0)
|
|
{
|
|
if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
(*argv)[i++] = NULL;
|
|
gdk_progclass = (*argv)[i];
|
|
(*argv)[i] = NULL;
|
|
}
|
|
}
|
|
#ifdef XINPUT_GXI
|
|
else if (strcmp ("--gxid_host", (*argv)[i]) == 0)
|
|
{
|
|
if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
(*argv)[i++] = NULL;
|
|
gdk_input_gxid_host = ((*argv)[i]);
|
|
(*argv)[i] = NULL;
|
|
}
|
|
}
|
|
else if (strcmp ("--gxid_port", (*argv)[i]) == 0)
|
|
{
|
|
if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
(*argv)[i++] = NULL;
|
|
gdk_input_gxid_port = atoi ((*argv)[i]);
|
|
(*argv)[i] = NULL;
|
|
}
|
|
}
|
|
#endif
|
|
#ifdef USE_XIM
|
|
else if (strcmp ("--xim-preedit", (*argv)[i]) == 0)
|
|
{
|
|
if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
(*argv)[i++] = NULL;
|
|
if (strcmp ("none", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
|
|
else if (strcmp ("nothing", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
|
|
else if (strcmp ("area", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
|
|
else if (strcmp ("position", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
|
|
else if (strcmp ("callbacks", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
|
|
(*argv)[i] = NULL;
|
|
}
|
|
}
|
|
else if (strcmp ("--xim-status", (*argv)[i]) == 0)
|
|
{
|
|
if ((i + 1) < *argc && (*argv)[i + 1])
|
|
{
|
|
(*argv)[i++] = NULL;
|
|
if (strcmp ("none", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_STATUS_NONE);
|
|
else if (strcmp ("nothing", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
|
|
else if (strcmp ("area", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_STATUS_AREA);
|
|
else if (strcmp ("callbacks", (*argv)[i]) == 0)
|
|
gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
|
|
(*argv)[i] = NULL;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
i += 1;
|
|
}
|
|
|
|
for (i = 1; i < *argc; i++)
|
|
{
|
|
for (k = i; k < *argc; k++)
|
|
if ((*argv)[k] != NULL)
|
|
break;
|
|
|
|
if (k > i)
|
|
{
|
|
k -= i;
|
|
for (j = i + k; j < *argc; j++)
|
|
(*argv)[j-k] = (*argv)[j];
|
|
*argc -= k;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
g_set_prgname ("<unknown>");
|
|
}
|
|
|
|
GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
|
|
|
|
gdk_display = XOpenDisplay (gdk_display_name);
|
|
if (!gdk_display)
|
|
return FALSE;
|
|
|
|
if (synchronize)
|
|
XSynchronize (gdk_display, True);
|
|
|
|
gdk_screen = DefaultScreen (gdk_display);
|
|
gdk_root_window = RootWindow (gdk_display, gdk_screen);
|
|
|
|
gdk_leader_window = XCreateSimpleWindow(gdk_display, gdk_root_window,
|
|
10, 10, 10, 10, 0, 0 , 0);
|
|
class_hint = XAllocClassHint();
|
|
class_hint->res_name = g_get_prgname ();
|
|
if (gdk_progclass == NULL)
|
|
{
|
|
gdk_progclass = g_strdup (g_get_prgname ());
|
|
gdk_progclass[0] = toupper (gdk_progclass[0]);
|
|
}
|
|
class_hint->res_class = gdk_progclass;
|
|
XmbSetWMProperties (gdk_display, gdk_leader_window,
|
|
NULL, NULL, argv_orig, argc_orig,
|
|
NULL, NULL, class_hint);
|
|
XFree (class_hint);
|
|
|
|
for (i = 0; i < argc_orig; i++)
|
|
g_free(argv_orig[i]);
|
|
g_free(argv_orig);
|
|
|
|
gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
|
|
gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
|
|
gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
|
|
gdk_wm_window_protocols[0] = gdk_wm_delete_window;
|
|
gdk_wm_window_protocols[1] = gdk_wm_take_focus;
|
|
gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False);
|
|
|
|
XGetKeyboardControl (gdk_display, &keyboard_state);
|
|
autorepeat = keyboard_state.global_auto_repeat;
|
|
|
|
timer.tv_sec = 0;
|
|
timer.tv_usec = 0;
|
|
timerp = NULL;
|
|
|
|
g_atexit (gdk_exit_func);
|
|
|
|
gdk_events_init ();
|
|
gdk_visual_init ();
|
|
gdk_window_init ();
|
|
gdk_image_init ();
|
|
gdk_input_init ();
|
|
gdk_dnd_init ();
|
|
|
|
#ifdef USE_XIM
|
|
gdk_im_open ();
|
|
#endif
|
|
|
|
gdk_initialized = 1;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
gdk_init (int *argc, char ***argv)
|
|
{
|
|
if (!gdk_init_check (argc, argv))
|
|
{
|
|
g_warning ("cannot open display: %s", gdk_get_display ());
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_exit
|
|
*
|
|
* Restores the library to an un-itialized state and exits
|
|
* the program using the "exit" system call.
|
|
*
|
|
* Arguments:
|
|
* "errorcode" is the error value to pass to "exit".
|
|
*
|
|
* Results:
|
|
* Allocated structures are freed and the program exits
|
|
* cleanly.
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
void
|
|
gdk_exit (gint errorcode)
|
|
{
|
|
/* de-initialisation is done by the gdk_exit_funct(),
|
|
no need to do this here (Alex J.) */
|
|
exit (errorcode);
|
|
}
|
|
|
|
void
|
|
gdk_set_use_xshm (gint use_xshm)
|
|
{
|
|
gdk_use_xshm = use_xshm;
|
|
}
|
|
|
|
gint
|
|
gdk_get_use_xshm (void)
|
|
{
|
|
return gdk_use_xshm;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_time_get
|
|
*
|
|
* Get the number of milliseconds since the library was
|
|
* initialized.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
* The time since the library was initialized is returned.
|
|
* This time value is accurate to milliseconds even though
|
|
* a more accurate time down to the microsecond could be
|
|
* returned.
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
guint32
|
|
gdk_time_get (void)
|
|
{
|
|
struct timeval end;
|
|
struct timeval elapsed;
|
|
guint32 milliseconds;
|
|
|
|
X_GETTIMEOFDAY (&end);
|
|
|
|
if (start.tv_usec > end.tv_usec)
|
|
{
|
|
end.tv_usec += 1000000;
|
|
end.tv_sec--;
|
|
}
|
|
elapsed.tv_sec = end.tv_sec - start.tv_sec;
|
|
elapsed.tv_usec = end.tv_usec - start.tv_usec;
|
|
|
|
milliseconds = (elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000);
|
|
|
|
return milliseconds;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_timer_get
|
|
*
|
|
* Returns the current timer.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
* Returns the current timer interval. This interval is
|
|
* in units of milliseconds.
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
guint32
|
|
gdk_timer_get (void)
|
|
{
|
|
return timer_val;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_timer_set
|
|
*
|
|
* Sets the timer interval.
|
|
*
|
|
* Arguments:
|
|
* "milliseconds" is the new value for the timer.
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
* Calls to "gdk_event_get" will last for a maximum
|
|
* of time of "milliseconds". However, a value of 0
|
|
* milliseconds will cause "gdk_event_get" to block
|
|
* indefinately until an event is received.
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
void
|
|
gdk_timer_set (guint32 milliseconds)
|
|
{
|
|
timer_val = milliseconds;
|
|
timer.tv_sec = milliseconds / 1000;
|
|
timer.tv_usec = (milliseconds % 1000) * 1000;
|
|
|
|
}
|
|
|
|
void
|
|
gdk_timer_enable (void)
|
|
{
|
|
timerp = &timer;
|
|
}
|
|
|
|
void
|
|
gdk_timer_disable (void)
|
|
{
|
|
timerp = NULL;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_pointer_grab
|
|
*
|
|
* Grabs the pointer to a specific window
|
|
*
|
|
* Arguments:
|
|
* "window" is the window which will receive the grab
|
|
* "owner_events" specifies whether events will be reported as is,
|
|
* or relative to "window"
|
|
* "event_mask" masks only interesting events
|
|
* "confine_to" limits the cursor movement to the specified window
|
|
* "cursor" changes the cursor for the duration of the grab
|
|
* "time" specifies the time
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
* requires a corresponding call to gdk_pointer_ungrab
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_pointer_grab (GdkWindow * window,
|
|
gint owner_events,
|
|
GdkEventMask event_mask,
|
|
GdkWindow * confine_to,
|
|
GdkCursor * cursor,
|
|
guint32 time)
|
|
{
|
|
/* From gdkwindow.c */
|
|
gint return_val;
|
|
GdkWindowPrivate *window_private;
|
|
GdkWindowPrivate *confine_to_private;
|
|
GdkCursorPrivate *cursor_private;
|
|
guint xevent_mask;
|
|
Window xwindow;
|
|
Window xconfine_to;
|
|
Cursor xcursor;
|
|
int i;
|
|
|
|
g_return_val_if_fail (window != NULL, 0);
|
|
|
|
window_private = (GdkWindowPrivate*) window;
|
|
confine_to_private = (GdkWindowPrivate*) confine_to;
|
|
cursor_private = (GdkCursorPrivate*) cursor;
|
|
|
|
xwindow = window_private->xwindow;
|
|
|
|
if (!confine_to || confine_to_private->destroyed)
|
|
xconfine_to = None;
|
|
else
|
|
xconfine_to = confine_to_private->xwindow;
|
|
|
|
if (!cursor)
|
|
xcursor = None;
|
|
else
|
|
xcursor = cursor_private->xcursor;
|
|
|
|
|
|
xevent_mask = 0;
|
|
for (i = 0; i < gdk_nevent_masks; i++)
|
|
{
|
|
if (event_mask & (1 << (i + 1)))
|
|
xevent_mask |= gdk_event_mask_table[i];
|
|
}
|
|
|
|
if (gdk_input_vtable.grab_pointer)
|
|
return_val = gdk_input_vtable.grab_pointer (window,
|
|
owner_events,
|
|
event_mask,
|
|
confine_to,
|
|
time);
|
|
else
|
|
return_val = Success;
|
|
|
|
if (return_val == Success)
|
|
{
|
|
if (!window_private->destroyed)
|
|
return_val = XGrabPointer (window_private->xdisplay,
|
|
xwindow,
|
|
owner_events,
|
|
xevent_mask,
|
|
GrabModeAsync, GrabModeAsync,
|
|
xconfine_to,
|
|
xcursor,
|
|
time);
|
|
else
|
|
return_val = AlreadyGrabbed;
|
|
}
|
|
|
|
if (return_val == GrabSuccess)
|
|
gdk_xgrab_window = window_private;
|
|
|
|
return return_val;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_pointer_ungrab
|
|
*
|
|
* Releases any pointer grab
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
void
|
|
gdk_pointer_ungrab (guint32 time)
|
|
{
|
|
if (gdk_input_vtable.ungrab_pointer)
|
|
gdk_input_vtable.ungrab_pointer (time);
|
|
|
|
XUngrabPointer (gdk_display, time);
|
|
gdk_xgrab_window = NULL;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_pointer_is_grabbed
|
|
*
|
|
* Tell wether there is an active x pointer grab in effect
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_pointer_is_grabbed (void)
|
|
{
|
|
return gdk_xgrab_window != NULL;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_keyboard_grab
|
|
*
|
|
* Grabs the keyboard to a specific window
|
|
*
|
|
* Arguments:
|
|
* "window" is the window which will receive the grab
|
|
* "owner_events" specifies whether events will be reported as is,
|
|
* or relative to "window"
|
|
* "time" specifies the time
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
* requires a corresponding call to gdk_keyboard_ungrab
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_keyboard_grab (GdkWindow * window,
|
|
gint owner_events,
|
|
guint32 time)
|
|
{
|
|
GdkWindowPrivate *window_private;
|
|
Window xwindow;
|
|
|
|
g_return_val_if_fail (window != NULL, 0);
|
|
|
|
window_private = (GdkWindowPrivate*) window;
|
|
xwindow = window_private->xwindow;
|
|
|
|
if (!window_private->destroyed)
|
|
return XGrabKeyboard (window_private->xdisplay,
|
|
xwindow,
|
|
owner_events,
|
|
GrabModeAsync, GrabModeAsync,
|
|
time);
|
|
else
|
|
return AlreadyGrabbed;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_keyboard_ungrab
|
|
*
|
|
* Releases any keyboard grab
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
void
|
|
gdk_keyboard_ungrab (guint32 time)
|
|
{
|
|
XUngrabKeyboard (gdk_display, time);
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_width
|
|
*
|
|
* Return the width of the screen.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_width (void)
|
|
{
|
|
gint return_val;
|
|
|
|
return_val = DisplayWidth (gdk_display, gdk_screen);
|
|
|
|
return return_val;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_height
|
|
*
|
|
* Return the height of the screen.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_height (void)
|
|
{
|
|
gint return_val;
|
|
|
|
return_val = DisplayHeight (gdk_display, gdk_screen);
|
|
|
|
return return_val;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_width_mm
|
|
*
|
|
* Return the width of the screen in millimeters.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_width_mm (void)
|
|
{
|
|
gint return_val;
|
|
|
|
return_val = DisplayWidthMM (gdk_display, gdk_screen);
|
|
|
|
return return_val;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_height
|
|
*
|
|
* Return the height of the screen in millimeters.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_height_mm (void)
|
|
{
|
|
gint return_val;
|
|
|
|
return_val = DisplayHeightMM (gdk_display, gdk_screen);
|
|
|
|
return return_val;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_set_sm_client_id
|
|
*
|
|
* Set the SM_CLIENT_ID property on the WM_CLIENT_LEADER window
|
|
* so that the window manager can save our state using the
|
|
* X11R6 ICCCM session management protocol. A NULL value should
|
|
* be set following disconnection from the session manager to
|
|
* remove the SM_CLIENT_ID property.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* "sm_client_id" specifies the client id assigned to us by the
|
|
* session manager or NULL to remove the property.
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
void
|
|
gdk_set_sm_client_id (const gchar* sm_client_id)
|
|
{
|
|
if (sm_client_id && strcmp (sm_client_id, ""))
|
|
{
|
|
XChangeProperty (gdk_display, gdk_leader_window,
|
|
gdk_atom_intern ("SM_CLIENT_ID", FALSE),
|
|
XA_STRING, 8, PropModeReplace,
|
|
sm_client_id, strlen(sm_client_id));
|
|
}
|
|
else
|
|
XDeleteProperty (gdk_display, gdk_leader_window,
|
|
gdk_atom_intern ("SM_CLIENT_ID", FALSE));
|
|
}
|
|
|
|
void
|
|
gdk_key_repeat_disable (void)
|
|
{
|
|
XAutoRepeatOff (gdk_display);
|
|
}
|
|
|
|
void
|
|
gdk_key_repeat_restore (void)
|
|
{
|
|
if (autorepeat)
|
|
XAutoRepeatOn (gdk_display);
|
|
else
|
|
XAutoRepeatOff (gdk_display);
|
|
}
|
|
|
|
|
|
void
|
|
gdk_beep (void)
|
|
{
|
|
XBell(gdk_display, 100);
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_exit_func
|
|
*
|
|
* This is the "atexit" function that makes sure the
|
|
* library gets a chance to cleanup.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
* The library is un-initialized and the program exits.
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
static void
|
|
gdk_exit_func (void)
|
|
{
|
|
static gboolean in_gdk_exit_func = FALSE;
|
|
|
|
/* This is to avoid an infinite loop if a program segfaults in
|
|
an atexit() handler (and yes, it does happen, especially if a program
|
|
has trounced over memory too badly for even g_message to work) */
|
|
if (in_gdk_exit_func == TRUE)
|
|
return;
|
|
in_gdk_exit_func = TRUE;
|
|
|
|
if (gdk_initialized)
|
|
{
|
|
#ifdef USE_XIM
|
|
/* cleanup IC */
|
|
gdk_ic_cleanup ();
|
|
/* close IM */
|
|
gdk_im_close ();
|
|
#endif
|
|
gdk_image_exit ();
|
|
gdk_input_exit ();
|
|
gdk_key_repeat_restore ();
|
|
|
|
XCloseDisplay (gdk_display);
|
|
gdk_initialized = 0;
|
|
}
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_x_error
|
|
*
|
|
* The X error handling routine.
|
|
*
|
|
* Arguments:
|
|
* "display" is the X display the error orignated from.
|
|
* "error" is the XErrorEvent that we are handling.
|
|
*
|
|
* Results:
|
|
* Either we were expecting some sort of error to occur,
|
|
* in which case we set the "gdk_error_code" flag, or this
|
|
* error was unexpected, in which case we will print an
|
|
* error message and exit. (Since trying to continue will
|
|
* most likely simply lead to more errors).
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
static int
|
|
gdk_x_error (Display *display,
|
|
XErrorEvent *error)
|
|
{
|
|
if (error->error_code)
|
|
{
|
|
if (gdk_error_warnings)
|
|
{
|
|
char buf[64];
|
|
|
|
XGetErrorText (display, error->error_code, buf, 63);
|
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
g_error ("%s\n serial %ld error_code %d request_code %d minor_code %d\n",
|
|
buf,
|
|
error->serial,
|
|
error->error_code,
|
|
error->request_code,
|
|
error->minor_code);
|
|
#else /* !G_ENABLE_DEBUG */
|
|
fprintf (stderr, "Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
|
|
buf,
|
|
error->serial,
|
|
error->error_code,
|
|
error->request_code,
|
|
error->minor_code);
|
|
|
|
exit(1);
|
|
#endif /* G_ENABLE_DEBUG */
|
|
}
|
|
gdk_error_code = error->error_code;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_x_io_error
|
|
*
|
|
* The X I/O error handling routine.
|
|
*
|
|
* Arguments:
|
|
* "display" is the X display the error orignated from.
|
|
*
|
|
* Results:
|
|
* An X I/O error basically means we lost our connection
|
|
* to the X server. There is not much we can do to
|
|
* continue, so simply print an error message and exit.
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
static int
|
|
gdk_x_io_error (Display *display)
|
|
{
|
|
/* This is basically modelled after the code in XLib. We need
|
|
* an explicit error handler here, so we can disable our atexit()
|
|
* which would otherwise cause a nice segfault.
|
|
* We fprintf(stderr, instead of g_warning() because g_warning()
|
|
* could possibly be redirected to a dialog
|
|
*/
|
|
if (errno == EPIPE)
|
|
{
|
|
fprintf (stderr, "Gdk-ERROR **: X connection to %s broken (explicit kill or server shutdown).\n", gdk_display ? DisplayString (gdk_display) : gdk_get_display());
|
|
}
|
|
else
|
|
{
|
|
fprintf (stderr, "Gdk-ERROR **: Fatal IO error %d (%s) on X server %s.\n",
|
|
errno, g_strerror (errno),
|
|
gdk_display ? DisplayString (gdk_display) : gdk_get_display());
|
|
}
|
|
|
|
/* Disable the atexit shutdown for GDK */
|
|
gdk_initialized = 0;
|
|
|
|
exit(1);
|
|
}
|
|
|
|
gchar *
|
|
gdk_get_display (void)
|
|
{
|
|
return (gchar *)XDisplayName (gdk_display_name);
|
|
}
|
|
|
|
/*************************************************************
|
|
* gdk_error_trap_push:
|
|
* Push an error trap. X errors will be trapped until
|
|
* the corresponding gdk_error_pop(), which will return
|
|
* the error code, if any.
|
|
* arguments:
|
|
*
|
|
* results:
|
|
*************************************************************/
|
|
|
|
void
|
|
gdk_error_trap_push (void)
|
|
{
|
|
GSList *node;
|
|
GdkErrorTrap *trap;
|
|
|
|
if (gdk_error_trap_free_list)
|
|
{
|
|
node = gdk_error_trap_free_list;
|
|
gdk_error_trap_free_list = gdk_error_trap_free_list->next;
|
|
}
|
|
else
|
|
{
|
|
node = g_slist_alloc ();
|
|
node->data = g_new (GdkErrorTrap, 1);
|
|
}
|
|
|
|
node->next = gdk_error_traps;
|
|
gdk_error_traps = node;
|
|
|
|
trap = node->data;
|
|
trap->error_code = gdk_error_code;
|
|
trap->error_warnings = gdk_error_warnings;
|
|
|
|
gdk_error_code = 0;
|
|
gdk_error_warnings = 0;
|
|
}
|
|
|
|
/*************************************************************
|
|
* gdk_error_trap_pop:
|
|
* Pop an error trap added with gdk_error_push()
|
|
* arguments:
|
|
*
|
|
* results:
|
|
* 0, if no error occured, otherwise the error code.
|
|
*************************************************************/
|
|
|
|
gint
|
|
gdk_error_trap_pop (void)
|
|
{
|
|
GSList *node;
|
|
GdkErrorTrap *trap;
|
|
gint result;
|
|
|
|
g_return_val_if_fail (gdk_error_traps != NULL, 0);
|
|
|
|
node = gdk_error_traps;
|
|
gdk_error_traps = gdk_error_traps->next;
|
|
|
|
node->next = gdk_error_trap_free_list;
|
|
gdk_error_trap_free_list = node;
|
|
|
|
result = gdk_error_code;
|
|
|
|
trap = node->data;
|
|
gdk_error_code = trap->error_code;
|
|
gdk_error_warnings = trap->error_warnings;
|
|
|
|
return result;
|
|
}
|
|
|
|
gint
|
|
gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
|
|
XEvent *event_send)
|
|
{
|
|
Status result;
|
|
gint old_warnings = gdk_error_warnings;
|
|
|
|
gdk_error_code = 0;
|
|
|
|
gdk_error_warnings = 0;
|
|
result = XSendEvent (gdk_display, window, propagate, event_mask, event_send);
|
|
XSync (gdk_display, False);
|
|
gdk_error_warnings = old_warnings;
|
|
|
|
return result && !gdk_error_code;
|
|
}
|
|
|
|
#ifndef HAVE_XCONVERTCASE
|
|
/* compatibility function from X11R6.3, since XConvertCase is not
|
|
* supplied by X11R5.
|
|
*/
|
|
static void
|
|
gdkx_XConvertCase (KeySym symbol,
|
|
KeySym *lower,
|
|
KeySym *upper)
|
|
{
|
|
register KeySym sym = symbol;
|
|
|
|
g_return_if_fail (lower != NULL);
|
|
g_return_if_fail (upper != NULL);
|
|
|
|
*lower = sym;
|
|
*upper = sym;
|
|
|
|
switch (sym >> 8)
|
|
{
|
|
#if defined (GDK_A) && defined (GDK_Ooblique)
|
|
case 0: /* Latin 1 */
|
|
if ((sym >= GDK_A) && (sym <= GDK_Z))
|
|
*lower += (GDK_a - GDK_A);
|
|
else if ((sym >= GDK_a) && (sym <= GDK_z))
|
|
*upper -= (GDK_a - GDK_A);
|
|
else if ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis))
|
|
*lower += (GDK_agrave - GDK_Agrave);
|
|
else if ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis))
|
|
*upper -= (GDK_agrave - GDK_Agrave);
|
|
else if ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn))
|
|
*lower += (GDK_oslash - GDK_Ooblique);
|
|
else if ((sym >= GDK_oslash) && (sym <= GDK_thorn))
|
|
*upper -= (GDK_oslash - GDK_Ooblique);
|
|
break;
|
|
#endif /* LATIN1 */
|
|
|
|
#if defined (GDK_Aogonek) && defined (GDK_tcedilla)
|
|
case 1: /* Latin 2 */
|
|
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
|
if (sym == GDK_Aogonek)
|
|
*lower = GDK_aogonek;
|
|
else if (sym >= GDK_Lstroke && sym <= GDK_Sacute)
|
|
*lower += (GDK_lstroke - GDK_Lstroke);
|
|
else if (sym >= GDK_Scaron && sym <= GDK_Zacute)
|
|
*lower += (GDK_scaron - GDK_Scaron);
|
|
else if (sym >= GDK_Zcaron && sym <= GDK_Zabovedot)
|
|
*lower += (GDK_zcaron - GDK_Zcaron);
|
|
else if (sym == GDK_aogonek)
|
|
*upper = GDK_Aogonek;
|
|
else if (sym >= GDK_lstroke && sym <= GDK_sacute)
|
|
*upper -= (GDK_lstroke - GDK_Lstroke);
|
|
else if (sym >= GDK_scaron && sym <= GDK_zacute)
|
|
*upper -= (GDK_scaron - GDK_Scaron);
|
|
else if (sym >= GDK_zcaron && sym <= GDK_zabovedot)
|
|
*upper -= (GDK_zcaron - GDK_Zcaron);
|
|
else if (sym >= GDK_Racute && sym <= GDK_Tcedilla)
|
|
*lower += (GDK_racute - GDK_Racute);
|
|
else if (sym >= GDK_racute && sym <= GDK_tcedilla)
|
|
*upper -= (GDK_racute - GDK_Racute);
|
|
break;
|
|
#endif /* LATIN2 */
|
|
|
|
#if defined (GDK_Hstroke) && defined (GDK_Cabovedot)
|
|
case 2: /* Latin 3 */
|
|
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
|
if (sym >= GDK_Hstroke && sym <= GDK_Hcircumflex)
|
|
*lower += (GDK_hstroke - GDK_Hstroke);
|
|
else if (sym >= GDK_Gbreve && sym <= GDK_Jcircumflex)
|
|
*lower += (GDK_gbreve - GDK_Gbreve);
|
|
else if (sym >= GDK_hstroke && sym <= GDK_hcircumflex)
|
|
*upper -= (GDK_hstroke - GDK_Hstroke);
|
|
else if (sym >= GDK_gbreve && sym <= GDK_jcircumflex)
|
|
*upper -= (GDK_gbreve - GDK_Gbreve);
|
|
else if (sym >= GDK_Cabovedot && sym <= GDK_Scircumflex)
|
|
*lower += (GDK_cabovedot - GDK_Cabovedot);
|
|
else if (sym >= GDK_cabovedot && sym <= GDK_scircumflex)
|
|
*upper -= (GDK_cabovedot - GDK_Cabovedot);
|
|
break;
|
|
#endif /* LATIN3 */
|
|
|
|
#if defined (GDK_Rcedilla) && defined (GDK_Amacron)
|
|
case 3: /* Latin 4 */
|
|
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
|
if (sym >= GDK_Rcedilla && sym <= GDK_Tslash)
|
|
*lower += (GDK_rcedilla - GDK_Rcedilla);
|
|
else if (sym >= GDK_rcedilla && sym <= GDK_tslash)
|
|
*upper -= (GDK_rcedilla - GDK_Rcedilla);
|
|
else if (sym == GDK_ENG)
|
|
*lower = GDK_eng;
|
|
else if (sym == GDK_eng)
|
|
*upper = GDK_ENG;
|
|
else if (sym >= GDK_Amacron && sym <= GDK_Umacron)
|
|
*lower += (GDK_amacron - GDK_Amacron);
|
|
else if (sym >= GDK_amacron && sym <= GDK_umacron)
|
|
*upper -= (GDK_amacron - GDK_Amacron);
|
|
break;
|
|
#endif /* LATIN4 */
|
|
|
|
#if defined (GDK_Serbian_DJE) && defined (GDK_Cyrillic_yu)
|
|
case 6: /* Cyrillic */
|
|
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
|
if (sym >= GDK_Serbian_DJE && sym <= GDK_Serbian_DZE)
|
|
*lower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
|
|
else if (sym >= GDK_Serbian_dje && sym <= GDK_Serbian_dze)
|
|
*upper += (GDK_Serbian_DJE - GDK_Serbian_dje);
|
|
else if (sym >= GDK_Cyrillic_YU && sym <= GDK_Cyrillic_HARDSIGN)
|
|
*lower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
|
|
else if (sym >= GDK_Cyrillic_yu && sym <= GDK_Cyrillic_hardsign)
|
|
*upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
|
|
break;
|
|
#endif /* CYRILLIC */
|
|
|
|
#if defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma)
|
|
case 7: /* Greek */
|
|
/* Assume the KeySym is a legal value (ignore discontinuities) */
|
|
if (sym >= GDK_Greek_ALPHAaccent && sym <= GDK_Greek_OMEGAaccent)
|
|
*lower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
|
|
else if (sym >= GDK_Greek_alphaaccent && sym <= GDK_Greek_omegaaccent &&
|
|
sym != GDK_Greek_iotaaccentdieresis &&
|
|
sym != GDK_Greek_upsilonaccentdieresis)
|
|
*upper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
|
|
else if (sym >= GDK_Greek_ALPHA && sym <= GDK_Greek_OMEGA)
|
|
*lower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
|
|
else if (sym >= GDK_Greek_alpha && sym <= GDK_Greek_omega &&
|
|
sym != GDK_Greek_finalsmallsigma)
|
|
*upper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
|
|
break;
|
|
#endif /* GREEK */
|
|
}
|
|
}
|
|
#endif
|
|
|
|
gchar*
|
|
gdk_keyval_name (guint keyval)
|
|
{
|
|
return XKeysymToString (keyval);
|
|
}
|
|
|
|
guint
|
|
gdk_keyval_from_name (const gchar *keyval_name)
|
|
{
|
|
g_return_val_if_fail (keyval_name != NULL, 0);
|
|
|
|
return XStringToKeysym (keyval_name);
|
|
}
|
|
|
|
guint
|
|
gdk_keyval_to_upper (guint keyval)
|
|
{
|
|
if (keyval)
|
|
{
|
|
KeySym lower_val = 0;
|
|
KeySym upper_val = 0;
|
|
|
|
XConvertCase (keyval, &lower_val, &upper_val);
|
|
return upper_val;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
guint
|
|
gdk_keyval_to_lower (guint keyval)
|
|
{
|
|
if (keyval)
|
|
{
|
|
KeySym lower_val = 0;
|
|
KeySym upper_val = 0;
|
|
|
|
XConvertCase (keyval, &lower_val, &upper_val);
|
|
return lower_val;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
gboolean
|
|
gdk_keyval_is_upper (guint keyval)
|
|
{
|
|
if (keyval)
|
|
{
|
|
KeySym lower_val = 0;
|
|
KeySym upper_val = 0;
|
|
|
|
XConvertCase (keyval, &lower_val, &upper_val);
|
|
return upper_val == keyval;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
gboolean
|
|
gdk_keyval_is_lower (guint keyval)
|
|
{
|
|
if (keyval)
|
|
{
|
|
KeySym lower_val = 0;
|
|
KeySym upper_val = 0;
|
|
|
|
XConvertCase (keyval, &lower_val, &upper_val);
|
|
return lower_val == keyval;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
gdk_threads_enter ()
|
|
{
|
|
GDK_THREADS_ENTER ();
|
|
}
|
|
|
|
void
|
|
gdk_threads_leave ()
|
|
{
|
|
GDK_THREADS_LEAVE ();
|
|
}
|
|
|