Nautilus hard code freeze break request: Fix first navigation window location on multi-screen setups



In Nautilus, we store the geometry of the last navigation window and
reuse it on the next application startup. It works like a charm for
single-screen setups. However, in the multi-screen case the first window
may be restored to a location that is not on the monitor where the
pointer is located, at least for the first opened navigation window.

The attached patch fixes this glitch by ignoring the old window position
(not the size) in this case, thus displaying it on the pointer's monitor
- at least for metacity. It also fixes a related bug report [1]. OK to
commit?

I also investigated to always (re-)store the last used navigation window
positions per monitor, but the coding is quite time intensive and I
don't have much time now. Even if the storage was be per monitor, the
attached patch would be neccessary for coping with modified monitor
layouts.

best regards,
 Christian Neumair

[1] http://bugzilla.gnome.org/show_bug.cgi?id=552839

-- 
Christian Neumair <cneumair gnome org>
Index: src/nautilus-application.c
===================================================================
--- src/nautilus-application.c	(Revision 14632)
+++ src/nautilus-application.c	(Arbeitskopie)
@@ -1253,6 +1253,48 @@ another_navigation_window_already_showin
 	return FALSE;
 }
 
+static gboolean
+cursor_on_monitor_by_geometry (const char *geometry_string)
+{
+	GdkScreen *screen;
+	EelGdkGeometryFlags geometry_flags;
+	int pointer_monitor;
+	int geometry_monitor;
+	int x, y;
+	int left, top, width, height;
+
+	geometry_flags = eel_gdk_parse_geometry (geometry_string, &left, &top, &width, &height);
+	if ((geometry_flags & EEL_GDK_X_VALUE) == 0 && (geometry_flags & EEL_GDK_Y_VALUE) == 0) {
+		return FALSE;
+	}
+
+	if (geometry_flags & EEL_GDK_X_NEGATIVE) {
+		left = gdk_screen_get_width (screen) - left;
+	}
+
+	if (geometry_flags & EEL_GDK_Y_NEGATIVE) {
+		top = gdk_screen_get_width (screen) - top;
+	}
+
+	if ((geometry_flags & EEL_GDK_WIDTH_VALUE) == 0) {
+		width = NAUTILUS_WINDOW_MIN_WIDTH;
+	}
+
+	if ((geometry_flags & EEL_GDK_HEIGHT_VALUE) == 0) {
+		height = NAUTILUS_WINDOW_MIN_HEIGHT;
+	}
+
+	x = left + width / 2;
+	y = top + height / 2;
+	geometry_monitor = gdk_screen_get_monitor_at_point (gdk_screen_get_default (), left, top);
+
+	gdk_display_get_pointer (gdk_display_get_default (),
+				 &screen, &x, &y, NULL);
+	pointer_monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+
+	return geometry_monitor == pointer_monitor;
+}
+
 NautilusWindow *
 nautilus_application_create_navigation_window (NautilusApplication *application,
 					       const char          *startup_id,
@@ -1291,7 +1333,8 @@ nautilus_application_create_navigation_w
 			 geometry_string,
 			 NAUTILUS_WINDOW_MIN_WIDTH, 
 			 NAUTILUS_WINDOW_MIN_HEIGHT,
-			 another_navigation_window_already_showing (window));
+			 another_navigation_window_already_showing (window) ||
+			 !cursor_on_monitor_by_geometry (geometry_string));
 	}
 	g_free (geometry_string);
 


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