From 7048d098f15eae7138b7d01c88ad6aebc1afaf26 Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Sun, 17 Feb 2019 19:33:48 +0100 Subject: Rescue code for restoring last used window geometry It was accidentally dropped in 8b1840f9507f10911f63fc00b9885354ead99d53 Also show window *after* setting position/size. This gives the window manager the chance to move an off-screen window back into the visible desktop bounds (e.g. after a monitor was disconnected). --- src/inkscape-window.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/inkscape-window.cpp') diff --git a/src/inkscape-window.cpp b/src/inkscape-window.cpp index 8c0525a87..f85d94473 100644 --- a/src/inkscape-window.cpp +++ b/src/inkscape-window.cpp @@ -85,11 +85,14 @@ InkscapeWindow::InkscapeWindow(SPDocument* document) // ================ Window Options ============== - show(); // Must show before resize! - // Resize the window to match the document properties sp_namedview_window_from_document(_desktop); // This should probably be a member function here. + + // Must show before setting zoom and view! (crashes otherwise) + // Should show after resizing/moving to allow window manager to correct an invalid windows size/position + show(); + sp_namedview_zoom_and_view_from_document(_desktop); sp_namedview_update_layers_from_document(_desktop); } -- cgit v1.2.3 From bbfd5e166a8adaf0e76919d5ee13e68db1f256c9 Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Wed, 20 Feb 2019 00:40:10 +0100 Subject: Fix query for monitor dimensions The call to Gdk::Display::get_monitor_at_window() in Inkscape::UI::get_monitor_geometry_at_window() requires the underlying GdkWindow to be fully initialized. This is achieved by calling "realize()" before attempting to read that information. Previously we used to show the window first (which implies realizing it) which worked around the issue. However it required us to hide and show it once again later if we wanted to move it in order for the window manager's routines to sanitize the position to kick in. --- src/inkscape-window.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/inkscape-window.cpp') diff --git a/src/inkscape-window.cpp b/src/inkscape-window.cpp index f85d94473..bcf10cedd 100644 --- a/src/inkscape-window.cpp +++ b/src/inkscape-window.cpp @@ -85,11 +85,15 @@ InkscapeWindow::InkscapeWindow(SPDocument* document) // ================ Window Options ============== + // Make sure the GdkWindow is fully initialized before resizing/moving + // (ensures the monitor it'll be shown on is known) + realize(); + // Resize the window to match the document properties sp_namedview_window_from_document(_desktop); // This should probably be a member function here. - + // Must show before setting zoom and view! (crashes otherwise) - // Should show after resizing/moving to allow window manager to correct an invalid windows size/position + // Showing after resizing/moving allows the window manager to correct an invalid size/position of the window show(); sp_namedview_zoom_and_view_from_document(_desktop); -- cgit v1.2.3