[Libreoffice-commits] core.git: sw/qa toolkit/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 17 06:21:32 UTC 2019
sw/qa/uitest/writer_tests5/xwindow.py | 10 +---
toolkit/source/awt/vclxwindow.cxx | 84 ++++++++++++++++++++--------------
2 files changed, 54 insertions(+), 40 deletions(-)
New commits:
commit 6f43902b12dd36fa2b69401065df198ef9ffdb09
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Wed Apr 10 11:21:32 2019 +0200
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Wed Apr 17 08:20:26 2019 +0200
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 at cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/sw/qa/uitest/writer_tests5/xwindow.py b/sw/qa/uitest/writer_tests5/xwindow.py
index 81104bb7a3ef..0ed53f49c9c7 100644
--- a/sw/qa/uitest/writer_tests5/xwindow.py
+++ b/sw/qa/uitest/writer_tests5/xwindow.py
@@ -43,15 +43,13 @@ class XMouseListenerExtended(unohelper.Base, XMouseListener):
# is invoked when the mouse enters a window.
@classmethod
def mouseEntered(self, xMouseEvent):
- global mouseEventsIntercepted
- mouseEventsIntercepted += 1
+ # doesn't work in UI tests
return super(XMouseListenerExtended, self).mouseEntered(xMouseEvent)
# is invoked when the mouse exits a window.
@classmethod
def mouseExited(self, xMouseEvent):
- global mouseEventsIntercepted
- mouseEventsIntercepted += 1
+ # doesn't work in UI tests
return super(XMouseListenerExtended, self).mouseExited(xMouseEvent)
@@ -142,8 +140,8 @@ class XWindow(UITestCase):
self.assertEqual(0, keymouseEventsIntercepted)
global mouseEventsIntercepted
- # Not expected 3 interceptions
- self.assertEqual(0, mouseEventsIntercepted)
+ # mousePressed, mouseReleased and mouseEntered should be triggered
+ self.assertEqual(2, mouseEventsIntercepted)
# close document
self.ui_test.close_doc()
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;
More information about the Libreoffice-commits
mailing list