summaryrefslogtreecommitdiffstats
path: root/src/sp-namedview.cpp
diff options
context:
space:
mode:
authorUlf Erikson <ulferikson@gmail.com>2006-11-30 21:08:58 +0000
committerulferikson <ulferikson@users.sourceforge.net>2006-11-30 21:08:58 +0000
commit9816f1cdb6771e8c2e648397a4ff85bd9ad72d8b (patch)
tree124b1286f1bb69b4d4ab9ca1d2cd06cb0ff7346f /src/sp-namedview.cpp
parentthese didn't compile for me. so let's try this. (diff)
downloadinkscape-9816f1cdb6771e8c2e648397a4ff85bd9ad72d8b.tar.gz
inkscape-9816f1cdb6771e8c2e648397a4ff85bd9ad72d8b.zip
open window ON-screen
(bzr r2059)
Diffstat (limited to 'src/sp-namedview.cpp')
-rw-r--r--src/sp-namedview.cpp18
1 files 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