[Libreoffice-commits] core.git: vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Wed Feb 10 10:43:57 UTC 2016


 vcl/source/window/event.cxx |   33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

New commits:
commit 603ea975c19ac8826bd0cdf27fb59a9a21f765b4
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Wed Feb 10 21:39:57 2016 +1100

    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

diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index b4e8034..a31c802 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 );
             }
         }


More information about the Libreoffice-commits mailing list