Patch to allow setting of initial position
Hi, for a TV Terminal I needed dillo to come up at a different position than 0,0. As there is no window manager running I wrote a small patch which allows to set the initial position of the upper left corner. Essentially it just clones the geometry code and adds a config option position=<xpos>x<ypos>. If it is not set or 0x0 specified it just takes it's default position. Perhaps this is of some use to anyone else. (Patch is against 0.7.3) Thanks, Jan diff -u org/src/dillo.c jan/src/dillo.c --- org/src/dillo.c Tue Jul 22 22:51:22 2003 +++ jan/src/dillo.c Fri Nov 28 14:34:35 2003 @@ -268,6 +268,8 @@ /* a_Nav_init() has been moved into this call because it needs to be * initialized with the new browser_window structure */ bw = a_Interface_browser_window_new(prefs.width, prefs.height, xid); + if ((prefs.xpos + prefs.ypos) > 0) + gtk_widget_set_uposition(bw->main_window, prefs.xpos, prefs.ypos); a_Bookmarks_init(); diff -u org/src/prefs.c jan/src/prefs.c --- org/src/prefs.c Mon Jul 7 17:40:15 2003 +++ jan/src/prefs.c Fri Nov 28 14:39:21 2003 @@ -35,6 +35,7 @@ guint token; } symbols[] = { { "geometry", DRC_TOKEN_GEOMETRY }, + { "position", DRC_TOKEN_POSITION }, { "http_proxy", DRC_TOKEN_PROXY }, { "no_proxy", DRC_TOKEN_NOPROXY }, { "link_color", DRC_TOKEN_LINK_COLOR }, @@ -114,6 +115,18 @@ } } break; + case DRC_TOKEN_POSITION: { + gchar *ptr, *str = scanner->value.v_string; + gint xpos, ypos; + + if ( (ptr = strchr(str, 'x')) && (xpos = strtol(str,NULL,10)) && + (ypos = strtol(++ptr,NULL,10)) ){ + prefs.xpos = xpos; + prefs.ypos = ypos; + } + } + break; + case DRC_TOKEN_PROXY: a_Url_free(prefs.http_proxy); prefs.http_proxy = a_Url_new(scanner->value.v_string, NULL, 0, 0); @@ -329,6 +342,8 @@ prefs.width = D_GEOMETRY_DEFAULT_WIDTH; prefs.height = D_GEOMETRY_DEFAULT_HEIGHT; + prefs.xpos = D_GEOMETRY_DEFAULT_XPOS; + prefs.ypos = D_GEOMETRY_DEFAULT_YPOS; prefs.http_proxy = NULL; prefs.no_proxy = NULL; prefs.no_proxy_vec = NULL; diff -u org/src/prefs.h jan/src/prefs.h --- org/src/prefs.h Thu Jul 10 00:00:34 2003 +++ jan/src/prefs.h Fri Nov 28 14:37:17 2003 @@ -10,6 +10,8 @@ #define DILLO_HOME "http://www.dillo.org/" #define D_GEOMETRY_DEFAULT_WIDTH 640 #define D_GEOMETRY_DEFAULT_HEIGHT 550 +#define D_GEOMETRY_DEFAULT_XPOS 0 +#define D_GEOMETRY_DEFAULT_YPOS 0 #define DW_COLOR_DEFAULT_GREY 0xd6d6d6 #define DW_COLOR_DEFAULT_BLACK 0x000000 @@ -27,6 +29,7 @@ typedef enum { DRC_TOKEN_FIRST = G_TOKEN_LAST, DRC_TOKEN_GEOMETRY, + DRC_TOKEN_POSITION, DRC_TOKEN_PROXY, DRC_TOKEN_NOPROXY, DRC_TOKEN_LINK_COLOR, @@ -70,6 +73,8 @@ struct _DilloPrefs { gint width; gint height; + gint xpos; + gint ypos; DilloUrl *http_proxy; gchar *no_proxy; gchar **no_proxy_vec;
On Fri, 28 Nov 2003, Jan Dittmer wrote:
Hi,
for a TV Terminal I needed dillo to come up at a different position than 0,0. As there is no window manager running I wrote a small patch which allows to set the initial position of the upper left corner. Essentially it just clones the geometry code and adds a config option position=<xpos>x<ypos>. If it is not set or 0x0 specified it just takes it's default position. Perhaps this is of some use to anyone else. (Patch is against 0.7.3)
I understand. Maybe the "canonical" solution to this problem is to add support for the geometry CLI option. That is: -geometry <width>x<height>{+-}<x>{+-}<y> Can you make the patch this way? Cheers Jorge.-
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jorge Arellano Cid wrote: | | I understand. Maybe the "canonical" solution to this problem is | to add support for the geometry CLI option. | | That is: | | -geometry <width>x<height>{+-}<x>{+-}<y> | | Can you make the patch this way? | Here is a preliminary version. Only problem is that entering it in the dillorc doesn't work, because the parser doesn't recognize the + as part of a string resulting in these errors: dillorc:2: unexpected character `+', expected symbol dillorc:2: unexpected character `0', expected symbol dillorc:2: unexpected character `+', expected symbol dillorc:2: unexpected character `0', expected symbol dillorc:2: error: unexpected character `0', expected symbol So I tried changing - - "~-_:&%#/.0123456789" + "~-_:&%#/.0123456789+" in prefs.c, which doesn't work. How the parse be changed that it recognizes + as part of the value? Thanks, Jan -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQE/ygYdLqMJRclVKIYRApfZAJ4jb1fc3Dd8OrMB+Csgyekz74VikwCfaFv5 s7AZVApr+hS8dRtKK97kS0Y= =axoU -----END PGP SIGNATURE----- Common subdirectories: org/src/IO and jan/src/IO diff -u org/src/dillo.c jan/src/dillo.c --- org/src/dillo.c Tue Jul 22 22:51:22 2003 +++ jan/src/dillo.c Sun Nov 30 15:59:29 2003 @@ -21,6 +21,7 @@ #include <stdio.h> #include <gtk/gtk.h> +#include <X11/Xlib.h> #include <sys/types.h> #include <sys/stat.h> @@ -66,6 +67,7 @@ DILLO_CLI_HELP = 1 << 3, DILLO_CLI_VERSION = 1 << 4, DILLO_CLI_LOCAL = 1 << 5, + DILLO_CLI_GEOMETRY = 1 << 6, DILLO_CLI_ERROR = 1 << 31 }; @@ -98,6 +100,9 @@ " -f, --fullwindow Start in full window mode."}, {"-l", "--local", 0, DILLO_CLI_LOCAL, " -l, --local Don't follow links for this URL(s)."}, + {"-g", "-geometry", 1, DILLO_CLI_GEOMETRY, + " -g, -geometry GEO Set initial window position where GEO is\n" + " <width>x<height>{+-}<x>{+-}<y>"}, {NULL, NULL, 0, 0, NULL} }; @@ -194,6 +199,8 @@ guint opt_flg; gint i; char **opt_argv = NULL; + gint xpos = D_GEOMETRY_DEFAULT_XPOS, ypos = D_GEOMETRY_DEFAULT_YPOS; + gint width = D_GEOMETRY_DEFAULT_WIDTH, height = D_GEOMETRY_DEFAULT_HEIGHT; /* set locale */ curr_locale = g_strdup(setlocale(LC_ALL, NULL)); @@ -226,6 +233,11 @@ case DILLO_CLI_FULLWINDOW: case DILLO_CLI_LOCAL: break; + case DILLO_CLI_GEOMETRY: + if ( XParseGeometry(opt_argv[0], &xpos, &ypos, &width, &height) ) { + g_print("Setting geometry from CLI to %dx%d %d %d\n", width, height, xpos, ypos); + break; + } default: g_print("Error in command line options.\n"); return -1; @@ -265,9 +277,18 @@ if (options_got & DILLO_CLI_FULLWINDOW) prefs.fullwindow_start = TRUE; + /* override dillorc geometry */ + if (options_got & DILLO_CLI_GEOMETRY) { + prefs.width = width; + prefs.height = height; + prefs.xpos = xpos; + prefs.ypos = ypos; + } /* a_Nav_init() has been moved into this call because it needs to be * initialized with the new browser_window structure */ bw = a_Interface_browser_window_new(prefs.width, prefs.height, xid); + if ( (prefs.xpos != D_GEOMETRY_DEFAULT_XPOS) && (prefs.ypos != D_GEOMETRY_DEFAULT_YPOS) ) + gtk_widget_set_uposition(bw->main_window, prefs.xpos, prefs.ypos); a_Bookmarks_init(); diff -u org/src/prefs.c jan/src/prefs.c --- org/src/prefs.c Mon Jul 7 17:40:15 2003 +++ jan/src/prefs.c Sun Nov 30 16:00:14 2003 @@ -19,6 +19,8 @@ */ #include <glib.h> +#include <gtk/gtk.h> +#include <X11/Xlib.h> #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> @@ -104,14 +106,9 @@ /* assign value and exit successfully */ switch (symbol) { case DRC_TOKEN_GEOMETRY: { - gchar *ptr, *str = scanner->value.v_string; - gint width, height; - - if ( (ptr = strchr(str, 'x')) && (width = strtol(str,NULL,10)) && - (height = strtol(++ptr,NULL,10)) ){ - prefs.width = width; - prefs.height = height; - } + gchar *str = scanner->value.v_string; + XParseGeometry(str, &prefs.xpos, &prefs.ypos, &prefs.width, &prefs.height); + g_print("Setting geometry from rc to %dx%d %d %d\n", prefs.width, prefs.height, prefs.xpos, prefs.ypos); } break; case DRC_TOKEN_PROXY: @@ -261,7 +258,7 @@ /* Specifies the chars which can be used in identifiers */ scanner->config->cset_identifier_nth = ( G_CSET_a_2_z - "~-_:&%#/.0123456789" + "~-_:&%#/.0123456789+" G_CSET_A_2_Z G_CSET_LATINS /*??? I don't know if we need these two */ G_CSET_LATINC /*??? */ @@ -329,6 +326,8 @@ prefs.width = D_GEOMETRY_DEFAULT_WIDTH; prefs.height = D_GEOMETRY_DEFAULT_HEIGHT; + prefs.xpos = D_GEOMETRY_DEFAULT_XPOS; + prefs.ypos = D_GEOMETRY_DEFAULT_YPOS; prefs.http_proxy = NULL; prefs.no_proxy = NULL; prefs.no_proxy_vec = NULL; diff -u org/src/prefs.h jan/src/prefs.h --- org/src/prefs.h Thu Jul 10 00:00:34 2003 +++ jan/src/prefs.h Sun Nov 30 15:29:57 2003 @@ -10,6 +10,8 @@ #define DILLO_HOME "http://www.dillo.org/" #define D_GEOMETRY_DEFAULT_WIDTH 640 #define D_GEOMETRY_DEFAULT_HEIGHT 550 +#define D_GEOMETRY_DEFAULT_XPOS -9999 +#define D_GEOMETRY_DEFAULT_YPOS -9999 #define DW_COLOR_DEFAULT_GREY 0xd6d6d6 #define DW_COLOR_DEFAULT_BLACK 0x000000 @@ -70,6 +72,8 @@ struct _DilloPrefs { gint width; gint height; + gint xpos; + gint ypos; DilloUrl *http_proxy; gchar *no_proxy; gchar **no_proxy_vec;
It works for me with today's CVS and your patch. in dillorc: geometry=320x200+50+50 dillo.pos/src>./dillo Setting geometry from rc to 320x200 50 50 ... The only problem, it seems, is that it still prints the dillorc setting, even when the CLI option is used: dillo.pos/src>./dillo -geometry 700x100+10+400 Setting geometry from CLI to 700x100 10 400 Setting geometry from rc to 320x200 50 50 ... The first one is actually used, but having the second message is confusing. Best, EG -- En reponse de "Re: [Dillo-dev] Patch to allow setting of initial position" de Jan Dittmer, le 30-Nov-2003 :
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Jorge Arellano Cid wrote: | | I understand. Maybe the "canonical" solution to this problem is | to add support for the geometry CLI option. | | That is: | | -geometry <width>x<height>{+-}<x>{+-}<y> | | Can you make the patch this way? |
Here is a preliminary version. Only problem is that entering it in the dillorc doesn't work, because the parser doesn't recognize the + as part of a string resulting in these errors:
dillorc:2: unexpected character `+', expected symbol dillorc:2: unexpected character `0', expected symbol dillorc:2: unexpected character `+', expected symbol dillorc:2: unexpected character `0', expected symbol dillorc:2: error: unexpected character `0', expected symbol
So I tried changing
- - "~-_:&%#/.0123456789" + "~-_:&%#/.0123456789+"
in prefs.c, which doesn't work. How the parse be changed that it recognizes + as part of the value?
Thanks,
Jan -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQE/ygYdLqMJRclVKIYRApfZAJ4jb1fc3Dd8OrMB+Csgyekz74VikwCfaFv5 s7AZVApr+hS8dRtKK97kS0Y= =axoU -----END PGP SIGNATURE-----
------------------------------------------------------------------------ Eric GAUDET <eric@rti-zone.org> Le 30-Nov-2003 a 13:41:12 "Parler pour ne rien dire et ne rien dire pour parler sont les deux principes majeurs et rigoureux de tous ceux qui feraient mieux de la fermer avant de l'ouvrir." ------------------------------------------------------------------------
Eric GAUDET wrote:
It works for me with today's CVS and your patch.
in dillorc: geometry=320x200+50+50
dillo.pos/src>./dillo Setting geometry from rc to 320x200 50 50 ...
The only problem, it seems, is that it still prints the dillorc setting, even when the CLI option is used:
dillo.pos/src>./dillo -geometry 700x100+10+400 Setting geometry from CLI to 700x100 10 400 Setting geometry from rc to 320x200 50 50 ...
The first one is actually used, but having the second message is confusing.
Those can probably both go entirely. It was more for debug uses. Here is an updated patch with those removed. Jan Common subdirectories: org/src/IO and jan/src/IO diff -u org/src/dillo.c jan/src/dillo.c --- org/src/dillo.c Tue Jul 22 22:51:22 2003 +++ jan/src/dillo.c Sun Nov 30 22:48:24 2003 @@ -21,6 +21,7 @@ #include <stdio.h> #include <gtk/gtk.h> +#include <X11/Xlib.h> #include <sys/types.h> #include <sys/stat.h> @@ -66,6 +67,7 @@ DILLO_CLI_HELP = 1 << 3, DILLO_CLI_VERSION = 1 << 4, DILLO_CLI_LOCAL = 1 << 5, + DILLO_CLI_GEOMETRY = 1 << 6, DILLO_CLI_ERROR = 1 << 31 }; @@ -98,6 +100,9 @@ " -f, --fullwindow Start in full window mode."}, {"-l", "--local", 0, DILLO_CLI_LOCAL, " -l, --local Don't follow links for this URL(s)."}, + {"-g", "-geometry", 1, DILLO_CLI_GEOMETRY, + " -g, -geometry GEO Set initial window position where GEO is\n" + " <width>x<height>{+-}<x>{+-}<y>"}, {NULL, NULL, 0, 0, NULL} }; @@ -194,6 +199,8 @@ guint opt_flg; gint i; char **opt_argv = NULL; + gint xpos = D_GEOMETRY_DEFAULT_XPOS, ypos = D_GEOMETRY_DEFAULT_YPOS; + gint width = D_GEOMETRY_DEFAULT_WIDTH, height = D_GEOMETRY_DEFAULT_HEIGHT; /* set locale */ curr_locale = g_strdup(setlocale(LC_ALL, NULL)); @@ -226,6 +233,9 @@ case DILLO_CLI_FULLWINDOW: case DILLO_CLI_LOCAL: break; + case DILLO_CLI_GEOMETRY: + if ( XParseGeometry(opt_argv[0], &xpos, &ypos, &width, &height) ) + break; default: g_print("Error in command line options.\n"); return -1; @@ -265,9 +275,18 @@ if (options_got & DILLO_CLI_FULLWINDOW) prefs.fullwindow_start = TRUE; + /* override dillorc geometry */ + if (options_got & DILLO_CLI_GEOMETRY) { + prefs.width = width; + prefs.height = height; + prefs.xpos = xpos; + prefs.ypos = ypos; + } /* a_Nav_init() has been moved into this call because it needs to be * initialized with the new browser_window structure */ bw = a_Interface_browser_window_new(prefs.width, prefs.height, xid); + if ( (prefs.xpos != D_GEOMETRY_DEFAULT_XPOS) && (prefs.ypos != D_GEOMETRY_DEFAULT_YPOS) ) + gtk_widget_set_uposition(bw->main_window, prefs.xpos, prefs.ypos); a_Bookmarks_init(); diff -u org/src/prefs.c jan/src/prefs.c --- org/src/prefs.c Mon Jul 7 17:40:15 2003 +++ jan/src/prefs.c Sun Nov 30 22:48:36 2003 @@ -19,6 +19,8 @@ */ #include <glib.h> +#include <gtk/gtk.h> +#include <X11/Xlib.h> #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> @@ -104,14 +106,8 @@ /* assign value and exit successfully */ switch (symbol) { case DRC_TOKEN_GEOMETRY: { - gchar *ptr, *str = scanner->value.v_string; - gint width, height; - - if ( (ptr = strchr(str, 'x')) && (width = strtol(str,NULL,10)) && - (height = strtol(++ptr,NULL,10)) ){ - prefs.width = width; - prefs.height = height; - } + gchar *str = scanner->value.v_string; + XParseGeometry(str, &prefs.xpos, &prefs.ypos, &prefs.width, &prefs.height); } break; case DRC_TOKEN_PROXY: @@ -261,7 +257,7 @@ /* Specifies the chars which can be used in identifiers */ scanner->config->cset_identifier_nth = ( G_CSET_a_2_z - "~-_:&%#/.0123456789" + "~-_:&%#/.0123456789+" G_CSET_A_2_Z G_CSET_LATINS /*??? I don't know if we need these two */ G_CSET_LATINC /*??? */ @@ -329,6 +325,8 @@ prefs.width = D_GEOMETRY_DEFAULT_WIDTH; prefs.height = D_GEOMETRY_DEFAULT_HEIGHT; + prefs.xpos = D_GEOMETRY_DEFAULT_XPOS; + prefs.ypos = D_GEOMETRY_DEFAULT_YPOS; prefs.http_proxy = NULL; prefs.no_proxy = NULL; prefs.no_proxy_vec = NULL; diff -u org/src/prefs.h jan/src/prefs.h --- org/src/prefs.h Thu Jul 10 00:00:34 2003 +++ jan/src/prefs.h Sun Nov 30 15:29:57 2003 @@ -10,6 +10,8 @@ #define DILLO_HOME "http://www.dillo.org/" #define D_GEOMETRY_DEFAULT_WIDTH 640 #define D_GEOMETRY_DEFAULT_HEIGHT 550 +#define D_GEOMETRY_DEFAULT_XPOS -9999 +#define D_GEOMETRY_DEFAULT_YPOS -9999 #define DW_COLOR_DEFAULT_GREY 0xd6d6d6 #define DW_COLOR_DEFAULT_BLACK 0x000000 @@ -70,6 +72,8 @@ struct _DilloPrefs { gint width; gint height; + gint xpos; + gint ypos; DilloUrl *http_proxy; gchar *no_proxy; gchar **no_proxy_vec;
Jan,
Eric GAUDET wrote:
It works for me with today's CVS and your patch.
in dillorc: geometry=320x200+50+50
dillo.pos/src>./dillo Setting geometry from rc to 320x200 50 50 ...
The first one is actually used, but having the second message is confusing.
Those can probably both go entirely. It was more for debug uses. Here is an updated patch with those removed.
Jan
Fore unknown reasons, gcc 3.2.2 gives me this error: <q> In file included from IO/Url.h:7, from IO/mime.h:14, from dillo.c:47: IO/IO.h:40: unnamed fields of type other than struct or union are not allowed make[1]: *** [dillo.o] Error 1 </q> when X11/Xlib.h is included from dillo.c. The interesting part is that libDio.a compiles flawlessly. I moved the call into misc.c (which gives no problems) and also made a custom function. I prefer this one (to avoid X11/Xlib.h). I'm sending you this version of the patch (outside dillo-dev), so you can review it and comment. Cheers Jorge.- PS: there's no need to CC' me, I read dillo-dev.
participants (3)
-
Eric GAUDET
-
Jan Dittmer
-
Jorge Arellano Cid