summaryrefslogtreecommitdiffstats
path: root/src/sp-namedview.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-07-14 21:09:41 +0000
committerMarkus Engel <markus.engel@tum.de>2013-07-14 21:09:41 +0000
commitd32efb61f1c2c18d1018e510bbe9bafc04a03905 (patch)
treeb447bf9856baf1cf485e38c4ce55edb27285129e /src/sp-namedview.cpp
parentMerged from trunk (r12305) (diff)
parentMinor C++ish refactoring pass. (diff)
downloadinkscape-d32efb61f1c2c18d1018e510bbe9bafc04a03905.tar.gz
inkscape-d32efb61f1c2c18d1018e510bbe9bafc04a03905.zip
Merged from trunk (r12419).
(bzr r11608.1.107)
Diffstat (limited to 'src/sp-namedview.cpp')
-rw-r--r--src/sp-namedview.cpp91
1 files changed, 59 insertions, 32 deletions
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 31074732d..e05ce7fd2 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -8,7 +8,7 @@
* Abhishek Sharma
*
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
- * Copyright (C) 1999-2008 Authors
+ * Copyright (C) 1999-2013 Authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -751,7 +751,27 @@ void SPNamedView::show(SPDesktop *desktop)
desktop->showGrids(grids_visible, false);
}
-#define MIN_ONSCREEN_DISTANCE 50
+namespace {
+
+gint const MIN_ONSCREEN_DISTANCE = 50;
+gdouble const NEWDOC_X_SCALE = 0.75;
+gdouble const NEWDOC_Y_SCALE = NEWDOC_X_SCALE;
+
+Geom::Point calcAnchorPoint(gint const x, gint const y,
+ gint const w, gint const h, gint const minOnscreen)
+{
+ // prevent the window from moving off the screen to the right or to the bottom
+ gint ax = MIN(gdk_screen_width() - minOnscreen, x);
+ gint ay = MIN(gdk_screen_height() - minOnscreen, y);
+
+ // prevent the window from moving off the screen to the left or to the top
+ ax = MAX(minOnscreen - w, ax);
+ ay = MAX(minOnscreen - h, ay);
+
+ return Geom::Point(ax, ay);
+}
+
+} // namespace
void SPNamedView::writeNewGrid(SPDocument *document,int gridtype)
{
@@ -767,42 +787,49 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
SPNamedView *nv = desktop->namedview;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool geometry_from_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0));
- bool show_dialogs = TRUE;
+ gint default_geometry = prefs->getInt("/options/defaultwindowsize/value", 1);
+ bool new_document = (nv->window_width <= 0) || (nv->window_height <= 0);
+ bool show_dialogs = true;
// restore window size and position stored with the document
- if (geometry_from_file) {
- if (nv->window_maximized) {
- Gtk::Window *win = desktop->getToplevel();
- if (win){
- win->maximize();
- }
- } else {
- gint w = MIN(gdk_screen_width(), nv->window_width);
- gint h = MIN(gdk_screen_height(), nv->window_height);
- // prevent the window from moving off the screen to the right or to the bottom
- gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
- gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
- // prevent the window from moving off the screen to the left or to the top
- x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x);
- y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y);
- if (w>0 && h>0) {
-
- #ifndef WIN32
- gint dx, dy, dw, dh;
- desktop->getWindowGeometry(dx, dy, dw, dh);
- if (w != dw || h != dh) {
- // Don't show dialogs when window is initially resized on OSX/Linux due to gdl dock bug
- // This will happen on sp_desktop_widget_size_allocate
- show_dialogs = FALSE;
- }
- #endif
-
- desktop->setWindowSize(w, h);
- desktop->setWindowPosition(Geom::Point(x, y));
+ bool sizeSet = false;
+ if ((geometry_from_file && nv->window_maximized) || (new_document && (default_geometry == 2))) {
+ Gtk::Window *win = desktop->getToplevel();
+ if (win) {
+ win->maximize();
+ }
+ sizeSet = true;
+ } else if (geometry_from_file && !nv->window_maximized) {
+ gint w = MIN(gdk_screen_width(), nv->window_width);
+ gint h = MIN(gdk_screen_height(), nv->window_height);
+ if ((w > 0) && (h > 0)) {
+#ifndef WIN32
+ gint dx= 0;
+ gint dy = 0;
+ gint dw = 0;
+ gint dh = 0;
+ desktop->getWindowGeometry(dx, dy, dw, dh);
+ if ((w != dw) || (h != dh)) {
+ // Don't show dialogs when window is initially resized on OSX/Linux due to gdl dock bug
+ // This will happen on sp_desktop_widget_size_allocate
+ show_dialogs = FALSE;
}
+#endif
+ Geom::Point origin = calcAnchorPoint(nv->window_x, nv->window_y, w, h, MIN_ONSCREEN_DISTANCE);
+ desktop->setWindowSize(w, h);
+ desktop->setWindowPosition(origin);
+ sizeSet = true;
}
+ }
+ if (!sizeSet && new_document && (default_geometry == 1))
+ {
+ gint w = gdk_screen_width() * NEWDOC_X_SCALE;
+ gint h = gdk_screen_height() * NEWDOC_Y_SCALE;
+ Geom::Point origin = calcAnchorPoint(nv->window_x, nv->window_y, w, h, MIN_ONSCREEN_DISTANCE);
+ desktop->setWindowSize(w, h);
+ desktop->setWindowPosition(origin);
}
// restore zoom and view