From 32e799484313dc3390f97fca38f6906e7c683048 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 21 Jun 2018 16:23:20 +0200 Subject: [PATCH] Restore mechanism to prevent windows from being restored off-screen on opening a book This got disabled in commit 54019608ee in the gtk3 refactoring by accident. While we now no longer save the negative coordinates for hidden windows, there are still other situations in which this could happen, like switching from a dual monitor to a single monitor setup (common with laptops). --- gnucash/gnome-utils/gnc-main-window.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c index 1b0b65195f..d28da6b15f 100644 --- a/gnucash/gnome-utils/gnc-main-window.c +++ b/gnucash/gnome-utils/gnc-main-window.c @@ -762,15 +762,15 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da g_warning("invalid number of values for group %s key %s", window_group, WINDOW_POSITION); } -// This does not do any thing ? -// else if ((pos[0] + (geom ? geom[0] : 0) < 0) || -// (pos[0] > gdk_screen_width()) || -// (pos[1] + (geom ? geom[1] : 0) < 0) || -// (pos[1] > gdk_screen_height())) -// { -// g_debug("position %dx%d, size%dx%d is offscreen; will not move", -// pos[0], pos[1], geom[0], geom[1]); -// } + /* Prevent restoring coordinates if this would move the window off-screen */ + else if ((pos[0] + (geom ? geom[0] : 0) < 0) || + (pos[0] > gdk_screen_width()) || + (pos[1] + (geom ? geom[1] : 0) < 0) || + (pos[1] > gdk_screen_height())) + { + g_debug("position %dx%d, size%dx%d is offscreen; will not move", + pos[0], pos[1], geom[0], geom[1]); + } else { gtk_window_move(GTK_WINDOW(window), pos[0], pos[1]);