diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-10 21:39:57 +1100 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-10 21:43:28 +1100 |
commit | 603ea975c19ac8826bd0cdf27fb59a9a21f765b4 (patch) | |
tree | 841d0bab7ee801adbddbc7cf83799228c3dc5bd5 /vcl/source | |
parent | b4c6cf513c5bb0ed02b95bbdbb0879a78c1eca65 (diff) |
vcl: ImplTranslate(Command|Mouse)Event changes
ImplTranslateCommandEvent is used exactly once, so remove this function.
ImplTranslateMouseEvent is used a few times, make it local to the file and
tweak.
Added comments to both areas explaining what is being done.
Change-Id: I68cd424a1d586df44957a62a66de3c9876ab873e
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/window/event.cxx | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx index b4e8034f29ad..a31c8026df15 100644 --- a/vcl/source/window/event.cxx +++ b/vcl/source/window/event.cxx @@ -341,11 +341,13 @@ void Window::RemoveUserEvent( ImplSVEvent * nUserEvent ) } -MouseEvent ImplTranslateMouseEvent( const MouseEvent& rE, vcl::Window* pSource, vcl::Window* pDest ) +static MouseEvent ImplTranslateMouseEvent( const MouseEvent& rE, vcl::Window* pSource, vcl::Window* pDest ) { + // the mouse event occured in a different window, we need to translate the coordinates of + // the mouse cursor within that (source) window to the coordinates the mouse cursor would + // be in the destination window Point aPos = pSource->OutputToScreenPixel( rE.GetPosPixel() ); - aPos = pDest->ScreenToOutputPixel( aPos ); - return MouseEvent( aPos, rE.GetClicks(), rE.GetMode(), rE.GetButtons(), rE.GetModifier() ); + return MouseEvent( pDest->ScreenToOutputPixel( aPos ), rE.GetClicks(), rE.GetMode(), rE.GetButtons(), rE.GetModifier() ); } CommandEvent ImplTranslateCommandEvent( const CommandEvent& rCEvt, vcl::Window* pSource, vcl::Window* pDest ) @@ -370,13 +372,26 @@ void Window::ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt ) if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) { - if ( rNEvt.GetWindow() == this ) - // not interested in: The event listeners are already called in ::Command, - // and calling them here a second time doesn't make sense - ; - else + // not interested: The event listeners are already called in ::Command, + // and calling them here a second time doesn't make sense + if ( rNEvt.GetWindow() != this ) { - CommandEvent aCommandEvent = ImplTranslateCommandEvent( *pCEvt, rNEvt.GetWindow(), this ); + CommandEvent aCommandEvent; + + if ( !pCEvt->IsMouseEvent() ) + { + aCommandEvent = *pCEvt; + } + else + { + // the mouse event occured in a different window, we need to translate the coordinates of + // the mouse cursor within that window to the coordinates the mouse cursor would be in the + // current window + vcl::Window* pSource = rNEvt.GetWindow(); + Point aPos = pSource->OutputToScreenPixel( pCEvt->GetMousePosPixel() ); + aCommandEvent = CommandEvent( ScreenToOutputPixel( aPos ), pCEvt->GetCommand(), pCEvt->IsMouseEvent(), pCEvt->GetEventData() ); + } + CallEventListeners( VCLEVENT_WINDOW_COMMAND, &aCommandEvent ); } } |