[xfce4-panel] Positioning after remote X login

Jasper Huijsmans jasper at moongroup.com
Sat Dec 6 22:21:25 CET 2003


Op za 06-12-2003, om 13:03 schreef Daniel Ciaglia:
...
> OK, I've attached an patch. This one is working at least for me. Please
> have a look.
> 

Hey, that's cheating ;-) You simply set the coordinates to (-1,-1) so
the panel will be in the default position. That only works if you have
the panel centered on the bottom or the left edge.

I think the included patch should work. It would be great if you could
test it.

	Jasper

Index: panel/panel.c
===================================================================
RCS file: /var/cvs/xfce/xfce4/xfce4-panel/panel/panel.c,v
retrieving revision 1.61
diff -u -r1.61 panel.c
--- panel/panel.c	22 Sep 2003 11:54:20 -0000	1.61
+++ panel/panel.c	6 Dec 2003 21:07:49 -0000
@@ -30,6 +30,7 @@
 #undef GDK_MULTIHEAD_SAFE
 #endif
 
+#include <math.h>
 #include <X11/Xlib.h>
 
 #include <libxfce4util/debug.h>
@@ -70,6 +71,10 @@
 /* lock settings update when panel is not yet (re)build */
 static gboolean panel_created = FALSE;
 
+/* used when screen size is different than in previous session */
+static int old_screen_width = 0;
+static int old_screen_height = 0;
+
 /* screen properties */
 static Display *dpy = NULL;
 static int scr = 0;
@@ -630,6 +635,22 @@
      * This function creates the panel items and popup menus */
     get_panel_config ();
 
+    if (old_screen_width > 0)
+    {
+	GtkRequisition req;
+	double xscale, yscale;
+
+	gtk_widget_size_request (panel.toplevel, &req);
+
+	xscale = (double) x / (double) (old_screen_width - req.width);
+	yscale = (double) y / (double) (old_screen_height - req.height);
+
+	x = rint (xscale * (screen_width - req.width));
+	y = rint (yscale * (screen_height - req.height));
+
+	old_screen_width = old_screen_height = 0;
+    }
+    
     panel.position.x = x;
     panel.position.y = y;
     panel_set_position ();
@@ -1075,16 +1096,10 @@
 	    else
 		break;
 
-	    /* this doesn't actually work completely, we need to
-	     * save the panel width as well to do it right */
 	    if (w != screen_width || h != screen_height)
 	    {
-		panel.position.x =
-		    (int) ((double) (panel.position.x * screen_width) /
-			   (double) w);
-		panel.position.y =
-		    (int) ((double) (panel.position.y * screen_height) /
-			   (double) h);
+		old_screen_width = w;
+		old_screen_height = h;
 	    }
 	}
     }




More information about the Xfce4-dev mailing list