[patch] gdk doesn't recognize "--display=foobar:0"



Hi all.

I sent this to submit bugs gnome org, but since "all controls are
on manual" and I didn't get a confirmation, I thought I'd send it here
as well.

The problem is no gnome apps use the --display options.
Its listed but always ignored.

I tracked it down to the following:
gnome_init uses popt to build the argv to pass to gtk_init.
It does this by roughly 'g_strconcat (option, "=", value, NULL);'

However all the way down in gdk/gdk.c in the gtk+ package,
gdk is not accepting "display=host:0", only "display host:0"

The attached patch fixes this and the other cases that weren't
accepting "option=value". Only the display option has been
tested though.

I've cross posted to gtk-devel since that's where the problem lies
and gnome-devel since that's where the symptoms occur. If you
followup only on gtk-devel, please cc me as I'm not subscribed there.

Thanks,
Sam


Here's the original bug report
----- Forwarded message from Samuel S Hunter II <shunter bigsky net> -----

Date: Wed, 18 Oct 2000 19:00:27 -0600
From: Samuel S Hunter II <shunter bigsky net>
To: submit bugs gnome org
Subject: gdk doesn't recognize "--display=foobar:0" 

Package: gtk+
Version: 1.2.8 

A co-worker asked why gnome programs aren't accepting
--display=hostname:0. I spent a little time on it and
tracked it down to gdk/gdk.c not accepting the "=" sign.

Since some of the other gdk.c options and all of the gtkmain.c
options work with or without "=", I patched gdk/gdk.c to handle
the "=" sign for all its options (those with args, of course).

I've only really tested the --display= option, I don't use any
of the other options. But thought it better to catch them all
for completeness.

The patch is attached. I tried hard to match gtk's style,
as much as it pained me :)

Its against gtk+-1.2.8, but I just verified it applies cleanly
against the most recent gtk-1-2 branch.

Sam
--- gtk+-1.2.8/gdk/gdk.c.orig	Wed Oct 18 16:30:53 2000
+++ gtk+-1.2.8/gdk/gdk.c	Wed Oct 18 17:35:46 2000
@@ -259,16 +259,27 @@
 	    }
 	  else 
 #endif /* G_ENABLE_DEBUG */
-	    if (strcmp ("--display", (*argv)[i]) == 0)
+	    if ((strcmp ("--display", (*argv)[i]) == 0) ||
+	        (strncmp ("--display=", (*argv)[i], 10) == 0))
 	      {
+	      	gchar *equal_pos = strchr ((*argv)[i], '=');
+
 		(*argv)[i] = NULL;
-		
-		if ((i + 1) < *argc && (*argv)[i + 1])
+
+		if (equal_pos != NULL)
 		  {
-		    gdk_display_name = g_strdup ((*argv)[i + 1]);
-		    (*argv)[i + 1] = NULL;
-		    i += 1;
+		    gdk_display_name = g_strdup (equal_pos+1);
 		  }
+		else
+		  {
+		    if ((i + 1) < *argc && (*argv)[i + 1])
+		    {
+		      gdk_display_name = g_strdup ((*argv)[i + 1]);
+		      (*argv)[i + 1] = NULL;
+		      i += 1;
+		    }
+		  }
+
 	      }
 	    else if (strcmp ("--sync", (*argv)[i]) == 0)
 	      {
@@ -280,77 +291,163 @@
 		(*argv)[i] = NULL;
 		gdk_use_xshm = FALSE;
 	      }
-	    else if (strcmp ("--name", (*argv)[i]) == 0)
+	    else if ((strcmp ("--name", (*argv)[i]) == 0) ||
+		     (strncmp ("--name=", (*argv)[i], 7) == 0))
 	      {
-		if ((i + 1) < *argc && (*argv)[i + 1])
+	      	gchar *equal_pos = strchr ((*argv)[i], '=');
+
+		(*argv)[i] = NULL;
+
+		if (equal_pos != NULL)
 		  {
-		    (*argv)[i++] = NULL;
-		    g_set_prgname ((*argv)[i]);
-		    (*argv)[i] = NULL;
+		    g_set_prgname (equal_pos+1);
+		  }
+		else
+		  {
+		    if ((i + 1) < *argc && (*argv)[i + 1])
+		      {
+			g_set_prgname ((*argv)[i + 1]);
+			(*argv)[i + 1] = NULL;
+			i += 1;
+		      }
 		  }
 	      }
-	    else if (strcmp ("--class", (*argv)[i]) == 0)
+	    else if ((strcmp ("--class", (*argv)[i]) == 0) ||
+		     (strncmp ("--class=", (*argv)[i], 8) == 0))
 	      {
-		if ((i + 1) < *argc && (*argv)[i + 1])
+	      	gchar *equal_pos = strchr ((*argv)[i], '=');
+
+		(*argv)[i] = NULL;
+
+		if (equal_pos != NULL)
 		  {
-		    (*argv)[i++] = NULL;
-		    gdk_progclass = (*argv)[i];
-		    (*argv)[i] = NULL;
+		    gdk_progclass = equal_pos + 1;
+		  }
+		else
+		  { 		    
+		    if ((i + 1) < *argc && (*argv)[i + 1])
+		      {
+			gdk_progclass = (*argv)[i + 1];
+			(*argv)[i + 1] = NULL;
+			i += 1;
+		      }
 		  }
 	      }
 #ifdef XINPUT_GXI
