include/vcl/weldutils.hxx | 10 ++++++++++ vcl/source/app/weldutils.cxx | 16 ++++++++++++++++ 2 files changed, 26 insertions(+)
New commits: commit 097faa945cfc7150d5c556444991f85458e9cea9 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Dec 14 15:08:33 2020 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Dec 15 09:45:19 2020 +0100 add a way to correctly position a weld::Menu given a vcl::Window Change-Id: I7fc6a1bb6cfca40a4a97568f957d127445b4d31c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107727 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx index ddd34d1ed787..43461ab6fb51 100644 --- a/include/vcl/weldutils.hxx +++ b/include/vcl/weldutils.hxx @@ -25,6 +25,11 @@ class CalendarWrapper; +namespace vcl +{ +class Window; +} + namespace weld { typedef cppu::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base; @@ -423,6 +428,11 @@ VCL_DLLPUBLIC void RemoveParentKeepChildren(weld::TreeView& rTreeView, weld::Tre // return the min height of a weld::Entry VCL_DLLPUBLIC int GetMinimumEditHeight(); + +// return the weld::Window of the SalFrame rOutWin is in, and convert rRect +// from relative to rOutWin to relative to that weld::Window suitable for use +// with popup_at_rect +VCL_DLLPUBLIC weld::Window* GetPopupParent(vcl::Window& rOutWin, tools::Rectangle& rRect); } #endif diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx index 837220447063..bce1f478a1f1 100644 --- a/vcl/source/app/weldutils.cxx +++ b/vcl/source/app/weldutils.cxx @@ -16,6 +16,7 @@ #include <vcl/commandevent.hxx> #include <vcl/commandinfoprovider.hxx> #include <vcl/event.hxx> +#include <vcl/floatwin.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/weldutils.hxx> @@ -595,6 +596,21 @@ IMPL_LINK_NOARG(ButtonPressRepeater, RepeatTimerHdl, Timer*, void) m_aRepeat.SetTimeout(Application::GetSettings().GetMouseSettings().GetButtonRepeat()); m_aLink.Call(m_rButton); } + +weld::Window* GetPopupParent(vcl::Window& rOutWin, tools::Rectangle& rRect) +{ + rRect.SetPos(rOutWin.OutputToScreenPixel(rRect.TopLeft())); + rRect = FloatingWindow::ImplConvertToAbsPos(&rOutWin, rRect); + + vcl::Window* pWin = &rOutWin; + while (!pWin->IsTopWindow()) + pWin = pWin->GetParent(); + + rRect = FloatingWindow::ImplConvertToRelPos(pWin, rRect); + rRect.SetPos(pWin->ScreenToOutputPixel(rRect.TopLeft())); + + return rOutWin.GetFrameWeld(); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits