diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2013-05-01 07:46:46 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2013-05-01 07:46:46 +0000 |
| commit | c86ef6517c24a2bec8e37f3b5d05ff941dce76d9 (patch) | |
| tree | eff00b27b1630bc21d618f9d2d338bbe07f75cac /src | |
| parent | Fix for Bug #830663 (default window size is too small) by Jiabao Wu (diff) | |
| download | inkscape-c86ef6517c24a2bec8e37f3b5d05ff941dce76d9.tar.gz inkscape-c86ef6517c24a2bec8e37f3b5d05ff941dce76d9.zip | |
Update minimum window size logic for cases when not saving window positions.
(bzr r12316)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-namedview.cpp | 96 |
1 files changed, 58 insertions, 38 deletions
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 91ad00cf4..452f57425 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -748,7 +748,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) { @@ -765,50 +785,50 @@ void sp_namedview_window_from_document(SPDesktop *desktop) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool geometry_from_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0)); gint default_geometry = prefs->getInt("/options/defaultwindowsize/value", 1); - bool new_document = !(nv->window_width > 0) || !(nv->window_height > 0); - bool show_dialogs = TRUE; + 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 || (new_document && (default_geometry == 2))) { - 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 + bool sizeSet = false; - desktop->setWindowSize(w, h); - desktop->setWindowPosition(Geom::Point(x, y)); - } else { - if (default_geometry == 1) { - w = gdk_screen_width() * 0.75; - h = gdk_screen_height() * 0.75; - desktop->setWindowSize(w, h); - desktop->setWindowPosition(Geom::Point(x, y)); - } + 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 if (nv->zoom != 0 && nv->zoom != HUGE_VAL && !IS_NAN(nv->zoom) && nv->cx != HUGE_VAL && !IS_NAN(nv->cx) |
