diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2018-01-06 21:54:56 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2018-01-07 16:37:02 +0000 |
| commit | c448e88e60ed70526cae42f22277701efbfd6ac2 (patch) | |
| tree | 5492b8b33a57381e116ae9cd5c64eff40f425730 /src | |
| parent | Simplify code to restore new windows to previous position (diff) | |
| download | inkscape-c448e88e60ed70526cae42f22277701efbfd6ac2.tar.gz inkscape-c448e88e60ed70526cae42f22277701efbfd6ac2.zip | |
Namedview: Use proper monitor to derive monitor_geometry
Inkscape does not necessarily start on the primary monitor.
GTK+ did not reveal it's secrets (i.e. it seems undocumented) but
empirically the monitor having the cursor is the monitor the initial
window will be placed on.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-namedview.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 99cc6fbfc..4e5da13c3 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -785,33 +785,24 @@ void sp_namedview_window_from_document(SPDesktop *desktop) bool show_dialogs = true; // restore window size and position stored with the document + Gtk::Window *win = desktop->getToplevel(); + g_assert(win); if (geometry_from_last) { // do nothing, as we already have code for that in interface.cpp // TODO: Probably should not do similar things in two places } else if ((geometry_from_file && nv->window_maximized) || (new_document && (default_geometry == 2))) { - Gtk::Window *win = desktop->getToplevel(); - if (win) { - win->maximize(); - } + win->maximize(); } else { - - // TODO: account for multi-monitor setups (i.e. on which monitor do we want to display Inkscape?) Gdk::Rectangle monitor_geometry; - #if GTKMM_CHECK_VERSION(3,22,0) auto const display = Gdk::Display::get_default(); - auto const monitor = display->get_primary_monitor(); - - // If user hasn't configured a primary monitor, nullptr is returned. - if (monitor) { - monitor->get_geometry(monitor_geometry); - } + auto const monitor = display->get_monitor_at_window(win->get_window()); + monitor->get_geometry(monitor_geometry); #else auto const default_screen = Gdk::Screen::get_default(); - auto const monitor_number = default_screen->get_primary_monitor(); + auto const monitor_number = default_screen->get_monitor_at_window(win->get_window()); default_screen->get_monitor_geometry(monitor_number, monitor_geometry); #endif - int w = monitor_geometry.get_width(); int h = monitor_geometry.get_height(); |
