diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-03-03 13:52:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-03-03 13:56:07 +0000 |
commit | fbea89b6b2a4a91fecc4200d59bf03166c3f8908 (patch) | |
tree | 5babc3e0a8e952f7214803f1199fda96048fde35 /vcl | |
parent | 509bc5e5cf8129d07b5d8cf22d4bfe9c968303c6 (diff) |
refactor these two bizarro positioning things into reusable chunks
Change-Id: I3f89aca650d31658ce17b3b1496a7babba23bdc6
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/floatwin.cxx | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx index ed997c8020af..00c3b34f0388 100644 --- a/vcl/source/window/floatwin.cxx +++ b/vcl/source/window/floatwin.cxx @@ -449,10 +449,8 @@ Point FloatingWindow::ImplCalcPos( vcl::Window* pWindow, return pW->OutputToScreenPixel( aPos ); } -FloatingWindow* FloatingWindow::ImplFloatHitTest( vcl::Window* pReference, const Point& rPos, HitTest& rHitTest ) +Point FloatingWindow::ImplConvertToAbsPos(vcl::Window* pReference, const Point& rPos) { - FloatingWindow* pWin = this; - Point aAbsolute( rPos ); const OutputDevice *pWindowOutDev = pReference->GetOutDev(); @@ -472,6 +470,37 @@ FloatingWindow* FloatingWindow::ImplFloatHitTest( vcl::Window* pReference, const aAbsolute = Point( pReference->OutputToAbsoluteScreenPixel( pReference->ScreenToOutputPixel(rPos) ) ); + return aAbsolute; +} + +Rectangle FloatingWindow::ImplConvertToAbsPos(vcl::Window* pReference, const Rectangle& rRect) +{ + Rectangle aFloatRect = rRect; + + const OutputDevice *pParentWinOutDev = pReference->GetOutDev(); + + // compare coordinates in absolute screen coordinates + // Keep in sync with FloatingWindow::ImplFloatHitTest, e.g. fdo#33509 + if( pReference->HasMirroredGraphics() ) + { + if(!pReference->IsRTLEnabled() ) + // --- RTL --- re-mirror back to get device coordinates + pParentWinOutDev->ReMirror(aFloatRect); + + aFloatRect.SetPos(pReference->ScreenToOutputPixel(aFloatRect.TopLeft())); + aFloatRect = pReference->ImplOutputToUnmirroredAbsoluteScreenPixel(aFloatRect); + } + else + aFloatRect.SetPos(pReference->OutputToAbsoluteScreenPixel(pReference->ScreenToOutputPixel(rRect.TopLeft()))); + return aFloatRect; +} + +FloatingWindow* FloatingWindow::ImplFloatHitTest( vcl::Window* pReference, const Point& rPos, HitTest& rHitTest ) +{ + FloatingWindow* pWin = this; + + Point aAbsolute(FloatingWindow::ImplConvertToAbsPos(pReference, rPos)); + do { // compute the floating window's size in absolute screen coordinates @@ -665,24 +694,7 @@ void FloatingWindow::StartPopupMode( const Rectangle& rRect, FloatWinPopupFlags // convert maFloatRect to absolute device coordinates // so they can be compared across different frames // !!! rRect is expected to be in screen coordinates of the parent frame window !!! - maFloatRect = rRect; - - vcl::Window *pReference = GetParent(); - const OutputDevice *pParentWinOutDev = pReference->GetOutDev(); - - // compare coordinates in absolute screen coordinates - // Keep in sync with FloatingWindow::ImplFloatHitTest, e.g. fdo#33509 - if( pReference->HasMirroredGraphics() ) - { - if(!pReference->IsRTLEnabled() ) - // --- RTL --- re-mirror back to get device coordinates - pParentWinOutDev->ReMirror(maFloatRect); - - maFloatRect.SetPos(pReference->ScreenToOutputPixel(maFloatRect.TopLeft())); - maFloatRect = pReference->ImplOutputToUnmirroredAbsoluteScreenPixel(maFloatRect); - } - else - maFloatRect.SetPos(pReference->OutputToAbsoluteScreenPixel(pReference->ScreenToOutputPixel(rRect.TopLeft()))); + maFloatRect = FloatingWindow::ImplConvertToAbsPos(GetParent(), rRect); maFloatRect.Left() -= 2; maFloatRect.Top() -= 2; |