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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 7 07:55:13 UTC 2019


 include/sfx2/templatedlg.hxx    |    3 +++
 include/vcl/weld.hxx            |   15 +++++++++++----
 sfx2/source/doc/templatedlg.cxx |   14 +++++++++++++-
 uui/source/passworddlg.cxx      |    2 +-
 vcl/source/app/salvtables.cxx   |    2 +-
 vcl/unx/gtk3/gtk3gtkinst.cxx    |    7 +++++--
 6 files changed, 34 insertions(+), 9 deletions(-)

New commits:
commit 5e8d51ca7b597eeaf9f8cfbb1c97e8ab51b030a8
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri May 3 12:37:32 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 7 09:54:39 2019 +0200

    tdf#125079 turn off GTK_WIN_POS_CENTER_ON_PARENT after a while
    
    Change-Id: Ib268a6b32257aee812e5bae27a6db94431d2abbb
    Reviewed-on: https://gerrit.libreoffice.org/71739
    Tested-by: Jenkins
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx
index e8ff1610caa3..dd821bdf3d05 100644
--- a/include/sfx2/templatedlg.hxx
+++ b/include/sfx2/templatedlg.hxx
@@ -15,6 +15,7 @@
 
 #include <set>
 
+#include <vcl/idle.hxx>
 #include <vcl/timer.hxx>
 #include <vcl/weld.hxx>
 
@@ -197,8 +198,10 @@ public:
 private:
     DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
     DECL_LINK(OkClickHdl, weld::Button&, void);
+    DECL_LINK(TimeOut, Timer*, void);
 
     OUString msTemplatePath;
+    Idle maIdle;
 };
 
 #endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 4bc3e0893cf2..be325ab9af34 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -342,10 +342,17 @@ 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;
+    // center window on is parent
+    //
+    // bTrackGeometryRequests set to true tries to ensure the window will end
+    // up still centered on its parent windows final size, taking into account
+    // that there may currently be pending geometry requests for the parent not
+    // yet processed by the underlying toolkit
+    //
+    // for e.g gtk this will means the window is always centered even when
+    // resized, calling set_centered_on_parent with false will turn this
+    // off again.
+    virtual void set_centered_on_parent(bool bTrackGeometryRequests) = 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 77ca1eb9b7dc..909a43ed30e5 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1381,6 +1381,7 @@ SfxTemplateSelectionDlg::SfxTemplateSelectionDlg(weld::Window* pParent)
 
 SfxTemplateSelectionDlg::~SfxTemplateSelectionDlg()
 {
+    maIdle.Stop();
 }
 
 short SfxTemplateSelectionDlg::run()
@@ -1389,10 +1390,21 @@ short SfxTemplateSelectionDlg::run()
     // 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();
+    m_xDialog->set_centered_on_parent(true);
+
+    // tdf#125079 toggle off the size tracking at some future idle point
+    maIdle.SetPriority(TaskPriority::LOWEST);
+    maIdle.SetInvokeHandler(LINK(this,SfxTemplateSelectionDlg,TimeOut));
+    maIdle.Start();
+
     return weld::GenericDialogController::run();
 }
 
+IMPL_LINK_NOARG(SfxTemplateSelectionDlg, TimeOut, Timer*, void)
+{
+    m_xDialog->set_centered_on_parent(false);
+}
+
 IMPL_LINK(SfxTemplateSelectionDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem, void)
 {
     TemplateViewItem *pViewItem = static_cast<TemplateViewItem*>(pItem);
diff --git a/uui/source/passworddlg.cxx b/uui/source/passworddlg.cxx
index ffa2897b24dc..7fa17d356cbf 100644
--- a/uui/source/passworddlg.cxx
+++ b/uui/source/passworddlg.cxx
@@ -42,7 +42,7 @@ PasswordDialog::PasswordDialog(weld::Window* pParent,
     , rResLocale(rLocale)
 {
     // tdf#115964 we can be launched before the parent has resized to its final size
-    m_xDialog->set_centered_on_parent_geometry_request();
+    m_xDialog->set_centered_on_parent(true);
 
     if( nDialogMode == task::PasswordRequestMode_PASSWORD_REENTER )
     {
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 4ed1d96158e4..6a7f3ab5c5d7 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -984,7 +984,7 @@ public:
         return m_xWindow->GetPosPixel();
     }
 
-    virtual void set_centered_on_parent_geometry_request() override
+    virtual void set_centered_on_parent(bool /*bTrackGeometryRequests*/) override
     {
         if (vcl::Window* pParent = m_xWidget->GetParent())
         {
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index b1c7cf963d3f..bb1803828ffa 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2582,9 +2582,12 @@ public:
         return Point(current_x, current_y);
     }
 
-    virtual void set_centered_on_parent_geometry_request() override
+    virtual void set_centered_on_parent(bool bTrackGeometryRequests) override
     {
-        gtk_window_set_position(m_pWindow, GTK_WIN_POS_CENTER_ALWAYS);
+        if (bTrackGeometryRequests)
+            gtk_window_set_position(m_pWindow, GTK_WIN_POS_CENTER_ALWAYS);
+        else
+            gtk_window_set_position(m_pWindow, GTK_WIN_POS_CENTER_ON_PARENT);
     }
 
     virtual bool get_resizable() const override


More information about the Libreoffice-commits mailing list