summaryrefslogtreecommitdiff
path: root/vcl/source/window/dndevdis.cxx
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2010-10-14 22:12:16 -0500
committerNorbert Thiebaud <nthiebaud@gmail.com>2010-10-25 19:55:37 -0500
commitea05f2aa4e28fd40238c4962e9dcbbf0d873cabd (patch)
tree80e77d745b3589bfeb4b1dc0280d5486a339f544 /vcl/source/window/dndevdis.cxx
parent3d99638e462ece3f2d82ccc7fe4a8d281e3f4068 (diff)
migrate OClearableGuard(SoalrMutex) to SolarMutexGuard
Factorized the Guarded piece of code to locate the TopWindow under a given Point, which was repeated verbatim in 4 different functions That allowed as a bonus to remove the need for a ClearableGuard, and allow the use of a straight SolarMutexGuard.
Diffstat (limited to 'vcl/source/window/dndevdis.cxx')
-rw-r--r--vcl/source/window/dndevdis.cxx113
1 files changed, 25 insertions, 88 deletions
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 );