summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/inkscape-window.cpp42
-rw-r--r--src/inkscape-window.h2
2 files changed, 30 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;
- }
}
/**
diff --git a/src/inkscape-window.h b/src/inkscape-window.h
index e05b923c0..f3c94452a 100644
--- a/src/inkscape-window.h
+++ b/src/inkscape-window.h
@@ -55,6 +55,8 @@ private:
Gtk::Box* _mainbox;
Gtk::MenuBar* _menubar;
+ void setup_view();
+
// Callbacks
bool on_key_press_event(GdkEventKey* event) override;
bool on_focus_in_event(GdkEventFocus* event) override;