Grzegorz Artur Daszuta <[email protected]> writes: > I was in the middle of preparation of Polish language translation of > PSPP (middle in this case is something about 20%), when I observed > strange behavior - while moving/resizing psppire window, something > starts frantically accessing something on my hard drive. No other > application share this behavior, even resource hogs like chrome, > firefox, or virtualbox. This appear to be linux-only issue - windows > works fine. Maybe it's also Gnome-only or Gnome-on-Fedora-only issue, > I'm not sure at all.
Wow. Thanks for reporting this. It doesn't show up on my laptop because of the way it's set up, but I can see how it would be very annoying. It's actually a change in Glib behavior that, as you say, only affects Unix. John, here is a proposed patch. It seems to work OK in my brief testing. How does it look to you? --8<--------------------------cut here-------------------------->8-- >From 61e32cd84c226f5e5c20f407da139dbb7cf5170b Mon Sep 17 00:00:00 2001 From: Ben Pfaff <[email protected]> Date: Thu, 25 Feb 2010 21:40:52 -0800 Subject: [PATCH] gui: Save positions of windows only when they are closed. When windows in the GUI are moved around the desktop or resized, the machine's disk can thrash madly in some setups. This is because each change in a window's position or size triggers a write to the PSPPIRE preferences file noting the new position as a default for the next PSPPIRE run. It wasn't always a problem, but newer Glib versions call fsync() from g_file_set_contents(), the function used to write the preferences file, which bypasses the OS cache and forces a synchronous disk write. This commit makes PSPPIRE update the preferences file only when a window is closed, which fixes the problem. Avoiding g_file_set_contents() would be another reasonable solution. Reported by Grzegorz Artur Daszuta <[email protected]>. --- src/ui/gui/psppire-conf.c | 47 ++++++++++++++++++------------------------ src/ui/gui/psppire-conf.h | 4 +- src/ui/gui/psppire-dialog.c | 4 +- src/ui/gui/psppire-window.c | 28 +++++++------------------ 4 files changed, 32 insertions(+), 51 deletions(-) diff --git a/src/ui/gui/psppire-conf.c b/src/ui/gui/psppire-conf.c index 4090b74..07db3b5 100644 --- a/src/ui/gui/psppire-conf.c +++ b/src/ui/gui/psppire-conf.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009 Free Software Foundation + Copyright (C) 2009, 2010 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -262,36 +262,29 @@ psppire_conf_set_window_geometry (PsppireConf *conf, void psppire_conf_save_window_geometry (PsppireConf *conf, const gchar *base, - GdkEvent *e) + GtkWindow *gtk_window) { - switch (e->type) - { - case GDK_CONFIGURE: - { - GdkEventConfigure *event = &e->configure; + gboolean maximized; + GdkWindow *w; - if ( gdk_window_get_state (event->window) & - GDK_WINDOW_STATE_MAXIMIZED ) - return; + w = gtk_widget_get_window (GTK_WIDGET (gtk_window)); + if (w == NULL) + return; - psppire_conf_set_int (conf, base, "height", event->height); - psppire_conf_set_int (conf, base, "width", event->width); + maximized = (gdk_window_get_state (w) & GDK_WINDOW_STATE_MAXIMIZED) != 0; + psppire_conf_set_boolean (conf, base, "maximize", maximized); - psppire_conf_set_int (conf, base, "x", event->x); - psppire_conf_set_int (conf, base, "y", event->y); - } - break; - case GDK_WINDOW_STATE: - { - GdkEventWindowState *event = &e->window_state; + if (!maximized) + { + gint width, height; + gint x, y; - psppire_conf_set_boolean (conf, base, "maximize", - event->new_window_state & - GDK_WINDOW_STATE_MAXIMIZED ); - } - break; - default: - break; - }; + gdk_drawable_get_size (w, &width, &height); + gdk_window_get_position (w, &x, &y); + psppire_conf_set_int (conf, base, "height", height); + psppire_conf_set_int (conf, base, "width", width); + psppire_conf_set_int (conf, base, "x", x); + psppire_conf_set_int (conf, base, "y", y); + } } diff --git a/src/ui/gui/psppire-conf.h b/src/ui/gui/psppire-conf.h index a7415b2..4e7ece0 100644 --- a/src/ui/gui/psppire-conf.h +++ b/src/ui/gui/psppire-conf.h @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009 Free Software Foundation + Copyright (C) 2009, 2010 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -96,7 +96,7 @@ void psppire_conf_set_window_geometry (PsppireConf *conf, void psppire_conf_save_window_geometry (PsppireConf *, const gchar *, - GdkEvent *); + GtkWindow *); G_END_DECLS diff --git a/src/ui/gui/psppire-dialog.c b/src/ui/gui/psppire-dialog.c index 4bcb5cc..e4d04a1 100644 --- a/src/ui/gui/psppire-dialog.c +++ b/src/ui/gui/psppire-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -305,7 +305,7 @@ configure_event_callback (GtkDialog *dialog, g_object_get (dialog, "name", &base, NULL); - psppire_conf_save_window_geometry (conf, base, event); + psppire_conf_save_window_geometry (conf, base, GTK_WINDOW (dialog)); return FALSE; } diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 70500e6..d3137ff 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009 Free Software Foundation + Copyright (C) 2009, 2010 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -203,19 +203,6 @@ on_realize (GtkWindow *window, gpointer data) } -static gboolean -save_geometry (GtkWidget *window, GdkEvent *event, gpointer data) -{ - const gchar *base = G_OBJECT_TYPE_NAME (window); - - PsppireConf *conf = psppire_conf_new (); - - psppire_conf_save_window_geometry (conf, base, event); - - return FALSE; -} - - static void psppire_window_finalize (GObject *object) { @@ -382,6 +369,13 @@ on_delete (PsppireWindow *w, GdkEvent *event, gpointer user_data) { PsppireWindowRegister *reg = psppire_window_register_new (); + const gchar *base = G_OBJECT_TYPE_NAME (w); + + PsppireConf *conf = psppire_conf_new (); + + psppire_conf_save_window_geometry (conf, base, GTK_WINDOW (w)); + + if ( w->dirty ) { gint response = psppire_window_query_save (w); @@ -435,12 +429,6 @@ psppire_window_init (PsppireWindow *window) g_object_set (window, "icon-name", "psppicon", NULL); - g_signal_connect (window, "configure-event", - G_CALLBACK (save_geometry), window); - - g_signal_connect (window, "window-state-event", - G_CALLBACK (save_geometry), window); - g_signal_connect (window, "realize", G_CALLBACK (on_realize), window); -- 1.6.5 -- Ben Pfaff http://benpfaff.org _______________________________________________ pspp-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/pspp-dev