-	    else if (strcmp ("--gxid_host", (*argv)[i]) == 0)
+	    else if ((strcmp ("--gxid_host", (*argv)[i]) == 0) ||
+		     (strncmp ("--gxid_host=", (*argv)[i], 12) == 0))
 	      {
-		if ((i + 1) < *argc && (*argv)[i + 1])
+	      	gchar *equal_pos = strchr ((*argv)[i], '=');
+
+		(*argv)[i] = NULL;
+
+		if (equal_pos != NULL)
 		  {
-		    (*argv)[i++] = NULL;
-		    gdk_input_gxid_host = ((*argv)[i]);
-		    (*argv)[i] = NULL;
+		    gdk_input_gxid_host = equal_pos + 1;
+		  }
+		else
+		  {
+		    if ((i + 1) < *argc && (*argv)[i + 1])
+		      {
+			gdk_input_gxid_host = ((*argv)[i + 1]);
+			(*argv)[i + 1] = NULL;
+			i += 1;
+		      }
 		  }
 	      }
-	    else if (strcmp ("--gxid_port", (*argv)[i]) == 0)
+	    else if ((strcmp ("--gxid_port", (*argv)[i]) == 0) ||
+		     (strncmp ("--gxid_port=", (*argv)[i], 12) == 0))
 	      {
-		if ((i + 1) < *argc && (*argv)[i + 1])
+	      	gchar *equal_pos = strchr ((*argv)[i], '=');
+
+		(*argv)[i] = NULL;
+
+		if (equal_pos != NULL)
 		  {
-		    (*argv)[i++] = NULL;
-		    gdk_input_gxid_port = atoi ((*argv)[i]);
-		    (*argv)[i] = NULL;
+		    gdk_input_gxid_port = equal_pos + 1;
+		  }
+		else
+		  {
+		    if ((i + 1) < *argc && (*argv)[i + 1])
+		      {
+			gdk_input_gxid_port = atoi ((*argv)[i + 1]);
+			(*argv)[i + 1] = NULL;
+			i += 1;
+		      }
 		  }
 	      }
 #endif
 #ifdef USE_XIM
-	    else if (strcmp ("--xim-preedit", (*argv)[i]) == 0)
+	    else if ((strcmp ("--xim-preedit", (*argv)[i]) == 0) ||
+		     (strncmp ("--xim-preedit=", (*argv)[i], 14) == 0))
 	      {
-		if ((i + 1) < *argc && (*argv)[i + 1])
+	      	gchar *equal_pos = strchr ((*argv)[i], '=');
+		gchar *best_style = NULL;
+
+		(*argv)[i] = NULL;
+
+		if (equal_pos != NULL)
 		  {
-		    (*argv)[i++] = NULL;
-		    if (strcmp ("none", (*argv)[i]) == 0)
+		    best_style = equal_pos + 1;
+		  }
+		else
+		  {
+		  
+		    if ((i + 1) < *argc && (*argv)[i + 1])
+		      {
+			best_style = (*argv)[i + 1];
+			(*argv)[i + 1] = NULL;
+			i += 1;
+		      }
+		  }
+
+		if (best_style != NULL)
+		  {
+		    if (strcmp ("none", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
-		    else if (strcmp ("nothing", (*argv)[i]) == 0)
+		    else if (strcmp ("nothing", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
-		    else if (strcmp ("area", (*argv)[i]) == 0)
+		    else if (strcmp ("area", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
-		    else if (strcmp ("position", (*argv)[i]) == 0)
+		    else if (strcmp ("position", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
-		    else if (strcmp ("callbacks", (*argv)[i]) == 0)
+		    else if (strcmp ("callbacks", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
-		    (*argv)[i] = NULL;
 		  }
 	      }
-	    else if (strcmp ("--xim-status", (*argv)[i]) == 0)
+	    else if ((strcmp ("--xim-status", (*argv)[i]) == 0) ||
+		     (strncmp ("--xim-status=", (*argv)[i], 13) == 0))
 	      {
-		if ((i + 1) < *argc && (*argv)[i + 1])
+	      	gchar *equal_pos = strchr ((*argv)[i], '=');
+		gchar *best_style = NULL;
+
+		(*argv)[i] = NULL;
+
+		if (equal_pos != NULL)
 		  {
-		    (*argv)[i++] = NULL;
-		    if (strcmp ("none", (*argv)[i]) == 0)
+		    best_style = equal_pos + 1;
+		  }
+		else
+		  {
+		  
+		    if ((i + 1) < *argc && (*argv)[i + 1])
+		      {
+			best_style = (*argv)[i + 1];
+			(*argv)[i + 1] = NULL;
+			i += 1;
+		      }
+		  }
+
+		if (best_style != NULL)
+		  {
+		    if (strcmp ("none", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_STATUS_NONE);
-		    else if (strcmp ("nothing", (*argv)[i]) == 0)
+		    else if (strcmp ("nothing", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
-		    else if (strcmp ("area", (*argv)[i]) == 0)
+		    else if (strcmp ("area", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_STATUS_AREA);
-		    else if (strcmp ("callbacks", (*argv)[i]) == 0)
+		    else if (strcmp ("callbacks", best_style) == 0)
 		      gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
-		    (*argv)[i] = NULL;
 		  }
 	      }
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]