summaryrefslogtreecommitdiffstats
path: root/src/inkscape-window.cpp
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-10-22 18:49:19 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-10-22 18:49:34 +0000
commit4e2f989a99874cf6a50cd9583c16fd36c6c8ac12 (patch)
tree1a8b0727e038a5cf1e091414bbdb3482d8e78812 /src/inkscape-window.cpp
parentProperly calculate line height for flowDiv (diff)
downloadinkscape-4e2f989a99874cf6a50cd9583c16fd36c6c8ac12.tar.gz
inkscape-4e2f989a99874cf6a50cd9583c16fd36c6c8ac12.zip
Properly update document view when closing, then opening a new file
We call "change_document()" in this case, which only switches the document without creating a new window and consequently did not do any of the required set-up This ensures window size/position and other preferences stored in <namedview> are properly applied.
Diffstat (limited to 'src/inkscape-window.cpp')
-rw-r--r--src/inkscape-window.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/inkscape-window.cpp b/src/inkscape-window.cpp
index 27ca5309b..b5ab15109 100644
--- a/src/inkscape-window.cpp
+++ b/src/inkscape-window.cpp
@@ -84,7 +84,28 @@ InkscapeWindow::InkscapeWindow(SPDocument* document)
// ================ Window Options ==============
+ setup_view();
+}
+// Change a document, leaving desktop/view the same. (Eventually move all code here.)
+void
+InkscapeWindow::change_document(SPDocument* document)
+{
+ if (!_app) {
+ std::cerr << "Inkscapewindow::change_document: app is nullptr!" << std::endl;
+ return;
+ }
+
+ _document = document;
+ _app->set_active_document(_document);
+
+ setup_view();
+}
+
+// Sets up the window and view according to user preferences and <namedview> of the just loaded document
+void
+InkscapeWindow::setup_view()
+{
// Make sure the GdkWindow is fully initialized before resizing/moving
// (ensures the monitor it'll be shown on is known)
realize();
@@ -93,9 +114,15 @@ InkscapeWindow::InkscapeWindow(SPDocument* document)
sp_namedview_window_from_document(_desktop); // This should probably be a member function here.
// Must show before setting zoom and view! (crashes otherwise)
+ //
// Showing after resizing/moving allows the window manager to correct an invalid size/position of the window
+ // TODO: This does *not* work when called from 'change_document()', i.e. when the window is already visible.
+ // This can result in off-screen windows! We previously worked around this by hiding and re-showing
+ // the window, but a call to hide() causes Inkscape to just exit since the migration to Gtk::Application
show();
- // Extra call seems to ensure toolbar widgets are visible after programmatic resize
+
+ // TODO: Extra call seems to ensure toolbar widgets are visible after programmatic resize
+ // (incomplete workaround for https://gitlab.com/inkscape/inkscape/issues/125)
check_resize();
sp_namedview_zoom_and_view_from_document(_desktop);
@@ -105,19 +132,6 @@ InkscapeWindow::InkscapeWindow(SPDocument* document)
if (nv && nv->lockguides) {
nv->lockGuides();
}
-
-}
-
-// Change a document, leaving desktop/view the same. (Eventually move all code here.)
-void
-InkscapeWindow::change_document(SPDocument* document)
-{
- _document = document;
- if (_app) {
- _app->set_active_document(_document);
- } else {
- std::cerr << "Inkscapewindow::change_document: app is nullptr!" << std::endl;
- }
}
/**