Ref #820: Problem with window in the current build
authorColin Clark <colin.clark@cclark.uk>
Thu, 29 Oct 2020 15:31:09 +0000 (15:31 +0000)
committerColin Clark <colin.clark@cclark.uk>
Thu, 29 Oct 2020 15:31:09 +0000 (15:31 +0000)
https://github.com/BestImageViewer/geeqie/issues/820

This fixes a problem with the command line geometry parameters being
ignored.

doc/docbook/GuideReferenceCommandLine.xml
geeqie.1
src/remote.c

index dad7908..4a72a0a 100644 (file)
           </row>\r
           <row>\r
             <entry />\r
-            <entry>--geometry=&lt;w&gt;x&lt;h&gt;+&lt;x&gt;+&lt;y&gt;</entry>\r
+            <entry>--geometry=[&lt;w&gt;x&lt;h&gt;][+&lt;x&gt;+&lt;y&gt;]</entry>\r
             <entry>Set the &lt;width&gt; &lt;height&gt; &lt;xoffset&gt; &lt;yoffset&gt; of the window. The parameters are in pixels.</entry>\r
           </row>\r
           <row>\r
index 9a0fb42..828239e 100644 (file)
--- 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
index d29565c..e4249d8 100644 (file)
@@ -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);
 }