From 3f6074b8a3112b92b66101d77a08cfbb133d4f27 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sun, 26 Nov 2006 00:32:36 +0000 Subject: [PATCH] Check if dialog is going to be displayed offscreen, if so: move it to center off screen. [ 1596374 ] To do: copy this to non-gtkmm dialogs --- src/ui/dialog/dialog.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 074ee0d36..8fb04a91f 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -31,6 +31,11 @@ #include "interface.h" #include "verbs.h" + +#define MIN_ONSCREEN_DISTANCE 50 + + + namespace Inkscape { namespace UI { namespace Dialog { @@ -96,18 +101,16 @@ Dialog::read_geometry() // g_print ("read %d %d %d %d\n", x, y, w, h); - if (x<0) x=0; - if (y<0) y=0; - // If there are stored height and width values for the dialog, // resize the window to match; otherwise we leave it at its default if (w != 0 && h != 0) { resize (w, h); } - + // If there are stored values for where the dialog should be // located, then restore the dialog to that position. - if (x != -1000 && y != -1000) { + // also check if (x,y) is actually onscreen with the current screen dimensions + if ( (x >= 0) && (y >= 0) && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE)) ) { move(x, y); } else { // ...otherwise just put it in the middle of the screen -- 2.30.2