diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2018-01-09 20:37:43 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2018-01-09 21:32:06 +0000 |
| commit | 87661ee65e9faccb22adeca6a37de7b065e8a702 (patch) | |
| tree | 474f2e077578ae8524f1697ad37dd61c7b267863 /src/ui/interface.cpp | |
| parent | Fix profiling build (diff) | |
| parent | Limit default window size to monitor dimensions (diff) | |
| download | inkscape-87661ee65e9faccb22adeca6a37de7b065e8a702.tar.gz inkscape-87661ee65e9faccb22adeca6a37de7b065e8a702.zip | |
Fix and improve window size/position handling/restoration
- Fix broken window size/position restoration after gtk3 deprecation
fixes in fa8a2ee7e2539b145a87ac9af0d9748effa91631
- Use monitor geometry of the monitor Inkscape will be shown on
instead of defaulting to the primary monitor which is often wrong
- Let gtk+ / window manager handle window size/position sanitization
(confirmed working on Windows and Ubuntu 16.04) and remove custom
code which was prone to errors and did not always work as desired
- Make default window size "Small" work again (was broken in gtk3)
and add a new preference "Default" which uses the native window
size (i.e. tries to make just enough room for all controls)
Diffstat (limited to 'src/ui/interface.cpp')
| -rw-r--r-- | src/ui/interface.cpp | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 826737c2c..7df3502f7 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -30,10 +30,7 @@ #include "file.h" #include <glibmm/miscutils.h> -#if GTKMM_CHECK_VERSION(3,22,0) -# include <gdkmm/monitor.h> -#endif - +#include "enums.h" #include "inkscape.h" #include "extension/db.h" #include "extension/effect.h" @@ -43,6 +40,7 @@ #include "document.h" #include "ui/interface.h" +#include "ui/monitor.h" #include "desktop.h" #include "selection-chemistry.h" #include "svg-view-widget.h" @@ -136,8 +134,6 @@ static void sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name); static void sp_recent_open(GtkRecentChooser *, gpointer); -static const int MIN_ONSCREEN_DISTANCE = 50; - void sp_create_window(SPViewWidget *vw, bool editable) { @@ -165,9 +161,8 @@ 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)); - if (prefs_geometry) { + int window_geometry = prefs->getInt("/options/savewindowgeometry/value", PREFS_WINDOW_GEOMETRY_NONE); + if (window_geometry == PREFS_WINDOW_GEOMETRY_LAST) { gint pw = prefs->getInt("/desktop/geometry/width", -1); gint ph = prefs->getInt("/desktop/geometry/height", -1); gint px = prefs->getInt("/desktop/geometry/x", -1); @@ -175,39 +170,11 @@ 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)); - } + Gdk::Rectangle monitor_geometry = Inkscape::UI::get_monitor_geometry_at_point(px, py); + pw = std::min(pw, monitor_geometry.get_width()); + ph = std::min(ph, monitor_geometry.get_height()); + desktop->setWindowSize(pw, ph); + desktop->setWindowPosition(Geom::Point(px, py)); } if (maxed) { win->maximize(); @@ -216,8 +183,7 @@ sp_create_window(SPViewWidget *vw, bool editable) win->fullscreen(); } } - - } + } if ( completeDropTargets == 0 || completeDropTargetsCount == 0 ) { |
