diff options
author | Owen Taylor <owt1@cornell.edu> | 1998-02-19 06:21:27 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-02-19 06:21:27 +0000 |
commit | fc7e845c8f4d3eb4481f803eae3f9c7f8d75a1d9 (patch) | |
tree | 888ffee4d7f12e1ed7aabf29fe67d80de3849268 | |
parent | 3d4cc2f904cd5d0dd1acfa6938c5577264fab524 (diff) | |
download | gtk+-fc7e845c8f4d3eb4481f803eae3f9c7f8d75a1d9.tar.gz |
configure.in gdk/gdk.[ch] gdk/gdkcc.c gdk/gdkglobals.c
Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu>
* configure.in gdk/gdk.[ch] gdk/gdkcc.c
gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h
gdk/gdkvisual.c glib/configure.in glib/glib.h
glib/gutils.c gtk/Makefile.am gtk/gtkmain.c
gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt
New system for controlling debugging:
* --enable-debug=[no/yes/minimum]
* G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib
* G_NO_CHECK_CASTS to control cast checking
* G_ENABLE_DEBUG enables run time checking which controls:
Object tracing
Showing events
Miscellaneous g_print's in GDK
And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG
* debug_level and show_events are gone from GTK
See docs/debugging.txt for details.
And some fixups to the configure.in's so '-g' can be
overriden on the command line for --enable-debug
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 25 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 25 | ||||
-rw-r--r-- | configure.in | 18 | ||||
-rw-r--r-- | docs/debugging.txt | 83 | ||||
-rw-r--r-- | gdk/gdk.c | 317 | ||||
-rw-r--r-- | gdk/gdk.h | 1 | ||||
-rw-r--r-- | gdk/gdkcc.c | 52 | ||||
-rw-r--r-- | gdk/gdkglobals.c | 3 | ||||
-rw-r--r-- | gdk/gdkinputcommon.h | 20 | ||||
-rw-r--r-- | gdk/gdkprivate.h | 24 | ||||
-rw-r--r-- | gdk/gdkvisual.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkcc-x11.c | 52 | ||||
-rw-r--r-- | gdk/x11/gdkglobals-x11.c | 3 | ||||
-rw-r--r-- | gdk/x11/gdkinput-x11.c | 20 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 317 | ||||
-rw-r--r-- | gdk/x11/gdkvisual-x11.c | 2 | ||||
-rw-r--r-- | glib/configure.in | 17 | ||||
-rw-r--r-- | glib/glib.h | 62 | ||||
-rw-r--r-- | glib/gutils.c | 47 | ||||
-rw-r--r-- | gtk/Makefile.am | 1 | ||||
-rw-r--r-- | gtk/gtkmain.c | 50 | ||||
-rw-r--r-- | gtk/gtkobject.c | 84 | ||||
-rw-r--r-- | gtk/gtkobject.h | 11 |
28 files changed, 873 insertions, 488 deletions
@@ -1,3 +1,28 @@ +Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu> + + * configure.in gdk/gdk.[ch] gdk/gdkcc.c + gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h + gdk/gdkvisual.c glib/configure.in glib/glib.h + glib/gutils.c gtk/Makefile.am gtk/gtkmain.c + gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt + + New system for controlling debugging: + + * --enable-debug=[no/yes/minimum] + * G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib + * G_NO_CHECK_CASTS to control cast checking + * G_ENABLE_DEBUG enables run time checking which controls: + Object tracing + Showing events + Miscellaneous g_print's in GDK + And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG + * debug_level and show_events are gone from GTK + + See docs/debugging.txt for details. + + And some fixups to the configure.in's so '-g' can be + overriden on the command line for --enable-debug + Thu Feb 19 05:40:51 1998 Tim Janik <timj@gimp.org> * gtk/gtknotebook.h: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index d65c6f4744..1105e9493c 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,28 @@ +Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu> + + * configure.in gdk/gdk.[ch] gdk/gdkcc.c + gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h + gdk/gdkvisual.c glib/configure.in glib/glib.h + glib/gutils.c gtk/Makefile.am gtk/gtkmain.c + gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt + + New system for controlling debugging: + + * --enable-debug=[no/yes/minimum] + * G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib + * G_NO_CHECK_CASTS to control cast checking + * G_ENABLE_DEBUG enables run time checking which controls: + Object tracing + Showing events + Miscellaneous g_print's in GDK + And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG + * debug_level and show_events are gone from GTK + + See docs/debugging.txt for details. + + And some fixups to the configure.in's so '-g' can be + overriden on the command line for --enable-debug + Thu Feb 19 05:40:51 1998 Tim Janik <timj@gimp.org> * gtk/gtknotebook.h: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d65c6f4744..1105e9493c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,28 @@ +Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu> + + * configure.in gdk/gdk.[ch] gdk/gdkcc.c + gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h + gdk/gdkvisual.c glib/configure.in glib/glib.h + glib/gutils.c gtk/Makefile.am gtk/gtkmain.c + gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt + + New system for controlling debugging: + + * --enable-debug=[no/yes/minimum] + * G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib + * G_NO_CHECK_CASTS to control cast checking + * G_ENABLE_DEBUG enables run time checking which controls: + Object tracing + Showing events + Miscellaneous g_print's in GDK + And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG + * debug_level and show_events are gone from GTK + + See docs/debugging.txt for details. + + And some fixups to the configure.in's so '-g' can be + overriden on the command line for --enable-debug + Thu Feb 19 05:40:51 1998 Tim Janik <timj@gimp.org> * gtk/gtknotebook.h: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d65c6f4744..1105e9493c 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,28 @@ +Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu> + + * configure.in gdk/gdk.[ch] gdk/gdkcc.c + gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h + gdk/gdkvisual.c glib/configure.in glib/glib.h + glib/gutils.c gtk/Makefile.am gtk/gtkmain.c + gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt + + New system for controlling debugging: + + * --enable-debug=[no/yes/minimum] + * G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib + * G_NO_CHECK_CASTS to control cast checking + * G_ENABLE_DEBUG enables run time checking which controls: + Object tracing + Showing events + Miscellaneous g_print's in GDK + And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG + * debug_level and show_events are gone from GTK + + See docs/debugging.txt for details. + + And some fixups to the configure.in's so '-g' can be + overriden on the command line for --enable-debug + Thu Feb 19 05:40:51 1998 Tim Janik <timj@gimp.org> * gtk/gtknotebook.h: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d65c6f4744..1105e9493c 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,28 @@ +Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu> + + * configure.in gdk/gdk.[ch] gdk/gdkcc.c + gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h + gdk/gdkvisual.c glib/configure.in glib/glib.h + glib/gutils.c gtk/Makefile.am gtk/gtkmain.c + gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt + + New system for controlling debugging: + + * --enable-debug=[no/yes/minimum] + * G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib + * G_NO_CHECK_CASTS to control cast checking + * G_ENABLE_DEBUG enables run time checking which controls: + Object tracing + Showing events + Miscellaneous g_print's in GDK + And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG + * debug_level and show_events are gone from GTK + + See docs/debugging.txt for details. + + And some fixups to the configure.in's so '-g' can be + overriden on the command line for --enable-debug + Thu Feb 19 05:40:51 1998 Tim Janik <timj@gimp.org> * gtk/gtknotebook.h: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d65c6f4744..1105e9493c 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,28 @@ +Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu> + + * configure.in gdk/gdk.[ch] gdk/gdkcc.c + gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h + gdk/gdkvisual.c glib/configure.in glib/glib.h + glib/gutils.c gtk/Makefile.am gtk/gtkmain.c + gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt + + New system for controlling debugging: + + * --enable-debug=[no/yes/minimum] + * G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib + * G_NO_CHECK_CASTS to control cast checking + * G_ENABLE_DEBUG enables run time checking which controls: + Object tracing + Showing events + Miscellaneous g_print's in GDK + And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG + * debug_level and show_events are gone from GTK + + See docs/debugging.txt for details. + + And some fixups to the configure.in's so '-g' can be + overriden on the command line for --enable-debug + Thu Feb 19 05:40:51 1998 Tim Janik <timj@gimp.org> * gtk/gtknotebook.h: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d65c6f4744..1105e9493c 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,28 @@ +Thu Feb 19 01:11:48 1998 Owen Taylor <owt1@cornell.edu> + + * configure.in gdk/gdk.[ch] gdk/gdkcc.c + gdk/gdkglobals.c gdk/gdkinputcommon.h gdk/gdkprivate.h + gdk/gdkvisual.c glib/configure.in glib/glib.h + glib/gutils.c gtk/Makefile.am gtk/gtkmain.c + gtk/gtkobject.[ch] gtk/gtkdebug.h docs/debugging.txt + + New system for controlling debugging: + + * --enable-debug=[no/yes/minimum] + * G_DISABLE_ASSERT and G_DISABLE_CHECKS for glib + * G_NO_CHECK_CASTS to control cast checking + * G_ENABLE_DEBUG enables run time checking which controls: + Object tracing + Showing events + Miscellaneous g_print's in GDK + And is controlled by --gdk-debug/GDK_DEBUG, --gtk-debug/GTK_DEBUG + * debug_level and show_events are gone from GTK + + See docs/debugging.txt for details. + + And some fixups to the configure.in's so '-g' can be + overriden on the command line for --enable-debug + Thu Feb 19 05:40:51 1998 Tim Janik <timj@gimp.org> * gtk/gtknotebook.h: diff --git a/configure.in b/configure.in index 1d8f0be0f3..94572ef61c 100644 --- a/configure.in +++ b/configure.in @@ -35,22 +35,24 @@ AC_CANONICAL_HOST AC_ARG_ENABLE(shm, [ --enable-shm support shared memory if available [default=yes]], echo $enable_shm, enable_shm="yes") -AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]], -if test "x$enable_debug" = "xyes"; then - DEBUGFLAG="-g" -fi) +AC_ARG_ENABLE(debug, [ --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],,enable_debug=minimum) AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]], , enable_ansi=no) AC_ARG_ENABLE(xim, [ --enable-xim support XIM [default=yes]], echo $enable_xim, enable_xim="yes") AC_ARG_WITH(locale, [ --with-locale=LOCALE locale name you want to use ]) -AC_ARG_WITH(xinput, [ --with-xinput[=no/gxi/xfree] support XInput ]) +AC_ARG_WITH(xinput, [ --with-xinput=[no/gxi/xfree] support XInput ]) -if test -n "$DEBUGFLAG"; then - test "$cflags_set" = set || CFLAGS="$DEBUGFLAG" +if test "x$enable_debug" = "xyes"; then + test "$cflags_set" = set || CFLAGS="-g" + CFLAGS="$CFLAGS -DG_ENABLE_DEBUG" else - CFLAGS="$CFLAGS -DNDEBUG" + if test "x$enable_debug" = "xno"; then + CFLAGS="$CFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DGTK_NO_CHECK_CASTS" + else + CFLAGS="$CFLAGS -DGTK_NO_CHECK_CASTS" + fi fi # Build time sanity check... diff --git a/docs/debugging.txt b/docs/debugging.txt new file mode 100644 index 0000000000..1313fcc061 --- /dev/null +++ b/docs/debugging.txt @@ -0,0 +1,83 @@ +The GLIB, GDK, and GTK libraries have extensive support for +debugging the library and your programs. + +The amount of debugging being done can be determined both +at run time and compile time. + +COMPILE TIME OPTIONS +-------------------- + +At compile time, the amount of debugging support included is +determined by four macros: + +G_ENABLE_DEBUG + If set, enable support for runtime checking. + +G_DISABLE_ASSERT + If set, disable g_assert macros + +G_DISABLE_CHECKS + If set, disable the g_return_if_fail and g_return_val_if_fail macros + +GTK_NO_CHECK_CASTS + If set, don't check casts between different object types + + +Whether these macros are defined is controlled at configuration +time by the --enable-debug option. + +--enable-debug=minimum [default] + Enable only inexpensive sanity checking + sets GTK_NO_CHECK_CASTS + +--enable-debug=yes + Enable all debugging support + sets G_ENABLE_DEBUG + +--enable-debug=no (or --disable-debug) + Disable all debugging support (fastest) + sets G_DISABLE_ASSERT, G_DISABLE_CHECKS, and GTK_NO_CHECK_CASTS + + +RUN TIME OPTIONS +---------------- + +At run time, if GTK+ was compiled with debugging enabled, +different types of debugging information can be printed +out by setting the --gtk-debug and --gdk-debug command line +options, or the GTK_DEBUG and GDK_DEBUG environment +variables. (The command line options override the environment +variables) + +Each of these can either be the special value ALL, +or a sequence of ':' separated options. (Note, case is +significant) + +As noted below, some of these are useful in application +debugging, but most are only interested to those debugging +the libraries + + GTK_DEBUG + --------- + + Application relevant options: + + 'objects' - Trace the creation and destruction of objects, print + out a summary at program termination + + Options only interesting to library maintainers: + + GDK_DEBUG + --------- + + Application relevant options: + + 'events' - Show all events received by GTK + + Options only interesting to library maintainers: + + 'misc' - Miscellaneous information + 'dnd' - Information about drag-and-drop + 'color-context' - Information about the internal workings of + GdkColorContext + 'xim' - Information about X Input Method support @@ -17,8 +17,6 @@ */ #include "../config.h" -/* #define DEBUG_DND 1 */ /* Shouldn't be needed much these days */ - /* If you don't want to use gdk's signal handlers define this */ /* #define I_NEED_TO_ACTUALLY_DEBUG_MY_PROGRAMS 1 */ @@ -227,6 +225,15 @@ static GList *putback_events = NULL; static gulong base_id; static gint autorepeat; +#ifdef G_ENABLE_DEBUG +static 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} +}; +#endif /* G_ENABLE_DEBUG */ /* *-------------------------------------------------------------- @@ -260,6 +267,8 @@ gdk_init (int *argc, int argc_orig = *argc; char **argv_orig; + gboolean debug_set = FALSE; + argv_orig = malloc ((argc_orig + 1) * sizeof (char*)); for (i = 0; i < argc_orig; i++) argv_orig[i] = g_strdup ((*argv)[i]); @@ -291,49 +300,49 @@ gdk_init (int *argc, for (i = 1; i < *argc;) { - if (strcmp ("--display", (*argv)[i]) == 0) + if ((*argv)[i] == NULL) + continue; + +#ifdef G_ENABLE_DEBUG + if (strcmp ("--gdk-debug", (*argv)[i]) == 0) { (*argv)[i] = NULL; - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { - gdk_display_name = g_strdup ((*argv)[i + 1]); + gdk_debug_flags = g_parse_debug_string ((*argv)[i+1], + gdk_debug_keys, + sizeof(gdk_debug_keys) / sizeof(GDebugKey)); + debug_set = TRUE; (*argv)[i + 1] = NULL; i += 1; } } - else if (strcmp ("--sync", (*argv)[i]) == 0) +#endif G_ENABLE_DEBUG + else if (strcmp ("--display", (*argv)[i]) == 0) { (*argv)[i] = NULL; - synchronize = TRUE; - } - else if (strcmp ("--show-events", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - gdk_show_events = TRUE; + + if ((i + 1) < *argc && (*argv)[i + 1]) + { + gdk_display_name = g_strdup ((*argv)[i + 1]); + (*argv)[i + 1] = NULL; + i += 1; + } } - else if (strcmp ("--no-show-events", (*argv)[i]) == 0) + else if (strcmp ("--sync", (*argv)[i]) == 0) { (*argv)[i] = NULL; - gdk_show_events = FALSE; + synchronize = TRUE; } else if (strcmp ("--no-xshm", (*argv)[i]) == 0) { (*argv)[i] = NULL; gdk_use_xshm = FALSE; } - else if (strcmp ("--debug-level", (*argv)[i]) == 0) - { - if ((i + 1) < *argc) - { - (*argv)[i++] = NULL; - gdk_debug_level = atoi ((*argv)[i]); - (*argv)[i] = NULL; - } - } else if (strcmp ("--name", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_progname = (*argv)[i]; @@ -342,7 +351,7 @@ gdk_init (int *argc, } else if (strcmp ("--class", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_progclass = (*argv)[i]; @@ -352,7 +361,7 @@ gdk_init (int *argc, #ifdef XINPUT_GXI else if (strcmp ("--gxid_host", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_input_gxid_host = ((*argv)[i]); @@ -361,7 +370,7 @@ gdk_init (int *argc, } else if (strcmp ("--gxid_port", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_input_gxid_port = atoi ((*argv)[i]); @@ -372,7 +381,7 @@ gdk_init (int *argc, #ifdef USE_XIM else if (strcmp ("--xim-preedit", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; if (strcmp ("none", (*argv)[i]) == 0) @@ -389,7 +398,7 @@ gdk_init (int *argc, } else if (strcmp ("--xim-status", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; if (strcmp ("none", (*argv)[i]) == 0) @@ -427,6 +436,15 @@ gdk_init (int *argc, gdk_progname = "<unknown>"; } + if (!debug_set) + { + gchar *debug_string = getenv("GDK_DEBUG"); + if (debug_string != NULL) + gdk_debug_flags = g_parse_debug_string (debug_string, + gdk_debug_keys, + sizeof(gdk_debug_keys) / sizeof(GDebugKey)); + } + gdk_display = XOpenDisplay (gdk_display_name); if (!gdk_display) { @@ -440,12 +458,11 @@ gdk_init (int *argc, */ /* base_id = RESOURCE_BASE; */ base_id = 0; - if (gdk_show_events) - g_print ("base id: %lu\n", base_id); + GDK_NOTE (EVENTS, g_print ("base id: %lu\n", base_id)); connection_number = ConnectionNumber (gdk_display); - if (gdk_debug_level >= 1) - g_print ("connection number: %d\n", connection_number); + GDK_NOTE (MISC, + g_print ("connection number: %d\n", connection_number)); if (synchronize) XSynchronize (gdk_display, True); @@ -929,31 +946,6 @@ gdk_event_free (GdkEvent *event) /* *-------------------------------------------------------------- - * gdk_set_debug_level - * - * Sets the debugging level. - * - * Arguments: - * "level" is the new debugging level. - * - * Results: - * - * Side effects: - * Other function calls to "gdk" use the debugging - * level to determine what kind of debugging information - * to print out. - * - *-------------------------------------------------------------- - */ - -void -gdk_set_debug_level (int level) -{ - gdk_debug_level = level; -} - -/* - *-------------------------------------------------------------- * gdk_set_show_events * * Turns on/off the showing of events. @@ -975,7 +967,10 @@ gdk_set_debug_level (int level) void gdk_set_show_events (int show_events) { - gdk_show_events = show_events; + if (show_events) + gdk_debug_flags |= GDK_DEBUG_EVENTS; + else + gdk_debug_flags &= ~GDK_DEBUG_EVENTS; } void @@ -985,15 +980,9 @@ gdk_set_use_xshm (gint use_xshm) } gint -gdk_get_debug_level () -{ - return gdk_debug_level; -} - -gint gdk_get_show_events () { - return gdk_show_events; + return gdk_debug_flags & GDK_DEBUG_EVENTS; } gint @@ -1750,8 +1739,8 @@ gdk_event_translate (GdkEvent *event, if (status == XBufferOverflow) { /* retry */ /* alloc adequate size of buffer */ - if (gdk_debug_level >= 1) - g_print("XIM: overflow (required %i)\n", charcount); + GDK_NOTE (XIM, + g_print("XIM: overflow (required %i)\n", charcount)); while (buf_len <= charcount) buf_len *= 2; @@ -1784,7 +1773,8 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ - if (gdk_show_events) +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & GDK_DEBUG_EVENTS) { g_print ("key press:\twindow: %ld key: %12s %d\n", xevent->xkey.window - base_id, @@ -1794,6 +1784,7 @@ gdk_event_translate (GdkEvent *event, g_print ("\t\tlength: %4d string: \"%s\"\n", charcount, buf); } +#endif /* G_ENABLE_DEBUG */ event->key.type = GDK_KEY_PRESS; event->key.window = window; @@ -1818,11 +1809,11 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("key release:\t\twindow: %ld key: %12s %d\n", xevent->xkey.window - base_id, XKeysymToString (event->key.keyval), - event->key.keyval); + event->key.keyval)); event->key.type = GDK_KEY_RELEASE; event->key.window = window; @@ -1837,12 +1828,12 @@ gdk_event_translate (GdkEvent *event, case ButtonPress: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d\n", window_private?window_private->dnd_drag_enabled:0, xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button); + xevent->xbutton.button)); if (window_private && (window_private->extension_events != 0) && @@ -1941,12 +1932,12 @@ gdk_event_translate (GdkEvent *event, case ButtonRelease: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("button release[%d]:\twindow: %ld x,y: %d %d button: %d\n", window_private?window_private->dnd_drag_enabled:0, xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button); + xevent->xbutton.button)); if (window_private && (window_private->extension_events != 0) && @@ -2018,12 +2009,12 @@ gdk_event_translate (GdkEvent *event, case MotionNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s d:%d r%d\n", xevent->xmotion.window - base_id, xevent->xmotion.x, xevent->xmotion.y, (xevent->xmotion.is_hint) ? "true" : "false", - dnd_drag_perhaps, gdk_dnd.drag_really); + dnd_drag_perhaps, gdk_dnd.drag_really)); if (window_private && (window_private->extension_events != 0) && @@ -2075,10 +2066,9 @@ gdk_event_translate (GdkEvent *event, x, y, &x, &y, &twin); } } -#if defined(DEBUG_DND) /* && defined(DEBUG_DND_MORE_DETAILS) */ - g_print("Drag is now in window %#x, lastwin was %#x, ddc = %#x\n", - curwin, lastwin, dnd_drag_curwin); -#endif + GDK_NOTE (DND, + g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n", + curwin, lastwin, dnd_drag_curwin)); if(curwin != dnd_drag_curwin && curwin != lastwin) { /* We have left one window and entered another @@ -2090,10 +2080,10 @@ gdk_event_translate (GdkEvent *event, dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; dnd_drag_dropzone.width = dnd_drag_dropzone.height = 0; dnd_drag_target = None; -#ifdef DEBUG_DND - g_print("curwin = %#x, lastwin = %#x, dnd_drag_curwin = %#x\n", - curwin, lastwin, dnd_drag_curwin); -#endif + GDK_NOTE (DND, + g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n", + curwin, lastwin, dnd_drag_curwin)); + XChangeActivePointerGrab(gdk_display, ButtonMotionMask | ButtonPressMask | ButtonReleaseMask, @@ -2139,13 +2129,11 @@ gdk_event_translate (GdkEvent *event, case EnterNotify: /* Print debugging info. */ -#if !(defined(DEBUG_DND) && defined(DEBUG_DND_MORE_DETAILS)) - if (gdk_show_events) -#endif + GDK_NOTE (EVENTS, g_print ("enter notify:\t\twindow: %ld detail: %d subwin: %ld\n", xevent->xcrossing.window - base_id, xevent->xcrossing.detail, - xevent->xcrossing.subwindow - base_id); + xevent->xcrossing.subwindow - base_id)); /* Tell XInput stuff about it if appropriate */ if (window_private && @@ -2188,21 +2176,20 @@ gdk_event_translate (GdkEvent *event, break; } -#ifdef DEBUG_DND - if(dnd_drag_perhaps) - { - g_print("We may[%d] have a drag into %#x = %#x\n", - gdk_dnd.drag_really, - xevent->xcrossing.window, real_sw->xwindow); - } -#endif + if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps) + { + g_print("We may[%d] have a drag into %#lx = %#lx\n", + gdk_dnd.drag_really, + xevent->xcrossing.window, real_sw->xwindow); + } + if (dnd_drag_perhaps && gdk_dnd.drag_really && (xevent->xcrossing.window == real_sw->xwindow)) { gdk_dnd.drag_really = 0; -#ifdef DEBUG_DND - g_print("Ungrabbed\n"); -#endif + + GDK_NOTE (DND, g_print("Ungrabbed\n")); + gdk_dnd.drag_numwindows = 0; g_free(gdk_dnd.drag_startwindows); gdk_dnd.drag_startwindows = NULL; @@ -2217,12 +2204,10 @@ gdk_event_translate (GdkEvent *event, case LeaveNotify: /* Print debugging info. */ -#if !(defined(DEBUG_DND) && defined(DEBUG_DND_MORE_DETAILS)) - if (gdk_show_events) -#endif + GDK_NOTE (EVENTS, g_print ("leave notify:\t\twindow: %ld detail: %d subwin: %ld\n", xevent->xcrossing.window - base_id, - xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id); + xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id)); event->crossing.type = GDK_LEAVE_NOTIFY; event->crossing.window = window; @@ -2258,14 +2243,12 @@ gdk_event_translate (GdkEvent *event, event->crossing.detail = GDK_NOTIFY_UNKNOWN; break; } -#ifdef DEBUG_DND - if(dnd_drag_perhaps) + if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps) { - g_print("We may[%d] have a drag out of %#x = %#x\n", + g_print("We may[%d] have a drag out of %#lx = %#lx\n", gdk_dnd.drag_really, xevent->xcrossing.window, real_sw->xwindow); } -#endif if (dnd_drag_perhaps && !gdk_dnd.drag_really && (xevent->xcrossing.window == real_sw->xwindow)) { @@ -2295,10 +2278,10 @@ gdk_event_translate (GdkEvent *event, case NotifyNonlinear: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("focus %s:\t\twindow: %ld\n", (xevent->xany.type == FocusIn) ? "in" : "out", - xevent->xfocus.window - base_id); + xevent->xfocus.window - base_id)); event->focus_change.type = GDK_FOCUS_CHANGE; event->focus_change.window = window; @@ -2314,8 +2297,8 @@ gdk_event_translate (GdkEvent *event, case KeymapNotify: /* Print debugging info. */ - if (gdk_show_events) - g_print ("keymap notify\n"); + GDK_NOTE (EVENTS, + g_print ("keymap notify\n")); /* Not currently handled */ break; @@ -2323,11 +2306,11 @@ gdk_event_translate (GdkEvent *event, case Expose: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d\n", xevent->xexpose.window - base_id, xevent->xexpose.count, xevent->xexpose.x, xevent->xexpose.y, - xevent->xexpose.width, xevent->xexpose.height); + xevent->xexpose.width, xevent->xexpose.height)); event->expose.type = GDK_EXPOSE; event->expose.window = window; @@ -2343,9 +2326,9 @@ gdk_event_translate (GdkEvent *event, case GraphicsExpose: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("graphics expose:\tdrawable: %ld\n", - xevent->xgraphicsexpose.drawable - base_id); + xevent->xgraphicsexpose.drawable - base_id)); event->expose.type = GDK_EXPOSE; event->expose.window = window; @@ -2361,9 +2344,9 @@ gdk_event_translate (GdkEvent *event, case NoExpose: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("no expose:\t\tdrawable: %ld\n", - xevent->xnoexpose.drawable - base_id); + xevent->xnoexpose.drawable - base_id)); event->no_expose.type = GDK_NO_EXPOSE; event->no_expose.window = window; @@ -2374,7 +2357,7 @@ gdk_event_translate (GdkEvent *event, case VisibilityNotify: /* Print debugging info. */ - if (gdk_show_events) + if (gdk_debug_flags & GDK_DEBUG_EVENTS) switch (xevent->xvisibility.state) { case VisibilityFullyObscured: @@ -2419,9 +2402,9 @@ gdk_event_translate (GdkEvent *event, case DestroyNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("destroy notify:\twindow: %ld\n", - xevent->xdestroywindow.window - base_id); + xevent->xdestroywindow.window - base_id)); event->any.type = GDK_DESTROY; event->any.window = window; @@ -2434,9 +2417,9 @@ gdk_event_translate (GdkEvent *event, case UnmapNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("unmap notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id); + xevent->xmap.window - base_id)); event->any.type = GDK_UNMAP; event->any.window = window; @@ -2450,9 +2433,9 @@ gdk_event_translate (GdkEvent *event, case MapNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("map notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id); + xevent->xmap.window - base_id)); event->any.type = GDK_MAP; event->any.window = window; @@ -2463,9 +2446,9 @@ gdk_event_translate (GdkEvent *event, case ReparentNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("reparent notify:\twindow: %ld\n", - xevent->xreparent.window - base_id); + xevent->xreparent.window - base_id)); /* Not currently handled */ break; @@ -2478,7 +2461,7 @@ gdk_event_translate (GdkEvent *event, ConfigureNotify, xevent)) /*XSync (gdk_display, 0)*/; - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d\n", xevent->xconfigure.window - base_id, xevent->xconfigure.x, @@ -2487,7 +2470,7 @@ gdk_event_translate (GdkEvent *event, xevent->xconfigure.height, xevent->xconfigure.border_width, xevent->xconfigure.above - base_id, - xevent->xconfigure.override_redirect); + xevent->xconfigure.override_redirect)); if (window_private) { @@ -2540,9 +2523,9 @@ gdk_event_translate (GdkEvent *event, case PropertyNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("property notify:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->property.type = GDK_PROPERTY_NOTIFY; event->property.window = window; @@ -2554,9 +2537,9 @@ gdk_event_translate (GdkEvent *event, break; case SelectionClear: - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("selection clear:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->selection.type = GDK_SELECTION_CLEAR; event->selection.window = window; @@ -2567,9 +2550,9 @@ gdk_event_translate (GdkEvent *event, break; case SelectionRequest: - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("selection request:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; @@ -2583,9 +2566,9 @@ gdk_event_translate (GdkEvent *event, break; case SelectionNotify: - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("selection notify:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->selection.type = GDK_SELECTION_NOTIFY; @@ -2601,9 +2584,9 @@ gdk_event_translate (GdkEvent *event, case ColormapNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("colormap notify:\twindow: %ld\n", - xevent->xcolormap.window - base_id); + xevent->xcolormap.window - base_id)); /* Not currently handled */ break; @@ -2611,9 +2594,9 @@ gdk_event_translate (GdkEvent *event, case ClientMessage: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("client message:\twindow: %ld\n", - xevent->xclient.window - base_id); + xevent->xclient.window - base_id)); /* Client messages are the means of the window manager * communicating with a program. We'll first check to @@ -2635,9 +2618,9 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("delete window:\t\twindow: %ld\n", - xevent->xclient.window - base_id); + xevent->xclient.window - base_id)); event->any.type = GDK_DELETE; event->any.window = window; @@ -2653,11 +2636,9 @@ gdk_event_translate (GdkEvent *event, Atom reptype = 0; event->dropenter.u.allflags = xevent->xclient.data.l[1]; -#ifndef DEBUG_DND - if (gdk_show_events) -#endif - g_print ("GDK_DROP_ENTER [%d][%d]\n", - window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply); + + GDK_NOTE (DND, g_print ("GDK_DROP_ENTER [%d][%d]\n", + window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply)); return_val = FALSE; /* Now figure out if we really want this drop... @@ -2694,18 +2675,18 @@ gdk_event_translate (GdkEvent *event, event->any.window = window; event->dropenter.requestor = replyev.xclient.window; event->dropenter.u.allflags = xevent->xclient.data.l[1]; -#ifdef DEBUG_DND - g_print("We sent a GDK_DROP_ENTER on to Gtk\n"); -#endif + + GDK_NOTE (DND, g_print("We sent a GDK_DROP_ENTER on to Gtk\n")); return_val = TRUE; } } else if (xevent->xclient.message_type == gdk_dnd.gdk_XdeLeave) { -#ifndef DEBUG_DND - if (gdk_show_events) -#endif +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) g_print ("GDK_DROP_LEAVE\n"); +#endif + if (window_private && window_private->dnd_drop_enabled) { event->dropleave.type = GDK_DROP_LEAVE; @@ -2723,10 +2704,10 @@ gdk_event_translate (GdkEvent *event, * make sure to only handle requests from the window the cursor is * over */ -#ifndef DEBUG_DND - if (gdk_show_events) -#endif +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) g_print ("GDK_DRAG_REQUEST\n"); +#endif event->dragrequest.u.allflags = xevent->xclient.data.l[1]; return_val = FALSE; @@ -2778,10 +2759,10 @@ gdk_event_translate (GdkEvent *event, gulong tmp_long; guchar *tmp_charptr; -#ifndef DEBUG_DND - if(gdk_show_events) -#endif - g_print("GDK_DROP_DATA_AVAIL\n"); +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) + g_print("GDK_DROP_DATA_AVAIL\n"); +#endif event->dropdataavailable.u.allflags = xevent->xclient.data.l[1]; if(window /* No preview of data ATM */ @@ -2809,10 +2790,8 @@ gdk_event_translate (GdkEvent *event, } else { -#ifdef DEBUG_DND - g_print("XGetWindowProperty got us %d bytes\n", - event->dropdataavailable.data_numbytes); -#endif + GDK_NOTE (DND, g_print("XGetWindowProperty got us %ld bytes\n", + event->dropdataavailable.data_numbytes)); event->dropdataavailable.data = g_malloc (event->dropdataavailable.data_numbytes); memcpy (event->dropdataavailable.data, @@ -2844,8 +2823,8 @@ gdk_event_translate (GdkEvent *event, case MappingNotify: /* Print debugging info. */ - if (gdk_show_events) - g_print ("mapping notify\n"); + GDK_NOTE (EVENTS, + g_print ("mapping notify\n")); /* Let XLib know that there is a new keyboard mapping. */ @@ -3569,9 +3548,9 @@ gdk_ic_cleanup (void) destroyed++; } } - if (gdk_debug_level >= 1 && destroyed > 0) + if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0) { - g_warning ("Cleanuped %i IC\n", destroyed); + g_warning ("Cleaned up %i IC(s)\n", destroyed); } g_list_free(xim_ic_list); xim_ic_list = NULL; @@ -42,7 +42,6 @@ void gdk_event_put (GdkEvent *event); GdkEvent *gdk_event_copy (GdkEvent *event); void gdk_event_free (GdkEvent *event); -void gdk_set_debug_level (gint level); void gdk_set_show_events (gint show_events); void gdk_set_use_xshm (gint use_xshm); diff --git a/gdk/gdkcc.c b/gdk/gdkcc.c index d027c6de6d..7224b3e939 100644 --- a/gdk/gdkcc.c +++ b/gdk/gdkcc.c @@ -552,11 +552,11 @@ gdk_color_context_new (GdkVisual *visual, { case GDK_VISUAL_STATIC_GRAY: case GDK_VISUAL_GRAYSCALE: - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_new: visual class is %s\n", (visual->type == GDK_VISUAL_STATIC_GRAY) ? "GDK_VISUAL_STATIC_GRAY" : - "GDK_VISUAL_GRAYSCALE"); + "GDK_VISUAL_GRAYSCALE")); if (GDK_VISUAL_XVISUAL (cc->visual)->map_entries == 2) init_bw (cc); @@ -566,26 +566,26 @@ gdk_color_context_new (GdkVisual *visual, break; case GDK_VISUAL_TRUE_COLOR: /* shifts */ - if (gdk_debug_level >= 1) - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n"); + GDK_NOTE (COLOR_CONTEXT, + g_print ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n")); init_true_color (cc); break; case GDK_VISUAL_DIRECT_COLOR: /* shifts and fake CLUT */ - if (gdk_debug_level >= 1) - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n"); + GDK_NOTE (COLOR_CONTEXT, + g_print ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n")); init_direct_color (cc); break; case GDK_VISUAL_STATIC_COLOR: case GDK_VISUAL_PSEUDO_COLOR: - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_new: visual class is %s\n", (visual->type == GDK_VISUAL_STATIC_COLOR) ? "GDK_VISUAL_STATIC_COLOR" : - "GDK_VISUAL_PSEUDO_COLOR"); + "GDK_VISUAL_PSEUDO_COLOR")); init_color (cc); break; @@ -607,9 +607,9 @@ gdk_color_context_new (GdkVisual *visual, cc->num_allocated = 0; - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n", - cc->visual->depth, cc->num_colors); + cc->visual->depth, cc->num_colors)); /* check if we need to initialize a hash table */ @@ -811,10 +811,10 @@ gdk_color_context_get_pixel (GdkColorContext *cc, { cc->max_colors *= 2; - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixel: " "resizing CLUT to %i entries\n", - cc->max_colors); + cc->max_colors)); cc->clut = g_realloc (cc->clut, cc->max_colors * sizeof (gulong)); @@ -906,9 +906,9 @@ gdk_color_context_get_pixels (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels: got all %i colors; " - "(%i colors allocated so far)\n", ncolors, cc->num_allocated); + "(%i colors allocated so far)\n", ncolors, cc->num_allocated)); return; } @@ -1031,10 +1031,10 @@ gdk_color_context_get_pixels (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels: got %i colors, %i exact and " "%i close (%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated); + ncolors, exact_col, close_col, cc->num_allocated)); return; } @@ -1102,10 +1102,10 @@ gdk_color_context_get_pixels (GdkColorContext *cc, } while (++idx < nopen); - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels: got %i colors, %i exact, %i close, " "%i substituted, %i to black (%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated); + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } void @@ -1176,9 +1176,9 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, } #ifdef DEBUG else - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: " - "pixel at slot %i already allocated, skipping\n", i); + "pixel at slot %i already allocated, skipping\n", i)); #endif } } @@ -1187,10 +1187,10 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: got all %i colors " "(%i colors allocated so far)\n", - ncolors, cc->num_allocated); + ncolors, cc->num_allocated)); return; } @@ -1293,11 +1293,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: " "got %i colors, %i exact and %i close " "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated); + ncolors, exact_col, close_col, cc->num_allocated)); return; } @@ -1364,11 +1364,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, } while (++idx < nopen); - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: " "got %i colors, %i exact, %i close, %i substituted, %i to black " "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated); + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } gint diff --git a/gdk/gdkglobals.c b/gdk/gdkglobals.c index 58f7bf8447..f27306fb34 100644 --- a/gdk/gdkglobals.c +++ b/gdk/gdkglobals.c @@ -20,8 +20,7 @@ #include "gdktypes.h" #include "gdkprivate.h" -gint gdk_debug_level = 0; -gint gdk_show_events = FALSE; +guint gdk_debug_flags = 0; gint gdk_use_xshm = TRUE; gchar *gdk_display_name = NULL; Display *gdk_display = NULL; diff --git a/gdk/gdkinputcommon.h b/gdk/gdkinputcommon.h index b0f7a058d7..7f0ab8c379 100644 --- a/gdk/gdkinputcommon.h +++ b/gdk/gdkinputcommon.h @@ -581,13 +581,13 @@ gdk_input_common_other_event (GdkEvent *event, event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state); event->button.button = xdbe->button; - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n", (event->button.type == GDK_BUTTON_PRESS) ? "press" : "release", xdbe->window, xdbe->deviceid, event->button.x, event->button.y, - xdbe->button); + xdbe->button)); return TRUE; } @@ -597,12 +597,12 @@ gdk_input_common_other_event (GdkEvent *event, { XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent); - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n", (event->key.type == GDK_KEY_PRESS) ? "press" : "release", xdke->window, xdke->deviceid, - xdke->keycode); + xdke->keycode)); if (xdke->keycode < gdkdev->min_keycode || xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys) @@ -615,8 +615,8 @@ gdk_input_common_other_event (GdkEvent *event, if (event->key.keyval == 0) { - if (gdk_show_events) - g_print ("\t\ttranslation - NONE\n"); + GDK_NOTE (EVENTS, + g_print ("\t\ttranslation - NONE\n")); return FALSE; } @@ -644,10 +644,10 @@ gdk_input_common_other_event (GdkEvent *event, event->key.string = g_new0 (gchar, 1); } - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n", event->key.keyval, - event->key.state); + event->key.state)); return TRUE; } @@ -672,13 +672,13 @@ gdk_input_common_other_event (GdkEvent *event, event->motion.source = gdkdev->info.source; event->motion.deviceid = xdme->deviceid; - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n", xdme->window, xdme->deviceid, event->motion.x, event->motion.y, event->motion.state, - (xdme->is_hint) ? "true" : "false"); + (xdme->is_hint) ? "true" : "false")); return TRUE; diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h index 55e150563f..c1abc26ecc 100644 --- a/gdk/gdkprivate.h +++ b/gdk/gdkprivate.h @@ -170,7 +170,6 @@ typedef struct _GdkICPrivate GdkICPrivate; #endif /* USE_XIM */ - struct _GdkColorContextPrivate { GdkColorContext color_context; @@ -178,6 +177,13 @@ struct _GdkColorContextPrivate XStandardColormap std_cmap; }; +typedef enum { + GDK_DEBUG_MISC = 1<<0, + GDK_DEBUG_EVENTS = 1 << 1, + GDK_DEBUG_DND = 1<<2, + GDK_DEBUG_COLOR_CONTEXT = 1<<3, + GDK_DEBUG_XIM = 1<<4 +} GdkDebugFlag; void gdk_window_init (void); void gdk_visual_init (void); @@ -219,6 +225,22 @@ extern gchar *gdk_progclass; extern gint gdk_error_code; extern gint gdk_error_warnings; +/* Debugging support */ + +#ifdef G_ENABLE_DEBUG + +#define GDK_NOTE(type,action) G_STMT_START { \ + if (gdk_debug_flags & GDK_DEBUG_##type) \ + action; } G_STMT_END + +#else /* !G_ENABLE_DEBUG */ + +#define GDK_NOTE(type,action) + +#endif /* G_ENABLE_DEBUG */ + +extern guint gdk_debug_flags; + #ifdef __cplusplus } diff --git a/gdk/gdkvisual.c b/gdk/gdkvisual.c index bb9388f208..b9f34a4843 100644 --- a/gdk/gdkvisual.c +++ b/gdk/gdkvisual.c @@ -201,7 +201,7 @@ gdk_visual_init () break; } - if (gdk_debug_level >= 1) + if (gdk_debug_flags & GDK_DEBUG_MISC) for (i = 0; i < nvisuals; i++) g_print ("visual: %s: %d\n", visual_names[visuals[i].visual.type], diff --git a/gdk/x11/gdkcc-x11.c b/gdk/x11/gdkcc-x11.c index d027c6de6d..7224b3e939 100644 --- a/gdk/x11/gdkcc-x11.c +++ b/gdk/x11/gdkcc-x11.c @@ -552,11 +552,11 @@ gdk_color_context_new (GdkVisual *visual, { case GDK_VISUAL_STATIC_GRAY: case GDK_VISUAL_GRAYSCALE: - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_new: visual class is %s\n", (visual->type == GDK_VISUAL_STATIC_GRAY) ? "GDK_VISUAL_STATIC_GRAY" : - "GDK_VISUAL_GRAYSCALE"); + "GDK_VISUAL_GRAYSCALE")); if (GDK_VISUAL_XVISUAL (cc->visual)->map_entries == 2) init_bw (cc); @@ -566,26 +566,26 @@ gdk_color_context_new (GdkVisual *visual, break; case GDK_VISUAL_TRUE_COLOR: /* shifts */ - if (gdk_debug_level >= 1) - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n"); + GDK_NOTE (COLOR_CONTEXT, + g_print ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n")); init_true_color (cc); break; case GDK_VISUAL_DIRECT_COLOR: /* shifts and fake CLUT */ - if (gdk_debug_level >= 1) - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n"); + GDK_NOTE (COLOR_CONTEXT, + g_print ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n")); init_direct_color (cc); break; case GDK_VISUAL_STATIC_COLOR: case GDK_VISUAL_PSEUDO_COLOR: - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_new: visual class is %s\n", (visual->type == GDK_VISUAL_STATIC_COLOR) ? "GDK_VISUAL_STATIC_COLOR" : - "GDK_VISUAL_PSEUDO_COLOR"); + "GDK_VISUAL_PSEUDO_COLOR")); init_color (cc); break; @@ -607,9 +607,9 @@ gdk_color_context_new (GdkVisual *visual, cc->num_allocated = 0; - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n", - cc->visual->depth, cc->num_colors); + cc->visual->depth, cc->num_colors)); /* check if we need to initialize a hash table */ @@ -811,10 +811,10 @@ gdk_color_context_get_pixel (GdkColorContext *cc, { cc->max_colors *= 2; - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixel: " "resizing CLUT to %i entries\n", - cc->max_colors); + cc->max_colors)); cc->clut = g_realloc (cc->clut, cc->max_colors * sizeof (gulong)); @@ -906,9 +906,9 @@ gdk_color_context_get_pixels (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels: got all %i colors; " - "(%i colors allocated so far)\n", ncolors, cc->num_allocated); + "(%i colors allocated so far)\n", ncolors, cc->num_allocated)); return; } @@ -1031,10 +1031,10 @@ gdk_color_context_get_pixels (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels: got %i colors, %i exact and " "%i close (%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated); + ncolors, exact_col, close_col, cc->num_allocated)); return; } @@ -1102,10 +1102,10 @@ gdk_color_context_get_pixels (GdkColorContext *cc, } while (++idx < nopen); - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels: got %i colors, %i exact, %i close, " "%i substituted, %i to black (%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated); + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } void @@ -1176,9 +1176,9 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, } #ifdef DEBUG else - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: " - "pixel at slot %i already allocated, skipping\n", i); + "pixel at slot %i already allocated, skipping\n", i)); #endif } } @@ -1187,10 +1187,10 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: got all %i colors " "(%i colors allocated so far)\n", - ncolors, cc->num_allocated); + ncolors, cc->num_allocated)); return; } @@ -1293,11 +1293,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, if ((ncols == ncolors) || (nopen == 0)) { - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: " "got %i colors, %i exact and %i close " "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated); + ncolors, exact_col, close_col, cc->num_allocated)); return; } @@ -1364,11 +1364,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, } while (++idx < nopen); - if (gdk_debug_level >= 1) + GDK_NOTE (COLOR_CONTEXT, g_print ("gdk_color_context_get_pixels_incremental: " "got %i colors, %i exact, %i close, %i substituted, %i to black " "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated); + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } gint diff --git a/gdk/x11/gdkglobals-x11.c b/gdk/x11/gdkglobals-x11.c index 58f7bf8447..f27306fb34 100644 --- a/gdk/x11/gdkglobals-x11.c +++ b/gdk/x11/gdkglobals-x11.c @@ -20,8 +20,7 @@ #include "gdktypes.h" #include "gdkprivate.h" -gint gdk_debug_level = 0; -gint gdk_show_events = FALSE; +guint gdk_debug_flags = 0; gint gdk_use_xshm = TRUE; gchar *gdk_display_name = NULL; Display *gdk_display = NULL; diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c index b0f7a058d7..7f0ab8c379 100644 --- a/gdk/x11/gdkinput-x11.c +++ b/gdk/x11/gdkinput-x11.c @@ -581,13 +581,13 @@ gdk_input_common_other_event (GdkEvent *event, event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state); event->button.button = xdbe->button; - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n", (event->button.type == GDK_BUTTON_PRESS) ? "press" : "release", xdbe->window, xdbe->deviceid, event->button.x, event->button.y, - xdbe->button); + xdbe->button)); return TRUE; } @@ -597,12 +597,12 @@ gdk_input_common_other_event (GdkEvent *event, { XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent); - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n", (event->key.type == GDK_KEY_PRESS) ? "press" : "release", xdke->window, xdke->deviceid, - xdke->keycode); + xdke->keycode)); if (xdke->keycode < gdkdev->min_keycode || xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys) @@ -615,8 +615,8 @@ gdk_input_common_other_event (GdkEvent *event, if (event->key.keyval == 0) { - if (gdk_show_events) - g_print ("\t\ttranslation - NONE\n"); + GDK_NOTE (EVENTS, + g_print ("\t\ttranslation - NONE\n")); return FALSE; } @@ -644,10 +644,10 @@ gdk_input_common_other_event (GdkEvent *event, event->key.string = g_new0 (gchar, 1); } - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n", event->key.keyval, - event->key.state); + event->key.state)); return TRUE; } @@ -672,13 +672,13 @@ gdk_input_common_other_event (GdkEvent *event, event->motion.source = gdkdev->info.source; event->motion.deviceid = xdme->deviceid; - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n", xdme->window, xdme->deviceid, event->motion.x, event->motion.y, event->motion.state, - (xdme->is_hint) ? "true" : "false"); + (xdme->is_hint) ? "true" : "false")); return TRUE; diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index b11b3f8236..de8a76e0d7 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -17,8 +17,6 @@ */ #include "../config.h" -/* #define DEBUG_DND 1 */ /* Shouldn't be needed much these days */ - /* If you don't want to use gdk's signal handlers define this */ /* #define I_NEED_TO_ACTUALLY_DEBUG_MY_PROGRAMS 1 */ @@ -227,6 +225,15 @@ static GList *putback_events = NULL; static gulong base_id; static gint autorepeat; +#ifdef G_ENABLE_DEBUG +static 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} +}; +#endif /* G_ENABLE_DEBUG */ /* *-------------------------------------------------------------- @@ -260,6 +267,8 @@ gdk_init (int *argc, int argc_orig = *argc; char **argv_orig; + gboolean debug_set = FALSE; + argv_orig = malloc ((argc_orig + 1) * sizeof (char*)); for (i = 0; i < argc_orig; i++) argv_orig[i] = g_strdup ((*argv)[i]); @@ -291,49 +300,49 @@ gdk_init (int *argc, for (i = 1; i < *argc;) { - if (strcmp ("--display", (*argv)[i]) == 0) + if ((*argv)[i] == NULL) + continue; + +#ifdef G_ENABLE_DEBUG + if (strcmp ("--gdk-debug", (*argv)[i]) == 0) { (*argv)[i] = NULL; - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { - gdk_display_name = g_strdup ((*argv)[i + 1]); + gdk_debug_flags = g_parse_debug_string ((*argv)[i+1], + gdk_debug_keys, + sizeof(gdk_debug_keys) / sizeof(GDebugKey)); + debug_set = TRUE; (*argv)[i + 1] = NULL; i += 1; } } - else if (strcmp ("--sync", (*argv)[i]) == 0) +#endif G_ENABLE_DEBUG + else if (strcmp ("--display", (*argv)[i]) == 0) { (*argv)[i] = NULL; - synchronize = TRUE; - } - else if (strcmp ("--show-events", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - gdk_show_events = TRUE; + + if ((i + 1) < *argc && (*argv)[i + 1]) + { + gdk_display_name = g_strdup ((*argv)[i + 1]); + (*argv)[i + 1] = NULL; + i += 1; + } } - else if (strcmp ("--no-show-events", (*argv)[i]) == 0) + else if (strcmp ("--sync", (*argv)[i]) == 0) { (*argv)[i] = NULL; - gdk_show_events = FALSE; + synchronize = TRUE; } else if (strcmp ("--no-xshm", (*argv)[i]) == 0) { (*argv)[i] = NULL; gdk_use_xshm = FALSE; } - else if (strcmp ("--debug-level", (*argv)[i]) == 0) - { - if ((i + 1) < *argc) - { - (*argv)[i++] = NULL; - gdk_debug_level = atoi ((*argv)[i]); - (*argv)[i] = NULL; - } - } else if (strcmp ("--name", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_progname = (*argv)[i]; @@ -342,7 +351,7 @@ gdk_init (int *argc, } else if (strcmp ("--class", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_progclass = (*argv)[i]; @@ -352,7 +361,7 @@ gdk_init (int *argc, #ifdef XINPUT_GXI else if (strcmp ("--gxid_host", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_input_gxid_host = ((*argv)[i]); @@ -361,7 +370,7 @@ gdk_init (int *argc, } else if (strcmp ("--gxid_port", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; gdk_input_gxid_port = atoi ((*argv)[i]); @@ -372,7 +381,7 @@ gdk_init (int *argc, #ifdef USE_XIM else if (strcmp ("--xim-preedit", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; if (strcmp ("none", (*argv)[i]) == 0) @@ -389,7 +398,7 @@ gdk_init (int *argc, } else if (strcmp ("--xim-status", (*argv)[i]) == 0) { - if ((i + 1) < *argc) + if ((i + 1) < *argc && (*argv)[i + 1]) { (*argv)[i++] = NULL; if (strcmp ("none", (*argv)[i]) == 0) @@ -427,6 +436,15 @@ gdk_init (int *argc, gdk_progname = "<unknown>"; } + if (!debug_set) + { + gchar *debug_string = getenv("GDK_DEBUG"); + if (debug_string != NULL) + gdk_debug_flags = g_parse_debug_string (debug_string, + gdk_debug_keys, + sizeof(gdk_debug_keys) / sizeof(GDebugKey)); + } + gdk_display = XOpenDisplay (gdk_display_name); if (!gdk_display) { @@ -440,12 +458,11 @@ gdk_init (int *argc, */ /* base_id = RESOURCE_BASE; */ base_id = 0; - if (gdk_show_events) - g_print ("base id: %lu\n", base_id); + GDK_NOTE (EVENTS, g_print ("base id: %lu\n", base_id)); connection_number = ConnectionNumber (gdk_display); - if (gdk_debug_level >= 1) - g_print ("connection number: %d\n", connection_number); + GDK_NOTE (MISC, + g_print ("connection number: %d\n", connection_number)); if (synchronize) XSynchronize (gdk_display, True); @@ -929,31 +946,6 @@ gdk_event_free (GdkEvent *event) /* *-------------------------------------------------------------- - * gdk_set_debug_level - * - * Sets the debugging level. - * - * Arguments: - * "level" is the new debugging level. - * - * Results: - * - * Side effects: - * Other function calls to "gdk" use the debugging - * level to determine what kind of debugging information - * to print out. - * - *-------------------------------------------------------------- - */ - -void -gdk_set_debug_level (int level) -{ - gdk_debug_level = level; -} - -/* - *-------------------------------------------------------------- * gdk_set_show_events * * Turns on/off the showing of events. @@ -975,7 +967,10 @@ gdk_set_debug_level (int level) void gdk_set_show_events (int show_events) { - gdk_show_events = show_events; + if (show_events) + gdk_debug_flags |= GDK_DEBUG_EVENTS; + else + gdk_debug_flags &= ~GDK_DEBUG_EVENTS; } void @@ -985,15 +980,9 @@ gdk_set_use_xshm (gint use_xshm) } gint -gdk_get_debug_level () -{ - return gdk_debug_level; -} - -gint gdk_get_show_events () { - return gdk_show_events; + return gdk_debug_flags & GDK_DEBUG_EVENTS; } gint @@ -1750,8 +1739,8 @@ gdk_event_translate (GdkEvent *event, if (status == XBufferOverflow) { /* retry */ /* alloc adequate size of buffer */ - if (gdk_debug_level >= 1) - g_print("XIM: overflow (required %i)\n", charcount); + GDK_NOTE (XIM, + g_print("XIM: overflow (required %i)\n", charcount)); while (buf_len <= charcount) buf_len *= 2; @@ -1784,7 +1773,8 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ - if (gdk_show_events) +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & GDK_DEBUG_EVENTS) { g_print ("key press:\twindow: %ld key: %12s %d\n", xevent->xkey.window - base_id, @@ -1794,6 +1784,7 @@ gdk_event_translate (GdkEvent *event, g_print ("\t\tlength: %4d string: \"%s\"\n", charcount, buf); } +#endif /* G_ENABLE_DEBUG */ event->key.type = GDK_KEY_PRESS; event->key.window = window; @@ -1818,11 +1809,11 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("key release:\t\twindow: %ld key: %12s %d\n", xevent->xkey.window - base_id, XKeysymToString (event->key.keyval), - event->key.keyval); + event->key.keyval)); event->key.type = GDK_KEY_RELEASE; event->key.window = window; @@ -1837,12 +1828,12 @@ gdk_event_translate (GdkEvent *event, case ButtonPress: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d\n", window_private?window_private->dnd_drag_enabled:0, xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button); + xevent->xbutton.button)); if (window_private && (window_private->extension_events != 0) && @@ -1941,12 +1932,12 @@ gdk_event_translate (GdkEvent *event, case ButtonRelease: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("button release[%d]:\twindow: %ld x,y: %d %d button: %d\n", window_private?window_private->dnd_drag_enabled:0, xevent->xbutton.window - base_id, xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button); + xevent->xbutton.button)); if (window_private && (window_private->extension_events != 0) && @@ -2018,12 +2009,12 @@ gdk_event_translate (GdkEvent *event, case MotionNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s d:%d r%d\n", xevent->xmotion.window - base_id, xevent->xmotion.x, xevent->xmotion.y, (xevent->xmotion.is_hint) ? "true" : "false", - dnd_drag_perhaps, gdk_dnd.drag_really); + dnd_drag_perhaps, gdk_dnd.drag_really)); if (window_private && (window_private->extension_events != 0) && @@ -2075,10 +2066,9 @@ gdk_event_translate (GdkEvent *event, x, y, &x, &y, &twin); } } -#if defined(DEBUG_DND) /* && defined(DEBUG_DND_MORE_DETAILS) */ - g_print("Drag is now in window %#x, lastwin was %#x, ddc = %#x\n", - curwin, lastwin, dnd_drag_curwin); -#endif + GDK_NOTE (DND, + g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n", + curwin, lastwin, dnd_drag_curwin)); if(curwin != dnd_drag_curwin && curwin != lastwin) { /* We have left one window and entered another @@ -2090,10 +2080,10 @@ gdk_event_translate (GdkEvent *event, dnd_drag_dropzone.x = dnd_drag_dropzone.y = 0; dnd_drag_dropzone.width = dnd_drag_dropzone.height = 0; dnd_drag_target = None; -#ifdef DEBUG_DND - g_print("curwin = %#x, lastwin = %#x, dnd_drag_curwin = %#x\n", - curwin, lastwin, dnd_drag_curwin); -#endif + GDK_NOTE (DND, + g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n", + curwin, lastwin, dnd_drag_curwin)); + XChangeActivePointerGrab(gdk_display, ButtonMotionMask | ButtonPressMask | ButtonReleaseMask, @@ -2139,13 +2129,11 @@ gdk_event_translate (GdkEvent *event, case EnterNotify: /* Print debugging info. */ -#if !(defined(DEBUG_DND) && defined(DEBUG_DND_MORE_DETAILS)) - if (gdk_show_events) -#endif + GDK_NOTE (EVENTS, g_print ("enter notify:\t\twindow: %ld detail: %d subwin: %ld\n", xevent->xcrossing.window - base_id, xevent->xcrossing.detail, - xevent->xcrossing.subwindow - base_id); + xevent->xcrossing.subwindow - base_id)); /* Tell XInput stuff about it if appropriate */ if (window_private && @@ -2188,21 +2176,20 @@ gdk_event_translate (GdkEvent *event, break; } -#ifdef DEBUG_DND - if(dnd_drag_perhaps) - { - g_print("We may[%d] have a drag into %#x = %#x\n", - gdk_dnd.drag_really, - xevent->xcrossing.window, real_sw->xwindow); - } -#endif + if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps) + { + g_print("We may[%d] have a drag into %#lx = %#lx\n", + gdk_dnd.drag_really, + xevent->xcrossing.window, real_sw->xwindow); + } + if (dnd_drag_perhaps && gdk_dnd.drag_really && (xevent->xcrossing.window == real_sw->xwindow)) { gdk_dnd.drag_really = 0; -#ifdef DEBUG_DND - g_print("Ungrabbed\n"); -#endif + + GDK_NOTE (DND, g_print("Ungrabbed\n")); + gdk_dnd.drag_numwindows = 0; g_free(gdk_dnd.drag_startwindows); gdk_dnd.drag_startwindows = NULL; @@ -2217,12 +2204,10 @@ gdk_event_translate (GdkEvent *event, case LeaveNotify: /* Print debugging info. */ -#if !(defined(DEBUG_DND) && defined(DEBUG_DND_MORE_DETAILS)) - if (gdk_show_events) -#endif + GDK_NOTE (EVENTS, g_print ("leave notify:\t\twindow: %ld detail: %d subwin: %ld\n", xevent->xcrossing.window - base_id, - xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id); + xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id)); event->crossing.type = GDK_LEAVE_NOTIFY; event->crossing.window = window; @@ -2258,14 +2243,12 @@ gdk_event_translate (GdkEvent *event, event->crossing.detail = GDK_NOTIFY_UNKNOWN; break; } -#ifdef DEBUG_DND - if(dnd_drag_perhaps) + if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps) { - g_print("We may[%d] have a drag out of %#x = %#x\n", + g_print("We may[%d] have a drag out of %#lx = %#lx\n", gdk_dnd.drag_really, xevent->xcrossing.window, real_sw->xwindow); } -#endif if (dnd_drag_perhaps && !gdk_dnd.drag_really && (xevent->xcrossing.window == real_sw->xwindow)) { @@ -2295,10 +2278,10 @@ gdk_event_translate (GdkEvent *event, case NotifyNonlinear: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("focus %s:\t\twindow: %ld\n", (xevent->xany.type == FocusIn) ? "in" : "out", - xevent->xfocus.window - base_id); + xevent->xfocus.window - base_id)); event->focus_change.type = GDK_FOCUS_CHANGE; event->focus_change.window = window; @@ -2314,8 +2297,8 @@ gdk_event_translate (GdkEvent *event, case KeymapNotify: /* Print debugging info. */ - if (gdk_show_events) - g_print ("keymap notify\n"); + GDK_NOTE (EVENTS, + g_print ("keymap notify\n")); /* Not currently handled */ break; @@ -2323,11 +2306,11 @@ gdk_event_translate (GdkEvent *event, case Expose: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d\n", xevent->xexpose.window - base_id, xevent->xexpose.count, xevent->xexpose.x, xevent->xexpose.y, - xevent->xexpose.width, xevent->xexpose.height); + xevent->xexpose.width, xevent->xexpose.height)); event->expose.type = GDK_EXPOSE; event->expose.window = window; @@ -2343,9 +2326,9 @@ gdk_event_translate (GdkEvent *event, case GraphicsExpose: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("graphics expose:\tdrawable: %ld\n", - xevent->xgraphicsexpose.drawable - base_id); + xevent->xgraphicsexpose.drawable - base_id)); event->expose.type = GDK_EXPOSE; event->expose.window = window; @@ -2361,9 +2344,9 @@ gdk_event_translate (GdkEvent *event, case NoExpose: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("no expose:\t\tdrawable: %ld\n", - xevent->xnoexpose.drawable - base_id); + xevent->xnoexpose.drawable - base_id)); event->no_expose.type = GDK_NO_EXPOSE; event->no_expose.window = window; @@ -2374,7 +2357,7 @@ gdk_event_translate (GdkEvent *event, case VisibilityNotify: /* Print debugging info. */ - if (gdk_show_events) + if (gdk_debug_flags & GDK_DEBUG_EVENTS) switch (xevent->xvisibility.state) { case VisibilityFullyObscured: @@ -2419,9 +2402,9 @@ gdk_event_translate (GdkEvent *event, case DestroyNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("destroy notify:\twindow: %ld\n", - xevent->xdestroywindow.window - base_id); + xevent->xdestroywindow.window - base_id)); event->any.type = GDK_DESTROY; event->any.window = window; @@ -2434,9 +2417,9 @@ gdk_event_translate (GdkEvent *event, case UnmapNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("unmap notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id); + xevent->xmap.window - base_id)); event->any.type = GDK_UNMAP; event->any.window = window; @@ -2450,9 +2433,9 @@ gdk_event_translate (GdkEvent *event, case MapNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("map notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id); + xevent->xmap.window - base_id)); event->any.type = GDK_MAP; event->any.window = window; @@ -2463,9 +2446,9 @@ gdk_event_translate (GdkEvent *event, case ReparentNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("reparent notify:\twindow: %ld\n", - xevent->xreparent.window - base_id); + xevent->xreparent.window - base_id)); /* Not currently handled */ break; @@ -2478,7 +2461,7 @@ gdk_event_translate (GdkEvent *event, ConfigureNotify, xevent)) /*XSync (gdk_display, 0)*/; - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d\n", xevent->xconfigure.window - base_id, xevent->xconfigure.x, @@ -2487,7 +2470,7 @@ gdk_event_translate (GdkEvent *event, xevent->xconfigure.height, xevent->xconfigure.border_width, xevent->xconfigure.above - base_id, - xevent->xconfigure.override_redirect); + xevent->xconfigure.override_redirect)); if (window_private) { @@ -2540,9 +2523,9 @@ gdk_event_translate (GdkEvent *event, case PropertyNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("property notify:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->property.type = GDK_PROPERTY_NOTIFY; event->property.window = window; @@ -2554,9 +2537,9 @@ gdk_event_translate (GdkEvent *event, break; case SelectionClear: - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("selection clear:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->selection.type = GDK_SELECTION_CLEAR; event->selection.window = window; @@ -2567,9 +2550,9 @@ gdk_event_translate (GdkEvent *event, break; case SelectionRequest: - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("selection request:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; @@ -2583,9 +2566,9 @@ gdk_event_translate (GdkEvent *event, break; case SelectionNotify: - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("selection notify:\twindow: %ld\n", - xevent->xproperty.window - base_id); + xevent->xproperty.window - base_id)); event->selection.type = GDK_SELECTION_NOTIFY; @@ -2601,9 +2584,9 @@ gdk_event_translate (GdkEvent *event, case ColormapNotify: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("colormap notify:\twindow: %ld\n", - xevent->xcolormap.window - base_id); + xevent->xcolormap.window - base_id)); /* Not currently handled */ break; @@ -2611,9 +2594,9 @@ gdk_event_translate (GdkEvent *event, case ClientMessage: /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("client message:\twindow: %ld\n", - xevent->xclient.window - base_id); + xevent->xclient.window - base_id)); /* Client messages are the means of the window manager * communicating with a program. We'll first check to @@ -2635,9 +2618,9 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ - if (gdk_show_events) + GDK_NOTE (EVENTS, g_print ("delete window:\t\twindow: %ld\n", - xevent->xclient.window - base_id); + xevent->xclient.window - base_id)); event->any.type = GDK_DELETE; event->any.window = window; @@ -2653,11 +2636,9 @@ gdk_event_translate (GdkEvent *event, Atom reptype = 0; event->dropenter.u.allflags = xevent->xclient.data.l[1]; -#ifndef DEBUG_DND - if (gdk_show_events) -#endif - g_print ("GDK_DROP_ENTER [%d][%d]\n", - window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply); + + GDK_NOTE (DND, g_print ("GDK_DROP_ENTER [%d][%d]\n", + window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply)); return_val = FALSE; /* Now figure out if we really want this drop... @@ -2694,18 +2675,18 @@ gdk_event_translate (GdkEvent *event, event->any.window = window; event->dropenter.requestor = replyev.xclient.window; event->dropenter.u.allflags = xevent->xclient.data.l[1]; -#ifdef DEBUG_DND - g_print("We sent a GDK_DROP_ENTER on to Gtk\n"); -#endif + + GDK_NOTE (DND, g_print("We sent a GDK_DROP_ENTER on to Gtk\n")); return_val = TRUE; } } else if (xevent->xclient.message_type == gdk_dnd.gdk_XdeLeave) { -#ifndef DEBUG_DND - if (gdk_show_events) -#endif +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) g_print ("GDK_DROP_LEAVE\n"); +#endif + if (window_private && window_private->dnd_drop_enabled) { event->dropleave.type = GDK_DROP_LEAVE; @@ -2723,10 +2704,10 @@ gdk_event_translate (GdkEvent *event, * make sure to only handle requests from the window the cursor is * over */ -#ifndef DEBUG_DND - if (gdk_show_events) -#endif +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) g_print ("GDK_DRAG_REQUEST\n"); +#endif event->dragrequest.u.allflags = xevent->xclient.data.l[1]; return_val = FALSE; @@ -2778,10 +2759,10 @@ gdk_event_translate (GdkEvent *event, gulong tmp_long; guchar *tmp_charptr; -#ifndef DEBUG_DND - if(gdk_show_events) -#endif - g_print("GDK_DROP_DATA_AVAIL\n"); +#ifdef G_ENABLE_DEBUG + if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) + g_print("GDK_DROP_DATA_AVAIL\n"); +#endif event->dropdataavailable.u.allflags = xevent->xclient.data.l[1]; if(window /* No preview of data ATM */ @@ -2809,10 +2790,8 @@ gdk_event_translate (GdkEvent *event, } else { -#ifdef DEBUG_DND - g_print("XGetWindowProperty got us %d bytes\n", - event->dropdataavailable.data_numbytes); -#endif + GDK_NOTE (DND, g_print("XGetWindowProperty got us %ld bytes\n", + event->dropdataavailable.data_numbytes)); event->dropdataavailable.data = g_malloc (event->dropdataavailable.data_numbytes); memcpy (event->dropdataavailable.data, @@ -2844,8 +2823,8 @@ gdk_event_translate (GdkEvent *event, case MappingNotify: /* Print debugging info. */ - if (gdk_show_events) - g_print ("mapping notify\n"); + GDK_NOTE (EVENTS, + g_print ("mapping notify\n")); /* Let XLib know that there is a new keyboard mapping. */ @@ -3569,9 +3548,9 @@ gdk_ic_cleanup (void) destroyed++; } } - if (gdk_debug_level >= 1 && destroyed > 0) + if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0) { - g_warning ("Cleanuped %i IC\n", destroyed); + g_warning ("Cleaned up %i IC(s)\n", destroyed); } g_list_free(xim_ic_list); xim_ic_list = NULL; diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c index bb9388f208..b9f34a4843 100644 --- a/gdk/x11/gdkvisual-x11.c +++ b/gdk/x11/gdkvisual-x11.c @@ -201,7 +201,7 @@ gdk_visual_init () break; } - if (gdk_debug_level >= 1) + if (gdk_debug_flags & GDK_DEBUG_MISC) for (i = 0; i < nvisuals; i++) g_print ("visual: %s: %d\n", visual_names[visuals[i].visual.type], diff --git a/glib/configure.in b/glib/configure.in index e417ccb99b..7f3815d911 100644 --- a/glib/configure.in +++ b/glib/configure.in @@ -1,6 +1,9 @@ # Process this file with autoconf to produce a configure script. AC_INIT(glist.c) +# Save this value here, since automake will set cflags later +cflags_set=${CFLAGS+set} + dnl Initialize automake stuff AM_INIT_AUTOMAKE(glib, 0.99.3) @@ -15,16 +18,18 @@ AM_MAINTAINER_MODE AC_CANONICAL_HOST -AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]], -if test "x$enable_debug" = "xyes"; then - DEBUGFLAG="-g" -fi) +AC_ARG_ENABLE(debug, [ --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],,enable_debug=minimum) AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]], , enable_ansi=no) -if test -n "$DEBUGFLAG"; then - test "$cflags_set" = set || CFLAGS="$DEBUGFLAG" +if test "x$enable_debug" = "xyes"; then + test "$cflags_set" = set || CFLAGS="-g" + CFLAGS="$CFLAGS -DG_ENABLE_DEBUG" +else + if test "x$enable_debug" = "xno"; then + CFLAGS="$CFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS" + fi fi # Checks for programs. diff --git a/glib/glib.h b/glib/glib.h index 5c795d3a61..d1de4ab768 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -182,6 +182,13 @@ * in order to support gcc's __PRETTY_FUNCTION__ capability. */ +#ifdef G_DISABLE_ASSERT + +#define g_assert(expr) +#define g_assert_not_reached() + +#else /* !G_DISABLE_ASSERT */ + #ifdef __GNUC__ #define g_assert(expr) G_STMT_START{\ @@ -198,6 +205,33 @@ __LINE__, \ __PRETTY_FUNCTION__); }G_STMT_END +#else /* !__GNUC__ */ + +#define g_assert(expr) G_STMT_START{\ + if (!(expr)) \ + g_error ("file %s: line %d: \"%s\"", \ + __FILE__, \ + __LINE__, \ + #expr); }G_STMT_END + +#define g_assert_not_reached() G_STMT_START{ \ + g_error ("file %s: line %d: \"should not be reached\"", \ + __FILE__, \ + __LINE__); }G_STMT_END + +#endif /* __GNUC__ */ + +#endif /* G_DISABLE_ASSERT */ + +#ifdef G_DISABLE_CHECKS + +#define g_return_if_fail(expr) +#define g_return_val_if_fail(expr,val) + +#else /* !G_DISABLE_CHECKS */ + +#ifdef __GNUC__ + #define g_return_if_fail(expr) G_STMT_START{ \ if (!(expr)) \ { \ @@ -220,19 +254,7 @@ return val; \ }; }G_STMT_END -#else /* __GNUC__ */ - -#define g_assert(expr) G_STMT_START{\ - if (!(expr)) \ - g_error ("file %s: line %d: \"%s\"", \ - __FILE__, \ - __LINE__, \ - #expr); }G_STMT_END - -#define g_assert_not_reached() G_STMT_START{ \ - g_error ("file %s: line %d: \"should not be reached\"", \ - __FILE__, \ - __LINE__); }G_STMT_END +#else /* !__GNUC__ */ #define g_return_if_fail(expr) G_STMT_START{ \ if (!(expr)) \ @@ -254,8 +276,9 @@ return val; \ }; }G_STMT_END -#endif /* __GNUC__ */ +#endif /* !__GNUC__ */ +#endif /* G_DISABLE_CHECKS */ #ifdef __cplusplus extern "C" { @@ -327,6 +350,7 @@ typedef struct _GListAllocator GListAllocator; typedef struct _GStringChunk GStringChunk; typedef struct _GString GString; typedef struct _GArray GArray; +typedef struct _GDebugKey GDebugKey; typedef void (*GFunc) (gpointer data, gpointer user_data); typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data); @@ -370,6 +394,12 @@ struct _GArray guint len; }; +struct _GDebugKey +{ + gchar *key; + guint value; +}; + struct _GHashTable { gint dummy; }; struct _GCache { gint dummy; }; struct _GTree { gint dummy; }; @@ -650,6 +680,10 @@ GWarningFunc g_set_warning_handler (GWarningFunc func); GPrintFunc g_set_message_handler (GPrintFunc func); GPrintFunc g_set_print_handler (GPrintFunc func); +guint g_parse_debug_string (const gchar *string, + GDebugKey *keys, + guint nkeys); + void g_debug (char *progname); void g_attach_process (char *progname, int query); void g_stack_trace (char *progname, int query); diff --git a/glib/gutils.c b/glib/gutils.c index ee4a0464d5..9e665ba6bc 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -862,3 +862,50 @@ g_strcasecmp (const guchar *s1, const guchar *s2) return ((gint) *s1 - (gint) *s2); #endif } + +guint +g_parse_debug_string (const gchar *string, + GDebugKey *keys, + guint nkeys) +{ + guint i; + guint result = 0; + + g_return_val_if_fail (string != NULL, 0); + + if (!strcmp (string, "ALL")) + { + for (i=0; i<nkeys; i++) + result |= keys[i].value; + } + else + { + gchar *str = g_strdup (string); + gchar *p = str; + gchar *q; + gboolean done = FALSE; + + while (*p && !done) + { + q = strchr (p, ':'); + if (!q) + { + q = p + strlen(p); + done = TRUE; + } + + *q = 0; + + for (i=0; i<nkeys; i++) + if (!strcmp(keys[i].key, p)) + result |= keys[i].value; + + p = q+1; + } + + g_free (str); + } + + return result; +} + diff --git a/gtk/Makefile.am b/gtk/Makefile.am index dc8caff9ef..4074395ad3 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -112,6 +112,7 @@ gtkinclude_HEADERS = \ gtkcontainer.h \ gtkcurve.h \ gtkdata.h \ + gtkdebug.h \ gtkdialog.h \ gtkdrawingarea.h \ gtkentry.h \ diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 2980150e01..90ce42cc0a 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -141,11 +141,22 @@ static GdkColormap *gtk_colormap; /* The colormap to be used in creating new * widgets. */ +guint gtk_debug_flags; /* Global GTK debug flag */ + +#ifdef G_ENABLE_DEBUG +static GDebugKey gtk_debug_keys[] = { + {"objects", GTK_DEBUG_OBJECTS} +}; +#endif /* G_ENABLE_DEBUG */ void gtk_init (int *argc, char ***argv) { +#ifdef G_ENABLE_DEBUG + gboolean debug_set = FALSE; +#endif + if (0) { g_set_error_handler (gtk_error); @@ -154,11 +165,46 @@ gtk_init (int *argc, g_set_print_handler (gtk_print); } - /* Initialize "gdk". We simply pass along the 'argc' and 'argv' - * parameters as they contain information that + /* Initialize "gdk". We pass along the 'argc' and 'argv' + * parameters as they contain information that GDK uses */ gdk_init (argc, argv); +#ifdef G_ENABLE_DEBUG + if (argc && argv) + { + gint i; + + for (i = 1; i < *argc;) + { + if ((*argv[i]) && strcmp ("--gtk-debug", (*argv)[i]) == 0) + { + (*argv)[i] = NULL; + + if ((i + 1) < *argc && (*argv)[i + 1]) + { + gtk_debug_flags = g_parse_debug_string ((*argv)[i+1], + gtk_debug_keys, + sizeof(gtk_debug_keys) / sizeof(GDebugKey)); + debug_set = TRUE; + (*argv)[i + 1] = NULL; + i += 1; + } + } + i += 1; + } + } + + if (!debug_set) + { + gchar *debug_string = getenv("GTK_DEBUG"); + if (debug_string != NULL) + gtk_debug_flags = g_parse_debug_string (debug_string, + gtk_debug_keys, + sizeof(gtk_debug_keys) / sizeof(GDebugKey)); + } +#endif /* G_ENABLE_DEBUG */ + /* Initialize the default visual and colormap to be * used in creating widgets. (We want to use the system * defaults so as to be nice to the colormap). diff --git a/gtk/gtkobject.c b/gtk/gtkobject.c index 41a46d39ed..5a90c5a82c 100644 --- a/gtk/gtkobject.c +++ b/gtk/gtkobject.c @@ -84,7 +84,6 @@ static gint object_signals[LAST_SIGNAL] = { 0 }; static gint object_data_init = TRUE; static GHashTable *object_data_ht = NULL; static GMemChunk *object_data_mem_chunk = NULL; -static GtkObjectData *object_data_free_list = NULL; static GSList *object_data_id_list = NULL; static gint object_data_id_index = 0; @@ -146,9 +145,10 @@ gtk_object_init_type () object_type = gtk_type_unique (0, &object_info); g_assert (object_type == GTK_TYPE_OBJECT); -#ifdef GTK_TRACE_OBJECTS - ATEXIT (gtk_object_debug); -#endif /* GTK_TRACE_OBJECTS */ +#ifdef G_ENABLE_DEBUG + if (gtk_debug_flags & GTK_DEBUG_OBJECTS) + ATEXIT (gtk_object_debug); +#endif /* G_ENABLE_DEBUG */ } GtkType @@ -223,10 +223,13 @@ gtk_object_init (GtkObject *object) object->ref_count = 1; object->object_data = NULL; -#ifdef GTK_TRACE_OBJECTS - obj_count++; - living_objs = g_slist_prepend (living_objs, object); -#endif /* GTK_TRACE_OBJECTS */ +#ifdef G_ENABLE_DEBUG + if (gtk_debug_flags & GTK_DEBUG_OBJECTS) + { + obj_count++; + living_objs = g_slist_prepend (living_objs, object); + } +#endif /* G_ENABLE_DEBUG */ } /***************************************** @@ -1495,13 +1498,20 @@ gtk_object_unref (GtkObject *object) if (object->ref_count == 0) { - g_assert (g_slist_find (living_objs, object)); - living_objs = g_slist_remove (living_objs, object); +#ifdef G_ENABLE_DEBUG + if (gtk_debug_flags & GTK_DEBUG_OBJECTS) + { + g_assert (g_slist_find (living_objs, object)); + living_objs = g_slist_remove (living_objs, object); + obj_count--; + } +#endif /* G_ENABLE_DEBUG */ object->klass->finalize (object); - obj_count--; } } +#ifdef G_ENABLE_DEBUG + static GtkObject *gtk_trace_object = NULL; void @@ -1514,34 +1524,40 @@ gtk_trace_referencing (gpointer *o, gboolean exists; GtkObject *object = (GtkObject*) o; - g_return_if_fail (object != NULL); - g_return_if_fail (GTK_IS_OBJECT (object)); + if (gtk_debug_flags & GTK_DEBUG_OBJECTS) + { + g_return_if_fail (object != NULL); + g_return_if_fail (GTK_IS_OBJECT (object)); - exists = (g_slist_find (living_objs, object) != NULL); - - if (exists && - (object == gtk_trace_object || - gtk_trace_object == (void*)42)) - printf ("trace: object_%s: (%s:%p)->ref_count=%d%s (%s_f%02d:%d)\n", - do_ref ? "ref" : "unref", - gtk_type_name (GTK_OBJECT_TYPE (object)), - object, - object->ref_count, - do_ref ? " + 1" : " - 1 ", - func, - local_frame, - line); + exists = (g_slist_find (living_objs, object) != NULL); + + if (exists && + (object == gtk_trace_object || + gtk_trace_object == (void*)42)) + printf ("trace: object_%s: (%s:%p)->ref_count=%d%s (%s_f%02d:%d)\n", + do_ref ? "ref" : "unref", + gtk_type_name (GTK_OBJECT_TYPE (object)), + object, + object->ref_count, + do_ref ? " + 1" : " - 1 ", + func, + local_frame, + line); - if (!exists) - printf ("trace: object_%s(%p): no such object! (%s_f%02d:%d)\n", - do_ref ? "ref" : "unref", - object, - func, - local_frame, - line); + if (!exists) + printf ("trace: object_%s(%p): no such object! (%s_f%02d:%d)\n", + do_ref ? "ref" : "unref", + object, + func, + local_frame, + line); + } if (do_ref) gtk_object_ref (object); else gtk_object_unref (object); } + +#endif /* G_ENABLE_DEBUG */ + diff --git a/gtk/gtkobject.h b/gtk/gtkobject.h index 2c6aeef09d..fadea418ee 100644 --- a/gtk/gtkobject.h +++ b/gtk/gtkobject.h @@ -18,11 +18,10 @@ #ifndef __GTK_OBJECT_H__ #define __GTK_OBJECT_H__ -#define GTK_TRACE_OBJECTS 1 - #include <gtk/gtkenums.h> #include <gtk/gtktypeutils.h> +#include <gtk/gtkdebug.h> #ifdef __cplusplus @@ -35,12 +34,12 @@ extern "C" { * before proceeding, but they are definately slower than their less * careful counterparts as they involve no less than 3 function calls. */ -#ifdef NDEBUG +#ifdef GTK_NO_CHECK_CASTS #define GTK_CHECK_CAST(obj,cast_type,cast) ((cast*) (obj)) #define GTK_CHECK_CLASS_CAST(klass,cast_type,cast) ((cast*) (klass)) -#else /* NDEBUG */ +#else /* !GTK_NO_CHECK_CASTS */ #define GTK_CHECK_CAST(obj,cast_type,cast) \ ((cast*) gtk_object_check_cast ((GtkObject*) (obj), cast_type)) @@ -48,7 +47,7 @@ extern "C" { #define GTK_CHECK_CLASS_CAST(klass,cast_type,cast) \ ((cast*) gtk_object_check_class_cast ((GtkObjectClass*) (klass), cast_type)) -#endif /* NDEBUG */ +#endif /* GTK_NO_CHECK_CASTS */ /* Determines whether 'obj' is a type of 'otype'. @@ -304,7 +303,7 @@ void gtk_trace_referencing (gpointer *object, guint line, gboolean do_ref); -#if defined (GTK_TRACE_OBJECTS) && defined (__GNUC__) +#if G_ENABLE_DEBUG && defined (__GNUC__) # define gtk_object_ref(o) G_STMT_START{static guint f=0;gtk_trace_referencing((gpointer)o,__PRETTY_FUNCTION__,++f,__LINE__, 1);f--;}G_STMT_END # define gtk_object_unref(o) G_STMT_START{static guint f=0;gtk_trace_referencing((gpointer)o,__PRETTY_FUNCTION__,++f,__LINE__, 0);f--;}G_STMT_END #endif /* GTK_TRACE_OBJECTS && __GNUC__ */ |