diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-12-14 15:08:33 +0000 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-04-22 10:01:06 +0200 |
commit | ec97d25ed63e0db98cc13d090c1d8830e2132a44 (patch) | |
tree | d40f2d49810a6021b194bac5f94c185b9d0bc3ad | |
parent | a4addb0f51123b1c043f8178d6917116d4fb6597 (diff) |
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 <caolanm@redhat.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114408
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | include/vcl/weldutils.hxx | 10 | ||||
-rw-r--r-- | vcl/source/app/weldutils.cxx | 17 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx index 9a29e89d7b5f..ecfe2c7e7dbb 100644 --- a/include/vcl/weldutils.hxx +++ b/include/vcl/weldutils.hxx @@ -24,6 +24,11 @@ class CalendarWrapper; +namespace vcl +{ +class Window; +} + namespace weld { typedef cppu::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base; @@ -401,6 +406,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 237645076330..a4c3de5097b6 100644 --- a/vcl/source/app/weldutils.cxx +++ b/vcl/source/app/weldutils.cxx @@ -14,6 +14,8 @@ #include <svl/zformat.hxx> #include <vcl/builderpage.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> @@ -546,6 +548,21 @@ void WidgetStatusListener::dispose() mxFrame.clear(); mWidget = nullptr; } + +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: */ |