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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 17 09:25:13 UTC 2019


 include/vcl/weld.hxx            |    4 ++++
 sfx2/source/doc/templatedlg.cxx |    5 +++++
 vcl/source/app/salvtables.cxx   |   12 ++++++++++++
 vcl/unx/gtk3/gtk3gtkinst.cxx    |    5 +++++
 4 files changed, 26 insertions(+)

New commits:
commit d17d9500a23705a315992ff42cb7c449894fc2ce
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Apr 16 14:49:46 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Apr 17 11:24:11 2019 +0200

    tdf#124597 template select dialog launched before parent gets final size
    
    Change-Id: If9f6fa6e072a95381aaf4a539e2081733a0248ec
    Reviewed-on: https://gerrit.libreoffice.org/70828
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 77205ced1f69..d2929d69bc9a 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -332,6 +332,10 @@ public:
     virtual bool get_resizable() const = 0;
     virtual Size get_size() const = 0;
     virtual Point get_position() const = 0;
+    // ensure window will be centered on its parent, taking into account that
+    // there may currently be pending geometry requests for the parent
+    // not yet processed by the underlying toolkit
+    virtual void set_centered_on_parent_geometry_request() = 0;
     virtual bool has_toplevel_focus() const = 0;
     virtual void present() = 0;
     virtual void set_window_state(const OString& rStr) = 0;
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 0136c425f987..77ca1eb9b7dc 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1385,6 +1385,11 @@ SfxTemplateSelectionDlg::~SfxTemplateSelectionDlg()
 
 short SfxTemplateSelectionDlg::run()
 {
+    // tdf#124597 at startup this dialog is launched before its parent window
+    // has taken its final size. The parent size request is processed during
+    // the dialogs event loop so configure this dialog to center to
+    // the parents pending geometry request
+    m_xDialog->set_centered_on_parent_geometry_request();
     return weld::GenericDialogController::run();
 }
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 310254b1cfeb..59a9ab3b527a 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -970,6 +970,18 @@ public:
         return m_xWindow->GetPosPixel();
     }
 
+    virtual void set_centered_on_parent_geometry_request() override
+    {
+        if (vcl::Window* pParent = m_xWidget->GetParent())
+        {
+            Size aParentGeometry(pParent->GetSizePixel());
+            Size aGeometry(m_xWidget->get_preferred_size());
+            auto nX = (aParentGeometry.Width() - aGeometry.Width()) / 2;
+            auto nY = (aParentGeometry.Height() - aGeometry.Height()) / 2;
+            m_xWidget->SetPosPixel(Point(nX, nY));
+        }
+    }
+
     virtual bool get_resizable() const override
     {
         return m_xWindow->GetStyle() & WB_SIZEABLE;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 19a3ed29edc4..cb816b751cd9 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2498,6 +2498,11 @@ public:
         return Point(current_x, current_y);
     }
 
+    virtual void set_centered_on_parent_geometry_request() override
+    {
+        gtk_window_set_position(m_pWindow, GTK_WIN_POS_CENTER_ALWAYS);
+    }
+
     virtual bool get_resizable() const override
     {
         return gtk_window_get_resizable(m_pWindow);


More information about the Libreoffice-commits mailing list