diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-12-09 15:43:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-12-09 15:46:12 +0000 |
commit | efbd8f7ae0818dd914b6b1cb0b3d86b3a58f5f3e (patch) | |
tree | 791997bb09d82cd4e46bc77380673ae53f6f5072 /vcl | |
parent | efc0752802ea526a326447cc8827e66f8af00cad (diff) |
Resolves: fdo#81421 listen to child window to see if it gets deleted
Change-Id: Iae2c642ad992c822720bcf1e34827bfaa35876b6
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/dndevdis.hxx | 3 | ||||
-rw-r--r-- | vcl/source/window/dndevdis.cxx | 33 |
2 files changed, 27 insertions, 9 deletions
diff --git a/vcl/inc/dndevdis.hxx b/vcl/inc/dndevdis.hxx index 5a1c0797dd7f..2f356c719b7b 100644 --- a/vcl/inc/dndevdis.hxx +++ b/vcl/inc/dndevdis.hxx @@ -33,7 +33,10 @@ class DNDEventDispatcher: public ::cppu::WeakImplHelper3< ::com::sun::star::datatransfer::dnd::XDragGestureListener > { vcl::Window * m_pTopWindow; + vcl::Window * m_pCurrentWindow; + void designate_currentwindow(vcl::Window *pWindow); + DECL_LINK(WindowEventListener, VclSimpleEvent*); ::osl::Mutex m_aMutex; ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavorList; diff --git a/vcl/source/window/dndevdis.cxx b/vcl/source/window/dndevdis.cxx index e7c3732c56f6..f422a9d99149 100644 --- a/vcl/source/window/dndevdis.cxx +++ b/vcl/source/window/dndevdis.cxx @@ -33,7 +33,6 @@ using namespace ::com::sun::star::datatransfer; using namespace ::com::sun::star::datatransfer::dnd; // DNDEventDispatcher::DNDEventDispatcher - DNDEventDispatcher::DNDEventDispatcher( vcl::Window * pTopWindow ): m_pTopWindow( pTopWindow ), m_pCurrentWindow( NULL ) @@ -41,9 +40,9 @@ DNDEventDispatcher::DNDEventDispatcher( vcl::Window * pTopWindow ): } // DNDEventDispatcher::~DNDEventDispatcher - DNDEventDispatcher::~DNDEventDispatcher() { + designate_currentwindow(NULL); } vcl::Window* DNDEventDispatcher::findTopLevelWindow(Point location) @@ -71,8 +70,25 @@ vcl::Window* DNDEventDispatcher::findTopLevelWindow(Point location) return pChildWindow; } -// DNDEventDispatcher::drop +IMPL_LINK(DNDEventDispatcher, WindowEventListener, VclSimpleEvent*, pEvent) +{ + if (pEvent && pEvent->GetId() == VCLEVENT_OBJECT_DYING) + { + designate_currentwindow(NULL); + } + return 0; +} + +void DNDEventDispatcher::designate_currentwindow(vcl::Window *pWindow) +{ + if (m_pCurrentWindow) + m_pCurrentWindow->RemoveEventListener(LINK(this, DNDEventDispatcher, WindowEventListener)); + m_pCurrentWindow = pWindow; + if (m_pCurrentWindow) + m_pCurrentWindow->AddEventListener(LINK(this, DNDEventDispatcher, WindowEventListener)); +} +// DNDEventDispatcher::drop void SAL_CALL DNDEventDispatcher::drop( const DropTargetDropEvent& dtde ) throw(RuntimeException, std::exception) { @@ -105,7 +121,7 @@ void SAL_CALL DNDEventDispatcher::drop( const DropTargetDropEvent& dtde ) } // this is a drop -> no further drag overs - m_pCurrentWindow = NULL; + designate_currentwindow(NULL); m_aDataFlavorList.realloc( 0 ); } @@ -120,7 +136,7 @@ void SAL_CALL DNDEventDispatcher::dragEnter( const DropTargetDragEnterEvent& dtd vcl::Window * pChildWindow = findTopLevelWindow(location); // assume pointer write operation to be atomic - m_pCurrentWindow = pChildWindow; + designate_currentwindow(pChildWindow); m_aDataFlavorList = dtdee.SupportedDataFlavors; // fire dragEnter on listeners of current window @@ -145,7 +161,7 @@ void SAL_CALL DNDEventDispatcher::dragExit( const DropTargetEvent& /*dte*/ ) fireDragExitEvent( m_pCurrentWindow ); // reset member values - m_pCurrentWindow = NULL; + designate_currentwindow(NULL); m_aDataFlavorList.realloc( 0 ); } @@ -167,7 +183,7 @@ void SAL_CALL DNDEventDispatcher::dragOver( const DropTargetDragEvent& dtde ) fireDragExitEvent( m_pCurrentWindow ); // remember new window - m_pCurrentWindow = pChildWindow; + designate_currentwindow(pChildWindow); // fire dragEnter on listeners of current window nListeners = fireDragEnterEvent( pChildWindow, dtde.Context, dtde.DropAction, location, @@ -189,7 +205,6 @@ void SAL_CALL DNDEventDispatcher::dragOver( const DropTargetDragEvent& dtde ) } // DNDEventDispatcher::dropActionChanged - void SAL_CALL DNDEventDispatcher::dropActionChanged( const DropTargetDragEvent& dtde ) throw(RuntimeException, std::exception) { @@ -206,7 +221,7 @@ void SAL_CALL DNDEventDispatcher::dropActionChanged( const DropTargetDragEvent& fireDragExitEvent( m_pCurrentWindow ); // remember new window - m_pCurrentWindow = pChildWindow; + designate_currentwindow(pChildWindow); // fire dragEnter on listeners of current window nListeners = fireDragEnterEvent( pChildWindow, dtde.Context, dtde.DropAction, location, |