*/
static gchar *gdk_progclass = NULL;
+static gint gdk_argc = 0;
+static gchar **gdk_argv = NULL;
#ifdef G_ENABLE_DEBUG
static const GDebugKey gdk_debug_keys[] = {
{"image", GDK_DEBUG_IMAGE},
{"input", GDK_DEBUG_INPUT},
{"cursor", GDK_DEBUG_CURSOR},
+ {"multihead", GDK_DEBUG_MULTIHEAD},
};
static const int gdk_ndebug_keys = G_N_ELEMENTS (gdk_debug_keys);
}
static GdkArgDesc gdk_args[] = {
- { "class" , GDK_ARG_CALLBACK, NULL, gdk_arg_class_cb },
- { "name", GDK_ARG_CALLBACK, NULL, gdk_arg_name_cb },
+ { "class" , GDK_ARG_CALLBACK, NULL, gdk_arg_class_cb },
+ { "name", GDK_ARG_CALLBACK, NULL, gdk_arg_name_cb },
+ { "display", GDK_ARG_STRING, &_gdk_display_name, (GdkArgFunc)NULL },
+
#ifdef G_ENABLE_DEBUG
{ "gdk-debug", GDK_ARG_CALLBACK, NULL, gdk_arg_debug_cb },
{ "gdk-no-debug", GDK_ARG_CALLBACK, NULL, gdk_arg_no_debug_cb },
{ NULL }
};
-/*
- *--------------------------------------------------------------
- * gdk_init_check
- *
- * Initialize the library for use.
- *
- * Arguments:
- * "argc" is the number of arguments.
- * "argv" is an array of strings.
- *
- * Results:
- * "argc" and "argv" are modified to reflect any arguments
- * which were not handled. (Such arguments should either
- * be handled by the application or dismissed). If initialization
- * fails, returns FALSE, otherwise TRUE.
+
+/**
+ * _gdk_get_command_line_args:
+ * @argv: location to store argv pointer
+ * @argc: location
+ *
+ * Retrieve the command line arguments passed to gdk_init().
+ * The returned argv pointer points to static storage ; no
+ * copy is made.
+ **/
+void
+_gdk_get_command_line_args (int *argc,
+ char ***argv)
+{
+ *argc = gdk_argc;
+ *argv = gdk_argv;
+}
+
+/**
+ * gdk_parse_args:
+ * @argc: the number of command line arguments.
+ * @argv: the array of command line arguments.
+ *
+ * Parse command line arguments, and store for future
+ * use by calls to gdk_open_display().
*
- * Side effects:
- * The library is initialized.
+ * Any arguments used by GDK are removed from the array and @argc and @argv are
+ * updated accordingly.
*
- *--------------------------------------------------------------
- */
-
-gboolean
-gdk_init_check (int *argc,
+ * You shouldn't call this function explicitely if you are using
+ * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
+ **/
+void
+gdk_parse_args (int *argc,
char ***argv)
{
- gchar **argv_orig = NULL;
- gint argc_orig = 0;
GdkArgContext *arg_context;
- gboolean result;
- int i;
-
- if (gdk_initialized)
- return TRUE;
+ gint i;
if (argc && argv)
{
- argc_orig = *argc;
+ gdk_argc = *argc;
- argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
- for (i = 0; i < argc_orig; i++)
- argv_orig[i] = g_strdup ((*argv)[i]);
- argv_orig[argc_orig] = NULL;
+ gdk_argv = g_malloc ((gdk_argc + 1) * sizeof (char*));
+ for (i = 0; i < gdk_argc; i++)
+ gdk_argv[i] = g_strdup ((*argv)[i]);
+ gdk_argv[gdk_argc] = NULL;
if (*argc > 0)
{
{
g_set_prgname ("<unknown>");
}
-
+
/* We set the fallback program class here, rather than lazily in
* gdk_get_program_class, since we don't want -name to override it.
*/
gdk_progclass = g_strdup (g_get_prgname ());
if (gdk_progclass[0])
- gdk_progclass[0] = g_ascii_toupper (gdk_progclass[0]);
+ gdk_progclass[0] = g_ascii_toupper (gdk_progclass[0]);
#ifdef G_ENABLE_DEBUG
{
GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
g_type_init ();
-
- result = _gdk_windowing_init_check (argc_orig, argv_orig);
- for (i = 0; i < argc_orig; i++)
- g_free(argv_orig[i]);
- g_free(argv_orig);
+ /* Do any setup particular to the windowing system
+ */
+ _gdk_windowing_init ();
+}
+
+/**
+ * gdk_get_display_arg_name:
+ *
+ * Gets the display name specified in the command line arguments passed
+ * to gdk_init() or gdk_parse_args(), if any.
+ *
+ * Returns: the display name, if specified explicitely, otherwise %NULL
+ */
+gchar *
+gdk_get_display_arg_name (void)
+{
+ return _gdk_display_name;
+}
- if (!result)
- return FALSE;
+/*
+ *--------------------------------------------------------------
+ * gdk_init_check
+ *
+ * Initialize the library for use.
+ *
+ * Arguments:
+ * "argc" is the number of arguments.
+ * "argv" is an array of strings.
+ *
+ * Results:
+ * "argc" and "argv" are modified to reflect any arguments
+ * which were not handled. (Such arguments should either
+ * be handled by the application or dismissed). If initialization
+ * fails, returns FALSE, otherwise TRUE.
+ *
+ * Side effects:
+ * The library is initialized.
+ *
+ *--------------------------------------------------------------
+ */
+
+gboolean
+gdk_init_check (int *argc,
+ char ***argv)
+{
+ GdkDisplay *display;
- _gdk_visual_init ();
- _gdk_windowing_window_init ();
- _gdk_windowing_image_init ();
- _gdk_events_init ();
- _gdk_input_init ();
- _gdk_dnd_init ();
+ if (gdk_initialized)
+ return TRUE;
+
+ gdk_parse_args (argc, argv);
gdk_initialized = 1;
- return TRUE;
+ display = gdk_open_display (_gdk_display_name);
+
+ if (display)
+ {
+ gdk_set_default_display (display);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
void
{
if (!gdk_init_check (argc, argv))
{
- g_warning ("cannot open display: %s", gdk_get_display ());
+ g_warning ("cannot open display: %s", gdk_get_display_arg_name ());
exit(1);
}
}