vcl/unx/gtk3/gtkinst.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
New commits: commit be34fe06751609382b5a650d481cf4be2484c6f8 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Jan 26 11:27:18 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Jan 26 14:49:30 2022 +0100 Related: tdf#146648 store last known position when visible to return later if the window is hidden when its position is queried, which is what vcl does and the assumption this is possible is baked in Change-Id: I5ce96a638796a6691eeb1b09578e23752a70c243 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128980 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index f4e89353e77f..548316c49860 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -6002,6 +6002,7 @@ class GtkInstanceWindow : public GtkInstanceContainer, public virtual weld::Wind private: GtkWindow* m_pWindow; rtl::Reference<SalGtkXWindow> m_xWindow; //uno api + std::optional<Point> m_aPosWhileInvis; //tdf#146648 store last known position when visible to return as pos if hidden gulong m_nToplevelFocusChangedSignalId; #if !GTK_CHECK_VERSION(4, 0, 0) @@ -6134,6 +6135,12 @@ public: virtual Point get_position() const override { + if (m_aPosWhileInvis) + { + assert(!get_visible()); + return *m_aPosWhileInvis; + } + int current_x(0), current_y(0); #if !GTK_CHECK_VERSION(4, 0, 0) gtk_window_get_position(m_pWindow, ¤t_x, ¤t_y); @@ -6141,6 +6148,19 @@ public: return Point(current_x, current_y); } + virtual void show() override + { + m_aPosWhileInvis.reset(); + GtkInstanceContainer::show(); + } + + virtual void hide() override + { + if (is_visible()) + m_aPosWhileInvis = get_position(); + GtkInstanceContainer::hide(); + } + virtual tools::Rectangle get_monitor_workarea() const override { return ::get_monitor_workarea(GTK_WIDGET(m_pWindow));