diff options
author | Philipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM> | 2010-07-22 17:19:16 +0200 |
---|---|---|
committer | Philipp Lohmann [pl] <Philipp.Lohmann@Oracle.COM> | 2010-07-22 17:19:16 +0200 |
commit | 6ea3c24201b2d4255306f6e745e242567f3bbb8c (patch) | |
tree | 66ffa792e1ec251282458d52582fc81410159ed6 /vcl/unx/source | |
parent | 5b92062661eb9fe6ecee0ed3fd6356e6d6d9fca9 (diff) |
ooo33gsl03: #i113333# work around a double pointer grab
Diffstat (limited to 'vcl/unx/source')
-rw-r--r-- | vcl/unx/source/dtrans/X11_selection.cxx | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/vcl/unx/source/dtrans/X11_selection.cxx b/vcl/unx/source/dtrans/X11_selection.cxx index 7f205407b21b..4bb24e03917b 100644 --- a/vcl/unx/source/dtrans/X11_selection.cxx +++ b/vcl/unx/source/dtrans/X11_selection.cxx @@ -28,15 +28,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" +#include "saldisp.hxx" +#include "saldata.hxx" + #include <unistd.h> #include <stdio.h> #include <string.h> #include <sys/time.h> + #include "tools/prex.h" #include <X11/Xatom.h> #include <X11/keysym.h> -#include <X11/Xlib.h> -#include <X11/X.h> #include <X11/Xutil.h> #include "tools/postx.h" #if defined(LINUX) || defined(NETBSD) || defined (FREEBSD) @@ -3259,6 +3261,8 @@ void SelectionManager::startDrag( return; } + SalFrame* pCaptureFrame = NULL; + { ClearableMutexGuard aGuard(m_aMutex); @@ -3327,6 +3331,32 @@ void SelectionManager::startDrag( None, None, CurrentTime ); + /* if we could not grab the pointer here, there is a chance + that the pointer is grabbed by the other vcl display (the main loop) + so let's break that grab an reset it later + + remark: this whole code should really be molten into normal vcl so only + one display is used .... + */ + if( nPointerGrabSuccess != GrabSuccess ) + { + vos::IMutex& rSolarMutex( Application::GetSolarMutex() ); + if( rSolarMutex.tryToAcquire() ) + { + pCaptureFrame = GetX11SalData()->GetDisplay()->GetCaptureFrame(); + if( pCaptureFrame ) + { + GetX11SalData()->GetDisplay()->CaptureMouse( NULL ); + nPointerGrabSuccess = + XGrabPointer( m_pDisplay, it->second.m_aRootWindow, True, + DRAG_EVENT_MASK, + GrabModeAsync, GrabModeAsync, + None, + None, + CurrentTime ); + } + } + } #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "%d\n", nPointerGrabSuccess ); #endif @@ -3349,6 +3379,16 @@ void SelectionManager::startDrag( aGuard.clear(); if( listener.is() ) listener->dragDropEnd( aDragFailedEvent ); + if( pCaptureFrame ) + { + vos::IMutex& rSolarMutex( Application::GetSolarMutex() ); + if( rSolarMutex.tryToAcquire() ) + GetX11SalData()->GetDisplay()->CaptureMouse( pCaptureFrame ); +#if OSL_DEBUG_LEVEL > 0 + else + OSL_ENSURE( 0, "failed to acquire SolarMutex to reset capture frame" ); +#endif + } return; } @@ -3428,6 +3468,17 @@ void SelectionManager::startDrag( XUngrabKeyboard( m_pDisplay, CurrentTime ); XFlush( m_pDisplay ); + if( pCaptureFrame ) + { + vos::IMutex& rSolarMutex( Application::GetSolarMutex() ); + if( rSolarMutex.tryToAcquire() ) + GetX11SalData()->GetDisplay()->CaptureMouse( pCaptureFrame ); +#if OSL_DEBUG_LEVEL > 0 + else + OSL_ENSURE( 0, "failed to acquire SolarMutex to reset capture frame" ); +#endif + } + m_aDragRunning.reset(); if( listener.is() ) |