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)
+At run time, if GTK+ was compiled with debugging enabled, different
+types of debugging information can be printed out. This is controlled
+by the:
+
+ GTK_DEBUG and GDK_DEBUG environment variables
+ --gtk-debug and --gdk-debug command line options
+ --gtk-no-debug and --gdk-no-debug command line options
-Each of these can either be the special value ALL,
-or a sequence of ':' separated options. (Note, case is
-significant)
+First the environment variables are applied, then the command line
+options are applied in the order given on the command line.
-As noted below, some of these are useful in application
-debugging, but most are only interested to those debugging
-the libraries
+Each of these can either be the special value ALL, or a sequence of
+':' separated options. (Note, case is significant). The environment
+variables and the --gtk-debug and --gdk-debug options add debugging
+options and the --gtk-no-debug and --gdk-no-debug options remove
+them.
+
+As noted below, some of these are useful in application debugging, but
+most are only interested to those debugging the libraries
+
+For instance:
+
+ GDK_DEBUG_FLAGS=misc:dnd testgtk --gdk-no-debug dnd --gdk-debug events
+
+runs testgtk with the 'misc' and 'events' debugging options.
GTK_DEBUG
---------
'color-context' - Information about the internal workings of
GdkColorContext
'xim' - Information about X Input Method support
+
+
+ - Owen Taylor <owt1@cornell.edu>
+ 98/02/19
\ No newline at end of file
{"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 */
/*
int argc_orig = *argc;
char **argv_orig;
-#ifdef G_ENABLE_DEBUG
- gboolean debug_set = FALSE;
-#endif /* G_ENABLE_DEBUG */
-
argv_orig = malloc ((argc_orig + 1) * sizeof (char*));
for (i = 0; i < argc_orig; i++)
argv_orig[i] = g_strdup ((*argv)[i]);
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,
+ gdk_debug_keys,
+ gdk_ndebug_keys);
+ }
+#endif /* G_ENABLE_DEBUG */
+
if (argc && argv)
{
if (*argc > 0)
for (i = 1; i < *argc;)
{
if ((*argv)[i] == NULL)
- continue;
+ {
+ i += 1;
+ continue;
+ }
#ifdef G_ENABLE_DEBUG
if (strcmp ("--gdk-debug", (*argv)[i]) == 0)
if ((i + 1) < *argc && (*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;
+ gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
+ gdk_debug_keys,
+ gdk_ndebug_keys);
+ (*argv)[i + 1] = NULL;
+ i += 1;
+ }
+ }
+ else if (strcmp ("--gdk-no-debug", (*argv)[i]) == 0)
+ {
+ (*argv)[i] = NULL;
+
+ if ((i + 1) < *argc && (*argv)[i + 1])
+ {
+ gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
+ gdk_debug_keys,
+ gdk_ndebug_keys);
(*argv)[i + 1] = NULL;
i += 1;
}
}
-#endif G_ENABLE_DEBUG
+#endif /* G_ENABLE_DEBUG */
else if (strcmp ("--display", (*argv)[i]) == 0)
{
(*argv)[i] = NULL;
gdk_progname = "<unknown>";
}
-#ifdef G_ENABLE_DEBUG
- 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));
- }
-#endif /* G_ENABLE_DEBUG */
-
gdk_display = XOpenDisplay (gdk_display_name);
if (!gdk_display)
{
break;
}
+#ifdef G_ENABLE_DEBUG
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);
}
+#endif /* G_ENABLE_DEBUG */
if (dnd_drag_perhaps && gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow))
event->crossing.detail = GDK_NOTIFY_UNKNOWN;
break;
}
+#ifdef G_ENABLE_DEBUG
if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps)
{
g_print("We may[%d] have a drag out of %#lx = %#lx\n",
gdk_dnd.drag_really,
xevent->xcrossing.window, real_sw->xwindow);
}
+#endif /* G_ENABLE_DEBUG */
if (dnd_drag_perhaps && !gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow))
{
case VisibilityNotify:
/* Print debugging info.
*/
+#ifdef G_ENABLE_DEBUG
if (gdk_debug_flags & GDK_DEBUG_EVENTS)
switch (xevent->xvisibility.state)
{
xevent->xvisibility.window - base_id);
break;
}
+#endif /* G_ENABLE_DEBUG */
event->visibility.type = GDK_VISIBILITY_NOTIFY;
event->visibility.window = window;
destroyed++;
}
}
+#ifdef G_ENABLE_DEBUG
if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0)
{
g_warning ("Cleaned up %i IC(s)\n", destroyed);
}
+#endif /* G_ENABLE_DEBUG */
g_list_free(xim_ic_list);
xim_ic_list = NULL;
}
{"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 */
/*
int argc_orig = *argc;
char **argv_orig;
-#ifdef G_ENABLE_DEBUG
- gboolean debug_set = FALSE;
-#endif /* G_ENABLE_DEBUG */
-
argv_orig = malloc ((argc_orig + 1) * sizeof (char*));
for (i = 0; i < argc_orig; i++)
argv_orig[i] = g_strdup ((*argv)[i]);
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,
+ gdk_debug_keys,
+ gdk_ndebug_keys);
+ }
+#endif /* G_ENABLE_DEBUG */
+
if (argc && argv)
{
if (*argc > 0)
for (i = 1; i < *argc;)
{
if ((*argv)[i] == NULL)
- continue;
+ {
+ i += 1;
+ continue;
+ }
#ifdef G_ENABLE_DEBUG
if (strcmp ("--gdk-debug", (*argv)[i]) == 0)
if ((i + 1) < *argc && (*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;
+ gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
+ gdk_debug_keys,
+ gdk_ndebug_keys);
+ (*argv)[i + 1] = NULL;
+ i += 1;
+ }
+ }
+ else if (strcmp ("--gdk-no-debug", (*argv)[i]) == 0)
+ {
+ (*argv)[i] = NULL;
+
+ if ((i + 1) < *argc && (*argv)[i + 1])
+ {
+ gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
+ gdk_debug_keys,
+ gdk_ndebug_keys);
(*argv)[i + 1] = NULL;
i += 1;
}
}
-#endif G_ENABLE_DEBUG
+#endif /* G_ENABLE_DEBUG */
else if (strcmp ("--display", (*argv)[i]) == 0)
{
(*argv)[i] = NULL;
gdk_progname = "<unknown>";
}
-#ifdef G_ENABLE_DEBUG
- 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));
- }
-#endif /* G_ENABLE_DEBUG */
-
gdk_display = XOpenDisplay (gdk_display_name);
if (!gdk_display)
{
break;
}
+#ifdef G_ENABLE_DEBUG
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);
}
+#endif /* G_ENABLE_DEBUG */
if (dnd_drag_perhaps && gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow))
event->crossing.detail = GDK_NOTIFY_UNKNOWN;
break;
}
+#ifdef G_ENABLE_DEBUG
if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps)
{
g_print("We may[%d] have a drag out of %#lx = %#lx\n",
gdk_dnd.drag_really,
xevent->xcrossing.window, real_sw->xwindow);
}
+#endif /* G_ENABLE_DEBUG */
if (dnd_drag_perhaps && !gdk_dnd.drag_really &&
(xevent->xcrossing.window == real_sw->xwindow))
{
case VisibilityNotify:
/* Print debugging info.
*/
+#ifdef G_ENABLE_DEBUG
if (gdk_debug_flags & GDK_DEBUG_EVENTS)
switch (xevent->xvisibility.state)
{
xevent->xvisibility.window - base_id);
break;
}
+#endif /* G_ENABLE_DEBUG */
event->visibility.type = GDK_VISIBILITY_NOTIFY;
event->visibility.window = window;
destroyed++;
}
}
+#ifdef G_ENABLE_DEBUG
if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0)
{
g_warning ("Cleaned up %i IC(s)\n", destroyed);
}
+#endif /* G_ENABLE_DEBUG */
g_list_free(xim_ic_list);
xim_ic_list = NULL;
}
\f
/* Other stuff */
+#undef G_COMPILED_WITH_DEBUGGING
#undef HAVE_BROKEN_WCTYPE
#undef HAVE_DOPRNT
#undef HAVE_FLOAT_H
fi
fi
+AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
+
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_STDC
/* Define to empty if the keyword does not work. */
#undef const
+/* Force recompilation when --enable-debug value changes */
+#undef G_COMPILED_WITH_DEBUGGING
+
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT
* widgets.
*/
-guint gtk_debug_flags; /* Global GTK debug flag */
+guint gtk_debug_flags = 0; /* Global GTK debug flag */
#ifdef G_ENABLE_DEBUG
static GDebugKey gtk_debug_keys[] = {
{"objects", GTK_DEBUG_OBJECTS}
};
+
+static const int gtk_ndebug_keys = sizeof(gtk_debug_keys)/sizeof(GDebugKey);
+
#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);
gdk_init (argc, argv);
#ifdef G_ENABLE_DEBUG
+ {
+ gchar *debug_string = getenv("GTK_DEBUG");
+ if (debug_string != NULL)
+ gtk_debug_flags = g_parse_debug_string (debug_string,
+ gtk_debug_keys,
+ gtk_ndebug_keys);
+ }
+
if (argc && argv)
{
gint i;
for (i = 1; i < *argc;)
{
- if ((*argv[i]) && strcmp ("--gtk-debug", (*argv)[i]) == 0)
+ if ((*argv)[i] == NULL)
+ {
+ i += 1;
+ continue;
+ }
+
+ if (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;
+ gtk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
+ gtk_debug_keys,
+ gtk_ndebug_keys);
+ (*argv)[i + 1] = NULL;
+ i += 1;
+ }
+ }
+ else if (strcmp ("--gtk-no-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,
+ gtk_ndebug_keys);
(*argv)[i + 1] = NULL;
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