From 34b23e328280c20263b23d02b3cfeec3cb230ab4 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 4 Aug 2012 16:08:43 +0000 Subject: [PATCH] Avoid windows with saved positions to reopen off-screen if possible git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22284 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/dialog-utils.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gnome-utils/dialog-utils.c b/src/gnome-utils/dialog-utils.c index 429772ea78..72d7255c97 100644 --- a/src/gnome-utils/dialog-utils.c +++ b/src/gnome-utils/dialog-utils.c @@ -164,9 +164,20 @@ gnc_restore_window_size(const char *section, GtkWindow *window) GCONF_VALUE_INT, NULL); if (coord_list) { + gint screen_width = gdk_screen_width(); + gint screen_height = gdk_screen_height(); + coords[0] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 0)); coords[1] = GPOINTER_TO_INT(g_slist_nth_data(coord_list, 1)); - DEBUG("coords[0]: %d, coords[1]: %d", coords[0], coords[1]); + DEBUG("from gconf - coords[0]: %d, coords[1]: %d", coords[0], coords[1]); + + /* Keep the window on screen if possible */ + if (screen_width != 0) + coords[0] = coords[0] % screen_width; + if (screen_height != 0) + coords[1] = coords[1] % screen_height; + DEBUG("after screen adaption - coords[0]: %d, coords[1]: %d", coords[0], coords[1]); + gtk_window_move(window, coords[0], coords[1]); g_slist_free(coord_list); }