[Libreoffice-commits] core.git: vcl/unx

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 5 16:04:08 UTC 2020


 vcl/unx/gtk3/gtk3gtkinst.cxx |   23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

New commits:
commit 9890240055c774c55f125b6db6146536980295ab
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Wed Nov 4 14:43:11 2020 +0100
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Thu Nov 5 17:03:25 2020 +0100

    gtk3: Allow restoring saved window position (if not on Wayland)
    
    Previously, while 'GtkInstanceWindow::get_window_state' returned
    the window position for the non-Wayland case,
    'GtkInstanceWindow::set_window_state' didn't take it into account
    when restoring the state.
    
    In order to actually restore the previously saved state, have
    'GtkInstanceWindow::set_window_state' take the window position into
    account as well if the corresponding flags are passed (and not on
    Wayland).
    
    This e.g. makes the print dialog show up at the same position on
    the screen as last time.
    
    (I came across this while looking at tdf#137471 "CMIS dialog advances
    beyond lower right corner of the screen" which affects qt5, and checking
    what gtk3 does in comparison. Actually, the "Remote files" dialog
    itself - other than the print dialog - still doesn't open at the same
    location with this commit in place, since
    'GtkInstanceWindow::get_window_state' for some reason doesn't return
    the actual location for that dialog, i.e. it cannot be restored
    by the handling introduced here, but that's a different issue.)
    
    Change-Id: Icb5e7e8c7ea3fad7800c4334ad56e47f88144a75
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105298
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 92298a2d0bd7..6f14c46d5e58 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3924,6 +3924,17 @@ private:
         pThis->signal_toplevel_focus_changed();
     }
 
+    bool isPositioningAllowed() const
+    {
+        bool bPositioningAllowed = true;
+#if defined(GDK_WINDOWING_WAYLAND)
+        // no X/Y positioning under Wayland
+        GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
+        bPositioningAllowed = !DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay);
+#endif
+        return bPositioningAllowed;
+    }
+
 protected:
     void help();
 public:
@@ -4052,16 +4063,16 @@ public:
             else
                 gtk_window_unmaximize(m_pWindow);
         }
+
+        if (isPositioningAllowed() && (nMask & WindowStateMask::X && nMask & WindowStateMask::Y))
+        {
+            gtk_window_move(m_pWindow, aData.GetX(), aData.GetY());
+        }
     }
 
     virtual OString get_window_state(WindowStateMask nMask) const override
     {
-        bool bPositioningAllowed = true;
-#if defined(GDK_WINDOWING_WAYLAND)
-        // drop x/y when under wayland
-        GdkDisplay *pDisplay = gtk_widget_get_display(m_pWidget);
-        bPositioningAllowed = !DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay);
-#endif
+        bool bPositioningAllowed = isPositioningAllowed();
 
         WindowStateData aData;
         WindowStateMask nAvailable = WindowStateMask::State |


More information about the Libreoffice-commits mailing list