diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2018-01-06 19:36:01 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2018-01-07 16:37:02 +0000 |
| commit | 7939322078af85900e32b5120c1fbcaf9c73f616 (patch) | |
| tree | 2d006af755165aceeab3d02a1328f04c79f392b9 /src/ui/interface.cpp | |
| parent | Fix typo (diff) | |
| download | inkscape-7939322078af85900e32b5120c1fbcaf9c73f616.tar.gz inkscape-7939322078af85900e32b5120c1fbcaf9c73f616.zip | |
Simplify code to restore new windows to previous position
GTK+ / window managers handle positioning of new windows on the
screen just fine, so don't do "our own thing" that is prone to errors.
Notably the previous code for gtkmm >=3.22 was broken as it assumed
Inkscape to be shown on the primary monitor and mixed coordinates
relative to the primary display with absolute screen coordinates
Diffstat (limited to 'src/ui/interface.cpp')
| -rw-r--r-- | src/ui/interface.cpp | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 826737c2c..3671380fe 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -30,10 +30,6 @@ #include "file.h" #include <glibmm/miscutils.h> -#if GTKMM_CHECK_VERSION(3,22,0) -# include <gdkmm/monitor.h> -#endif - #include "inkscape.h" #include "extension/db.h" #include "extension/effect.h" @@ -165,8 +161,7 @@ sp_create_window(SPViewWidget *vw, bool editable) win->signal_focus_in_event().connect(sigc::mem_fun(*desktop_widget, &SPDesktopWidget::onFocusInEvent)); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint prefs_geometry = - (2==prefs->getInt("/options/savewindowgeometry/value", 0)); + gint prefs_geometry = (2==prefs->getInt("/options/savewindowgeometry/value", 0)); if (prefs_geometry) { gint pw = prefs->getInt("/desktop/geometry/width", -1); gint ph = prefs->getInt("/desktop/geometry/height", -1); @@ -175,39 +170,8 @@ sp_create_window(SPViewWidget *vw, bool editable) gint full = prefs->getBool("/desktop/geometry/fullscreen"); gint maxed = prefs->getBool("/desktop/geometry/maximized"); if (pw>0 && ph>0) { -#if GTKMM_CHECK_VERSION(3,22,0) - auto const display = Gdk::Display::get_default(); - auto const monitor = display->get_primary_monitor(); - - // A Gdk::Rectangle in "application pixel" units - Gdk::Rectangle screen_geometry; - monitor->get_geometry(screen_geometry); - auto const screen_width = screen_geometry.get_width(); - auto const screen_height = screen_geometry.get_height(); -#else - auto const screen_width = gdk_screen_width(); - auto const screen_height = gdk_screen_height(); -#endif - gint w = MIN(screen_width, pw); - gint h = MIN(screen_height, ph); - gint x = MIN(screen_width - MIN_ONSCREEN_DISTANCE, px); - gint y = MIN(screen_height - MIN_ONSCREEN_DISTANCE, py); - if (w>0 && h>0) { - x = MIN(screen_width - w, x); - y = MIN(screen_height - h, y); - desktop->setWindowSize(w, h); - } - - // Only restore xy for the first window so subsequent windows don't overlap exactly - // with first. (Maybe rule should be only restore xy if it's different from xy of - // other desktops?) - - // Empirically it seems that active_desktop==this desktop only the first time a - // desktop is created. - SPDesktop *active_desktop = SP_ACTIVE_DESKTOP; - if (active_desktop == desktop || active_desktop==NULL) { - desktop->setWindowPosition(Geom::Point(x, y)); - } + desktop->setWindowSize(pw, ph); + desktop->setWindowPosition(Geom::Point(px, py)); } if (maxed) { win->maximize(); @@ -216,8 +180,7 @@ sp_create_window(SPViewWidget *vw, bool editable) win->fullscreen(); } } - - } + } if ( completeDropTargets == 0 || completeDropTargetsCount == 0 ) { |
