summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-11 10:52:52 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-11 12:19:21 +0100
commitaadc7ee973c1f28a0e17d551fef6b76e015a28ef (patch)
treecc72fdd80dd6f04831c4f41f40467ffe18c19ebe /toolkit
parent24f17f0336badfbba276c1e6713a89b4f9bb7cb8 (diff)
tdf#127921 Revert mouse/key listeners to original state
The changes caused several issues in the presenter console (mouse events delivered to wrong widgets). Also it turned up that parent windows got the notification about mouse events from their children, but the position was always relative to the top widget, so very unhelpful for the parent widgets. Also I found out that there are XKeyHandler and XMouseClickHandler interfaces which already do what I tried to do with the below commits (events get passed down to parent widgets, and they even can be marked as consumed). So the original issue reported can be fixed by using XKeyHandler/XMouseClickHandler instead. This reverts the following two commits: * "Related tdf#122920 Treat UNO key events the same as mouse events" 9e0e97b716ab074d4558c76a62a66bf597f332a5 * "tdf#122920 Send UNO mouse events to parent window listeners as well" 6f43902b12dd36fa2b69401065df198ef9ffdb09 Change-Id: I005d22770a7a4db9588c5bc22197dc0ae526627e Reviewed-on: https://gerrit.libreoffice.org/82423 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/awt/vclxwindow.cxx117
1 files changed, 49 insertions, 68 deletions
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index 7e9478ed3121..83b17f2fbf8e 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -644,27 +644,24 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
}
break;
case VclEventId::WindowKeyInput:
+ {
+ if ( mpImpl->getKeyListeners().getLength() )
+ {
+ css::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent(
+ *static_cast<KeyEvent*>(rVclWindowEvent.GetData()), *this
+ ) );
+ mpImpl->getKeyListeners().keyPressed( aEvent );
+ }
+ }
+ break;
case VclEventId::WindowKeyUp:
{
- VclPtr<vcl::Window> pWin = GetWindow();
- while (pWin)
+ if ( mpImpl->getKeyListeners().getLength() )
{
- VCLXWindow* pXWindow = pWin->GetWindowPeer();
- if (!pXWindow || pXWindow->mpImpl->getKeyListeners().getLength() == 0)
- {
- pWin = pWin->GetWindow(GetWindowType::RealParent);
- continue;
- }
-
- awt::KeyEvent aEvent(VCLUnoHelper::createKeyEvent(
- *static_cast<KeyEvent*>(rVclWindowEvent.GetData()), *this));
- if (rVclWindowEvent.GetId() == VclEventId::WindowKeyInput)
- pXWindow->mpImpl->getKeyListeners().keyPressed(aEvent);
- else
- pXWindow->mpImpl->getKeyListeners().keyReleased(aEvent);
-
- // Next window (parent)
- pWin = pWin->GetWindow(GetWindowType::RealParent);
+ css::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent(
+ *static_cast<KeyEvent*>(rVclWindowEvent.GetData()), *this
+ ) );
+ mpImpl->getKeyListeners().keyReleased( aEvent );
}
}
break;
@@ -697,66 +694,50 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
case VclEventId::WindowMouseMove:
{
MouseEvent* pMouseEvt = static_cast<MouseEvent*>(rVclWindowEvent.GetData());
- VclPtr<vcl::Window> pWin = GetWindow();
- while (pWin)
+ if ( mpImpl->getMouseListeners().getLength() && ( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() ) )
{
- VCLXWindow* pXWindow = pWin->GetWindowPeer();
- if (!pXWindow || pXWindow->mpImpl->getMouseListeners().getLength() == 0)
- {
- pWin = pWin->GetWindow(GetWindowType::RealParent);
- continue;
- }
- awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(*pMouseEvt, *pXWindow));
+ 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); };
- 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
- {
- aEvent.ClickCount = 0;
- MouseMotionListenerMultiplexer& rMouseListeners
- = pXWindow->mpImpl->getMouseMotionListeners();
- if (pMouseEvt->GetMode() & MouseEventModifiers::SIMPLEMOVE)
- rMouseListeners.mouseMoved(aEvent);
- else
- rMouseListeners.mouseDragged(aEvent);
- }
+ ImplExecuteAsyncWithoutSolarLock( aCallback );
+ }
- // Next window (parent)
- pWin = pWin->GetWindow(GetWindowType::RealParent);
+ 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 );
+ else
+ mpImpl->getMouseMotionListeners().mouseDragged( aEvent );
}
}
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:
{
- VclPtr<vcl::Window> pWin = GetWindow();
- while (pWin)
+ if ( mpImpl->getMouseListeners().getLength() )
{
- 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);
+ awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast<MouseEvent*>(rVclWindowEvent.GetData()), *this ) );
+
+ Callback aCallback = [ this, aEvent ]()
+ { this->mpImpl->getMouseListeners().mouseReleased( aEvent ); };
+ ImplExecuteAsyncWithoutSolarLock( aCallback );
}
}
break;