diff options
-rw-r--r-- | vcl/inc/vcl/dndevdis.hxx | 1 | ||||
-rw-r--r-- | vcl/source/window/dndevdis.cxx | 113 |
2 files changed, 26 insertions, 88 deletions
diff --git a/vcl/inc/vcl/dndevdis.hxx b/vcl/inc/vcl/dndevdis.hxx index 1fb1bba574e2..41be5ba3fc38 100644 --- a/vcl/inc/vcl/dndevdis.hxx +++ b/vcl/inc/vcl/dndevdis.hxx @@ -47,6 +47,7 @@ class DNDEventDispatcher: public ::cppu::WeakImplHelper3< ::osl::Mutex m_aMutex; ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavorList; + Window* findTopLevelWindow(Point location); /* * fire the events on the dnd listener container of the specified window */ diff --git a/vcl/source/window/dndevdis.cxx b/vcl/source/window/dndevdis.cxx index aacb106eac4b..05ec366a509b 100644 --- a/vcl/source/window/dndevdis.cxx +++ b/vcl/source/window/dndevdis.cxx @@ -62,20 +62,11 @@ DNDEventDispatcher::~DNDEventDispatcher() { } -//================================================================================================== -// DNDEventDispatcher::drop -//================================================================================================== - -void SAL_CALL DNDEventDispatcher::drop( const DropTargetDropEvent& dtde ) - throw(RuntimeException) +Window* DNDEventDispatcher::findTopLevelWindow(Point location) { - MutexGuard aImplGuard( m_aMutex ); - - Point location( dtde.LocationX, dtde.LocationY ); + SolarMutexGuard aSolarGuard; // find the window that is toplevel for this coordinates - OClearableGuard aSolarGuard( Application::GetSolarMutex() ); - // because those coordinates come from outside, they must be mirrored if RTL layout is active if( Application::GetSettings().GetLayoutRTL() ) m_pTopWindow->ImplMirrorFramePos( location ); @@ -90,7 +81,21 @@ void SAL_CALL DNDEventDispatcher::drop( const DropTargetDropEvent& dtde ) if( pChildWindow->ImplIsAntiparallel() ) pChildWindow->ImplReMirror( location ); - aSolarGuard.clear(); + return pChildWindow; +} + +//================================================================================================== +// DNDEventDispatcher::drop +//================================================================================================== + +void SAL_CALL DNDEventDispatcher::drop( const DropTargetDropEvent& dtde ) + throw(RuntimeException) +{ + MutexGuard aImplGuard( m_aMutex ); + + Point location( dtde.LocationX, dtde.LocationY ); + + Window* pChildWindow = findTopLevelWindow(location); // handle the case that drop is in an other vcl window than the last dragOver if( pChildWindow != m_pCurrentWindow ) @@ -129,24 +134,7 @@ void SAL_CALL DNDEventDispatcher::dragEnter( const DropTargetDragEnterEvent& dtd MutexGuard aImplGuard( m_aMutex ); Point location( dtdee.LocationX, dtdee.LocationY ); - // find the window that is toplevel for this coordinates - OClearableGuard aSolarGuard( Application::GetSolarMutex() ); - - // because those coordinates come from outside, they must be mirrored if RTL layout is active - if( Application::GetSettings().GetLayoutRTL() ) - m_pTopWindow->ImplMirrorFramePos( location ); - Window * pChildWindow = m_pTopWindow->ImplFindWindow( location ); - - if( NULL == pChildWindow ) - pChildWindow = m_pTopWindow; - - while( pChildWindow->ImplGetClientWindow() ) - pChildWindow = pChildWindow->ImplGetClientWindow(); - - if( pChildWindow->ImplIsAntiparallel() ) - pChildWindow->ImplReMirror( location ); - - aSolarGuard.clear(); + Window * pChildWindow = findTopLevelWindow(location); // assume pointer write operation to be atomic m_pCurrentWindow = pChildWindow; @@ -192,24 +180,7 @@ void SAL_CALL DNDEventDispatcher::dragOver( const DropTargetDragEvent& dtde ) Point location( dtde.LocationX, dtde.LocationY ); sal_Int32 nListeners; - // find the window that is toplevel for this coordinates - OClearableGuard aSolarGuard( Application::GetSolarMutex() ); - - // because those coordinates come from outside, they must be mirrored if RTL layout is active - if( Application::GetSettings().GetLayoutRTL() ) - m_pTopWindow->ImplMirrorFramePos( location ); - Window * pChildWindow = m_pTopWindow->ImplFindWindow( location ); - - if( NULL == pChildWindow ) - pChildWindow = m_pTopWindow; - - while( pChildWindow->ImplGetClientWindow() ) - pChildWindow = pChildWindow->ImplGetClientWindow(); - - if( pChildWindow->ImplIsAntiparallel() ) - pChildWindow->ImplReMirror( location ); - - aSolarGuard.clear(); + Window * pChildWindow = findTopLevelWindow(location); if( pChildWindow != m_pCurrentWindow ) { @@ -250,24 +221,7 @@ void SAL_CALL DNDEventDispatcher::dropActionChanged( const DropTargetDragEvent& Point location( dtde.LocationX, dtde.LocationY ); sal_Int32 nListeners; - // find the window that is toplevel for this coordinates - OClearableGuard aSolarGuard( Application::GetSolarMutex() ); - - // because those coordinates come from outside, they must be mirrored if RTL layout is active - if( Application::GetSettings().GetLayoutRTL() ) - m_pTopWindow->ImplMirrorFramePos( location ); - Window * pChildWindow = m_pTopWindow->ImplFindWindow( location ); - - if( NULL == pChildWindow ) - pChildWindow = m_pTopWindow; - - while( pChildWindow->ImplGetClientWindow() ) - pChildWindow = pChildWindow->ImplGetClientWindow(); - - if( pChildWindow->ImplIsAntiparallel() ) - pChildWindow->ImplReMirror( location ); - - aSolarGuard.clear(); + Window* pChildWindow = findTopLevelWindow(location); if( pChildWindow != m_pCurrentWindow ) { @@ -307,24 +261,7 @@ void SAL_CALL DNDEventDispatcher::dragGestureRecognized( const DragGestureEvent& Point origin( dge.DragOriginX, dge.DragOriginY ); - // find the window that is toplevel for this coordinates - OClearableGuard aSolarGuard( Application::GetSolarMutex() ); - - // because those coordinates come from outside, they must be mirrored if RTL layout is active - if( Application::GetSettings().GetLayoutRTL() ) - m_pTopWindow->ImplMirrorFramePos( origin ); - Window * pChildWindow = m_pTopWindow->ImplFindWindow( origin ); - - if( NULL == pChildWindow ) - pChildWindow = m_pTopWindow; - - while( pChildWindow->ImplGetClientWindow() ) - pChildWindow = pChildWindow->ImplGetClientWindow(); - - if( pChildWindow->ImplIsAntiparallel() ) - pChildWindow->ImplReMirror( origin ); - - aSolarGuard.clear(); + Window* pChildWindow = findTopLevelWindow(origin); fireDragGestureEvent( pChildWindow, dge.DragSource, dge.Event, origin, dge.DragAction ); } @@ -368,7 +305,7 @@ sal_Int32 DNDEventDispatcher::fireDragEnterEvent( Window *pWindow, if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) { - OClearableGuard aGuard( Application::GetSolarMutex() ); + SolarMutexClearableGuard aSolarGuard; // set an UI lock pWindow->IncrementLockCount(); @@ -380,7 +317,7 @@ sal_Int32 DNDEventDispatcher::fireDragEnterEvent( Window *pWindow, { // retrieve relative mouse position Point relLoc = pWindow->ImplFrameToOutput( rLocation ); - aGuard.clear(); + aSolarGuard.clear(); n = static_cast < DNDListenerContainer * > ( xDropTarget.get() )->fireDragEnterEvent( xContext, nDropAction, relLoc.X(), relLoc.Y(), nSourceActions, aFlavorList ); @@ -404,7 +341,7 @@ sal_Int32 DNDEventDispatcher::fireDragOverEvent( Window *pWindow, if( pWindow && pWindow->IsInputEnabled() && ! pWindow->IsInModalMode() ) { - OClearableGuard aGuard( Application::GetSolarMutex() ); + SolarMutexClearableGuard aSolarGuard; // query DropTarget from window Reference< XDropTarget > xDropTarget = pWindow->GetDropTarget(); @@ -413,7 +350,7 @@ sal_Int32 DNDEventDispatcher::fireDragOverEvent( Window *pWindow, { // retrieve relative mouse position Point relLoc = pWindow->ImplFrameToOutput( rLocation ); - aGuard.clear(); + aSolarGuard.clear(); n = static_cast < DNDListenerContainer * > ( xDropTarget.get() )->fireDragOverEvent( xContext, nDropAction, relLoc.X(), relLoc.Y(), nSourceActions ); |