summaryrefslogtreecommitdiff
path: root/gdk/gdk.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-04-25 22:29:14 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-04-25 22:29:14 +0000
commit425b9886c9e042bc4e8c789e6983127981aca6cf (patch)
tree9ee6face8770b4e4bea7d4b68cb4e31cb2aa86ab /gdk/gdk.c
parente39e92123b156b6a470d54fd4d9000d7eedcf478 (diff)
downloadgtk+-425b9886c9e042bc4e8c789e6983127981aca6cf.tar.gz
Start of integration of Erwann Chenede's multihead work from the
Thu Apr 25 16:51:40 2002 Owen Taylor <otaylor@redhat.com> Start of integration of Erwann Chenede's multihead work from the gtk-multihead branch. * gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkscreen-x11.[ch] New classes representing a set of screens with attached input devices and a single contiguous area, respectively. * gdk/gdk.[ch] gdk/gdkinternals.h gdk/x11/gdkmain-x11.c: gdk/x11/gdkprivate-x11.h: Make the initialization interface simple _gdk_windowing_init() and do the rest in gdk_open_display() calls. * gdk/gdk.[ch]: Add gdk_parse_args() which can be used to do the display-independent part of initialization instead of gdk_init_[check]. * gdk/gdkcursor.h gdk/gdkfont.h gdk/gdkkeys.h gdk/gdkpixmap.h gdk/gdkproperty.h gdk/gdkselection.h gdk/gdkwindow.h: Add multihead variants (_for_display(), for_screen()) of functions getting information specific to a particular screen screen or display. * gdk/gdkscreen.[ch]: Add gdk_screen__* variants of functions like gdk_rgb_get_colormap() that used to get/list global objects. * gdk/x11/gdkx.h: Add functions for converting GdkScreen and GdkDisplay into the X equivalents. * gdk/x11/gdkwindow-x11.c: Removed gdk_window_xid_at_coords() not in the headers and unused. * configure.in gdk/x11/{gxid.c,gxid_lib.[ch],gdkinput-gxi.c}: Remove gxid support ... has not been tested for a long time... "xfree" support is more portable to non XFree86. * gdk/**.h: Add a GDK_MULTIHEAD_SAFE define that can be used to turn off functions that are inherently non-multihead safe. * gdk/**.c: add GDK_NOTE(multihead, ...) calls when functions are used in non-multihead-safe ways. * gdk/*.c gdk/x11/*.c: Changes to make the internals of GDK multihead safe.
Diffstat (limited to 'gdk/gdk.c')
-rw-r--r--gdk/gdk.c159
1 files changed, 106 insertions, 53 deletions
diff --git a/gdk/gdk.c b/gdk/gdk.c
index 097a396422..8f6d99ec37 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -51,6 +51,8 @@ static int gdk_initialized = 0; /* 1 if the library is initialized,
*/
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[] = {
@@ -66,6 +68,7 @@ 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);
@@ -233,8 +236,10 @@ gdk_arg_name_cb (const char *key, const char *value, gpointer user_data)
}
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 },
@@ -242,49 +247,53 @@ static GdkArgDesc gdk_args[] = {
{ 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)
{
@@ -301,13 +310,13 @@ gdk_init_check (int *argc,
{
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
{
@@ -328,26 +337,70 @@ gdk_init_check (int *argc,
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
@@ -355,7 +408,7 @@ gdk_init (int *argc, char ***argv)
{
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);
}
}