Re: Geometry issues ...



Hi Micheal et al,

attached is a little patch that makes Nautilus only save the geometry
after a timeout. This basically causes the geometry to be saved only
once for every resize the user performs. That should solve most of the
disk thrashing problems and is just as (in)efficient as saving at every
location change (since we most likely only resize the window once, if at
all).

The second part of the patch places new windows at a slightly offset
position if a window with the same URI is already open, that makes for a
nicer UI experience. Except ... well, right now when I enable that code
all my new windows show up without a menubar. Toolbars, status bar, etc.
are there, just not the menubar. Maybe someone with GTK knowledge can
figure that one out ... otherwise it works fine. ;)

> 	I agree with you for the 'Open In New Window' (OINW) mode, fine - I'm
> just arguing about the 'browse' mode.

I think this also matters for the browse mode, hence the change in the
first place.

> 	Fair enough, then store the size, but not the position - that's a
> fairly simple solution. Only store the size if we're not in OINW mode,
> it doesn't worry me. Or - store both, but certainly ignore the position
> in browse mode, or we get all windows piled up in an unusable mess.

I don't understand why you think this only matters in OINW mode. Windows
also handles this in browse mode and it is really nice. Your main
concern here seems to be that new windows show up on top of each other,
the patch should fix that. That would be even better than Windows which
also just piles windows on top of each other. And what is wrong with
piling the windows on top anyway??

> 	Why ? why fix the metadata system ? it's not reasonable to complain
> about the underlying system when it is being deliberately misused. It's
> less simple and generic to fix the metadata system than to stop
> hammering the API needlessly, - read the metadata code:
> 
> nautilus-directory-metafile.c (nautilus_directory_metadata_monitor),
> nautilus-directory-metafile-monitor.c (corba_metafile_changed):
> nautilus-directory.h etc. etc.

I agree that hammering the API with constant save requests for every
drag operation was wrong, the timeout fixes that issue.

I guess the metadata probably doesn't need fixing outright, although a
redraw for every geometry save still does suck. A more finegrained
changed signal that tells us what changed might be useful. And yes, I
still think the geometry should be saved in the metadata since it
belongs to a directory just as much as any other metadata like emblems.

- Frank
Index: src/nautilus-application.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-application.c,v
retrieving revision 1.193
diff -u -p -r1.193 nautilus-application.c
--- src/nautilus-application.c	8 Jul 2002 15:32:08 -0000	1.193
+++ src/nautilus-application.c	9 Jul 2002 19:35:35 -0000
@@ -643,7 +643,7 @@ nautilus_window_delete_event_callback (G
 }				       
 
 static gboolean
-save_window_geometry_idle (gpointer callback_data)
+save_window_geometry_timeout (gpointer callback_data)
 {
 	NautilusWindow *window;
 	
@@ -651,7 +651,7 @@ save_window_geometry_idle (gpointer call
 	
 	nautilus_window_save_geometry (window);
 	
-	window->save_geometry_idle_id = 0;
+	window->save_geometry_timeout_id = 0;
 	return FALSE;
 }
  
@@ -664,12 +664,16 @@ nautilus_window_configure_event_callback
 	
 	window = NAUTILUS_WINDOW (widget);
 	
-	/* Only save the geometry when we are idle, 
-	 * since we receive configure events all the time.
+	/* Only save the geometry if the user hasn't resized the window
+	 * for one second. Otherwise delay the callback for another second.
 	 */
-	if (window->save_geometry_idle_id == 0) {
-		window->save_geometry_idle_id = 
-				g_idle_add (save_window_geometry_idle, window);
+	if (window->save_geometry_timeout_id == 0) {
+		window->save_geometry_timeout_id = 
+				g_timeout_add (500, save_window_geometry_timeout, window);
+	} else {
+		g_source_remove (window->save_geometry_timeout_id);
+		window->save_geometry_timeout_id = 
+				g_timeout_add (500, save_window_geometry_timeout, window);		
 	}
 
 	return FALSE;
@@ -684,9 +688,9 @@ nautilus_window_unrealize_event_callback
 	
 	window = NAUTILUS_WINDOW (widget);
 
-	if (window->save_geometry_idle_id != 0) {
-		g_source_remove (window->save_geometry_idle_id);
-		window->save_geometry_idle_id = 0;
+	if (window->save_geometry_timeout_id != 0) {
+		g_source_remove (window->save_geometry_timeout_id);
+		window->save_geometry_timeout_id = 0;
 		nautilus_window_save_geometry (window);
 	}
 
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.301
diff -u -p -r1.301 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	5 Jul 2002 10:51:03 -0000	1.301
+++ src/nautilus-window-manage-views.c	9 Jul 2002 19:35:35 -0000
@@ -44,6 +44,7 @@
 #include <eel/eel-vfs-extensions.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtksignal.h>
+#include <gdk/gdkx.h>
 #include <libgnome/gnome-i18n.h>
 #include <libgnomeui/gnome-dialog-util.h>
 #include <libgnomevfs/gnome-vfs-async-ops.h>
@@ -1114,7 +1115,10 @@ position_and_show_window_callback (Nauti
 {
 	NautilusWindow *window;
 	char *geometry_string;
-        
+	char *location, *temp;
+	GList *list, *item;
+	int x, y, h, w, c;
+   
 	window = NAUTILUS_WINDOW (callback_data);
 
         if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
@@ -1129,6 +1133,47 @@ position_and_show_window_callback (Nauti
                                  NAUTILUS_WINDOW_MIN_HEIGHT);
                 }
                 g_free (geometry_string);
+
+		/* Check if a window with this uri is already open. If there
+		 * is, then position the new window at a slightly different
+		 * location so that it doesn't fully cover the existing window.
+		 */
+		temp = window->details->pending_location;
+		list = nautilus_application_get_window_list ();
+		for (item = list; item != NULL; item = item->next) {
+			location = nautilus_window_get_location (NAUTILUS_WINDOW (item->data));
+
+			if (!NAUTILUS_IS_DESKTOP_WINDOW (item->data)
+			    && location != NULL
+			    && item->data != window
+			    && !strcmp (temp, location)) {
+				gtk_window_get_position (GTK_WINDOW (window), &x, &y);
+				gtk_window_get_size (GTK_WINDOW (window), &w, &h);
+	
+				for (c = 30; c >= 10; c -= 10) {
+					if ((x += c) + w > gdk_screen_width ())
+						if ((x -= (2 * c)) < 0) {
+							x += c;
+							continue;
+						}
+					break;
+				}
+				
+				for (c = 30; c >= 10; c -= 10) {
+					if ((y += c) + h > gdk_screen_height ())
+						if ((y -= (2 * c)) < 0) {
+						y += c;
+							continue;
+						}
+					break;
+				}
+
+				gtk_window_move (GTK_WINDOW (window), x, y);
+				g_free (location);
+				break;
+			}
+			g_free (location);
+		}
         }
 
         /* If we finished constructing the window by now we need
Index: src/nautilus-window.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.h,v
retrieving revision 1.102
diff -u -p -r1.102 nautilus-window.h
--- src/nautilus-window.h	11 Jun 2002 08:57:14 -0000	1.102
+++ src/nautilus-window.h	9 Jul 2002 19:35:35 -0000
@@ -82,7 +82,7 @@ struct NautilusWindow {
         GtkWidget *navigation_bar;
         
         guint status_bar_clear_id;
-        guint save_geometry_idle_id;
+        guint save_geometry_timeout_id;
 	  
         /** CORBA-related elements **/
         NautilusApplication *application;


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