diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-04-10 11:21:32 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-04-17 08:20:26 +0200 |
commit | 6f43902b12dd36fa2b69401065df198ef9ffdb09 (patch) | |
tree | ceec26c88e04371cf7acff07fbf023afb1bba3c0 /toolkit | |
parent | c650217cc543080928a26de4bfc07ebb0be5c6ca (diff) |
tdf#122920 Send UNO mouse events to parent window listeners as well
When user registers a mouse listener to a window, he expects
to receive mouse events when a user clicks in somewhere in that
window, even if it's technically a widget inside that window
Change-Id: Ie6d3f8b140e4a5b516051014282b43775ecec59e
Reviewed-on: https://gerrit.libreoffice.org/70512
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/vclxwindow.cxx | 84 |
1 files changed, 50 insertions, 34 deletions
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 4442f1714727..0f37e710e0b2 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -703,50 +703,66 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) case VclEventId::WindowMouseMove: { MouseEvent* pMouseEvt = static_cast<MouseEvent*>(rVclWindowEvent.GetData()); - if ( mpImpl->getMouseListeners().getLength() && ( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() ) ) + VclPtr<vcl::Window> pWin = GetWindow(); + while (pWin) { - awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) ); - bool const isEnter(pMouseEvt->IsEnterWindow()); - Callback aCallback = [ this, isEnter, aEvent ]() - { MouseListenerMultiplexer& rMouseListeners = this->mpImpl->getMouseListeners(); - isEnter - ? rMouseListeners.mouseEntered(aEvent) - : rMouseListeners.mouseExited(aEvent); }; - - ImplExecuteAsyncWithoutSolarLock( aCallback ); - } + VCLXWindow* pXWindow = pWin->GetWindowPeer(); + if (!pXWindow || pXWindow->mpImpl->getMouseListeners().getLength() == 0) + { + pWin = pWin->GetWindow(GetWindowType::RealParent); + continue; + } + awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(*pMouseEvt, *pXWindow)); - if ( mpImpl->getMouseMotionListeners().getLength() && !pMouseEvt->IsEnterWindow() && !pMouseEvt->IsLeaveWindow() ) - { - awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) ); - aEvent.ClickCount = 0; - if ( pMouseEvt->GetMode() & MouseEventModifiers::SIMPLEMOVE ) - mpImpl->getMouseMotionListeners().mouseMoved( aEvent ); + if (pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow()) + { + bool const isEnter(pMouseEvt->IsEnterWindow()); + Callback aCallback = [pXWindow, isEnter, aEvent]() { + isEnter ? pXWindow->mpImpl->getMouseListeners().mouseEntered(aEvent) + : pXWindow->mpImpl->getMouseListeners().mouseExited(aEvent); + }; + ImplExecuteAsyncWithoutSolarLock(aCallback); + } else - mpImpl->getMouseMotionListeners().mouseDragged( aEvent ); + { + aEvent.ClickCount = 0; + MouseMotionListenerMultiplexer& rMouseListeners + = pXWindow->mpImpl->getMouseMotionListeners(); + if (pMouseEvt->GetMode() & MouseEventModifiers::SIMPLEMOVE) + rMouseListeners.mouseMoved(aEvent); + else + rMouseListeners.mouseDragged(aEvent); + } + + // Next window (parent) + pWin = pWin->GetWindow(GetWindowType::RealParent); } } break; case VclEventId::WindowMouseButtonDown: - { - if ( mpImpl->getMouseListeners().getLength() ) - { - awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast<MouseEvent*>(rVclWindowEvent.GetData()), *this ) ); - Callback aCallback = [ this, aEvent ]() - { this->mpImpl->getMouseListeners().mousePressed( aEvent ); }; - ImplExecuteAsyncWithoutSolarLock( aCallback ); - } - } - break; case VclEventId::WindowMouseButtonUp: { - if ( mpImpl->getMouseListeners().getLength() ) + VclPtr<vcl::Window> pWin = GetWindow(); + while (pWin) { - awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast<MouseEvent*>(rVclWindowEvent.GetData()), *this ) ); - - Callback aCallback = [ this, aEvent ]() - { this->mpImpl->getMouseListeners().mouseReleased( aEvent ); }; - ImplExecuteAsyncWithoutSolarLock( aCallback ); + VCLXWindow* pXWindow = pWin->GetWindowPeer(); + if (!pXWindow || pXWindow->mpImpl->getMouseListeners().getLength() == 0) + { + pWin = pWin->GetWindow(GetWindowType::RealParent); + continue; + } + MouseEvent* pMouseEvt = static_cast<MouseEvent*>(rVclWindowEvent.GetData()); + awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(*pMouseEvt, *pXWindow)); + VclEventId eventId = rVclWindowEvent.GetId(); + Callback aCallback = [pXWindow, aEvent, eventId]() { + eventId == VclEventId::WindowMouseButtonDown + ? pXWindow->mpImpl->getMouseListeners().mousePressed(aEvent) + : pXWindow->mpImpl->getMouseListeners().mouseReleased(aEvent); + }; + ImplExecuteAsyncWithoutSolarLock(aCallback); + + // Next window (parent) + pWin = pWin->GetWindow(GetWindowType::RealParent); } } break; |