From e71d95824ddacd3207d230ac9f58d19c6d85689f Mon Sep 17 00:00:00 2001 From: ulferikson Date: Thu, 30 Nov 2006 21:08:58 +0000 Subject: [PATCH] open window ON-screen --- src/sp-namedview.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 1b973a6ba..cf83596db 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -655,6 +655,8 @@ void SPNamedView::show(SPDesktop *desktop) sp_namedview_setup_grid(this); } +#define MIN_ONSCREEN_DISTANCE 50 + /* * Restores window geometry from the document settings */ @@ -665,10 +667,18 @@ void sp_namedview_window_from_document(SPDesktop *desktop) // restore window size and position if (save_geometry) { - if (nv->window_width != -1 && nv->window_height != -1) - desktop->setWindowSize(nv->window_width, nv->window_height); - if (nv->window_x != -1 && nv->window_y != -1) - desktop->setWindowPosition(NR::Point(nv->window_x, nv->window_y)); + gint w = MIN(gdk_screen_width(), nv->window_width); + gint h = MIN(gdk_screen_height(), nv->window_height); + gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x); + gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y); + if (w>0 && h>0 && x>0 && y>0) { + x = MIN(gdk_screen_width() - w, x); + y = MIN(gdk_screen_height() - h, y); + } + if (w>0 && h>0) + desktop->setWindowSize(w, h); + if (x>0 && y>0) + desktop->setWindowPosition(NR::Point(x, y)); } // restore zoom and view -- 2.30.2