From: Colin Clark Date: Thu, 29 Oct 2020 15:31:09 +0000 (+0000) Subject: Ref #820: Problem with window in the current build X-Git-Tag: v1.6~10 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=804593cfce94eacf75cae6a2b6b792fefee8a16f Ref #820: Problem with window in the current build https://github.com/BestImageViewer/geeqie/issues/820 This fixes a problem with the command line geometry parameters being ignored. --- diff --git a/doc/docbook/GuideReferenceCommandLine.xml b/doc/docbook/GuideReferenceCommandLine.xml index dad79085..4a72a0ad 100644 --- a/doc/docbook/GuideReferenceCommandLine.xml +++ b/doc/docbook/GuideReferenceCommandLine.xml @@ -339,7 +339,7 @@ - --geometry=<w>x<h>+<x>+<y> + --geometry=[<w>x<h>][+<x>+<y>] Set the <width> <height> <xoffset> <yoffset> of the window. The parameters are in pixels. diff --git a/geeqie.1 b/geeqie.1 index 9a0fb429..828239e5 100644 --- a/geeqie.1 +++ b/geeqie.1 @@ -252,7 +252,7 @@ Open new window. Close window. .br .B -.IP \-\-geometry=XxY+XOFF+YOFF +.IP \-\-geometry=[XxY][+XOFF+YOFF] Set window geometry. .br .B diff --git a/src/remote.c b/src/remote.c index d29565cc..e4249d8b 100644 --- a/src/remote.c +++ b/src/remote.c @@ -949,17 +949,47 @@ static void gr_collection_list(const gchar *text, GIOChannel *channel, gpointer g_string_free(out_string, TRUE); } +static gboolean wait_cb(const gpointer data) +{ + gint position = GPOINTER_TO_INT(data); + gint x = position >> 16; + gint y = position - (x << 16); + + gtk_window_move(GTK_WINDOW(lw_id->window), x, y); + + return FALSE; +} + static void gr_geometry(const gchar *text, GIOChannel *channel, gpointer data) { gchar **geometry; - geometry = g_strsplit_set(text, "+x", 4); - if (geometry[0] != NULL && geometry[1] != NULL && geometry[2] != NULL && geometry[3] != NULL) + if (!layout_valid(&lw_id) || !text) { - gtk_window_resize(GTK_WINDOW(lw_id->window), atoi(geometry[0]), atoi(geometry[1])); - gtk_window_move(GTK_WINDOW(lw_id->window), atoi(geometry[2]), atoi(geometry[3])); + return; } + if (text[0] == '+') + { + geometry = g_strsplit_set(text, "+", 3); + if (geometry[1] != NULL && geometry[2] != NULL ) + { + gtk_window_move(GTK_WINDOW(lw_id->window), atoi(geometry[1]), atoi(geometry[2])); + } + } + else + { + geometry = g_strsplit_set(text, "+x", 4); + if (geometry[0] != NULL && geometry[1] != NULL) + { + gtk_window_resize(GTK_WINDOW(lw_id->window), atoi(geometry[0]), atoi(geometry[1])); + } + if (geometry[2] != NULL && geometry[3] != NULL) + { + /* There is an occasional problem with a window_move immediately after a window_resize */ + g_idle_add(wait_cb, GINT_TO_POINTER((atoi(geometry[2]) << 16) + atoi(geometry[3]))); + } + } g_strfreev(geometry); }