[Libreoffice-commits] core.git: sw/qa toolkit/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 21 15:29:28 UTC 2019
sw/qa/uitest/writer_tests5/xwindow.py | 31 ++++++++++++++++++-------------
toolkit/source/awt/vclxwindow.cxx | 33 ++++++++++++++++++---------------
2 files changed, 36 insertions(+), 28 deletions(-)
New commits:
commit 9e0e97b716ab074d4558c76a62a66bf597f332a5
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue May 21 11:43:31 2019 +0200
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue May 21 17:28:13 2019 +0200
Related tdf#122920 Treat UNO key events the same as mouse events
by sending the notifications to the parent windows as well
Change-Id: Ibb33f608d7b9c3871aadd0c13db32effd99fe698
Reviewed-on: https://gerrit.libreoffice.org/72675
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 b0d9e941e484..a1be89bf2981 100644
--- a/sw/qa/uitest/writer_tests5/xwindow.py
+++ b/sw/qa/uitest/writer_tests5/xwindow.py
@@ -17,12 +17,13 @@ from com.sun.star.awt import XKeyListener
mouseListenerCount = 0
+keyListenerCount = 0
mousePressedEventsIntercepted = 0
mouseReleasedEventsIntercepted = 0
mouseEnteredEventsIntercepted = 0
mouseExitedEventsIntercepted = 0
-keymousePressedEventsIntercepted = 0
-keymouseReleasedEventsIntercepted = 0
+keyPressedEventsIntercepted = 0
+keyReleasedEventsIntercepted = 0
class XMouseListenerExtended(unohelper.Base, XMouseListener):
@@ -57,24 +58,28 @@ class XMouseListenerExtended(unohelper.Base, XMouseListener):
class XKeyListenerExtended(unohelper.Base, XKeyListener):
+ def __init__(self):
+ global keyListenerCount
+ keyListenerCount += 1
+ super().__init__()
+
# is invoked when a key has been pressed
@classmethod
def keyPressed(self, xKeyEvent):
- global keymousePressedEventsIntercepted
- keymousePressedEventsIntercepted += 1
- return super(XKeyListenerExtended, self).keyPressed(xKeyEvent)
+ global keyPressedEventsIntercepted
+ keyPressedEventsIntercepted += 1
# is invoked when a key has been released
@classmethod
def keyReleased(self, xKeyEvent):
- global keymouseReleasedEventsIntercepted
- keymouseReleasedEventsIntercepted += 1
- return super(XKeyListenerExtended, self).keyReleased(xKeyEvent)
+ global keyReleasedEventsIntercepted
+ keyReleasedEventsIntercepted += 1
# Test that registered mouse/key listeners for top window receive mouse/key events
class XWindow(UITestCase):
def test_listeners(self):
global mouseListenerCount
+ global keyListenerCount
self.ui_test.create_doc_in_start_center("writer")
xDoc = self.ui_test.get_component()
@@ -95,6 +100,7 @@ class XWindow(UITestCase):
xKeyListener = XKeyListenerExtended()
self.assertIsNotNone(xKeyListener)
xWindow.addKeyListener(xKeyListener)
+ self.assertEqual(1, keyListenerCount)
# create dummy mouse event
xMouseEvent = MouseEvent()
@@ -115,7 +121,6 @@ class XWindow(UITestCase):
xMouseEvent2.PopupTrigger = False
xMouseEvent2.Source = xWindow
- # send mouse event
xToolkitRobot = xWindow.getToolkit()
self.assertIsNotNone(xToolkitRobot)
@@ -151,13 +156,13 @@ class XWindow(UITestCase):
xWindow.removeKeyListener(xKeyListener)
del xKeyListener
- global keymousePressedEventsIntercepted
+ global keyPressedEventsIntercepted
# Not expected any interceptions
- self.assertEqual(0, keymousePressedEventsIntercepted)
+ self.assertEqual(1, keyPressedEventsIntercepted)
- global keymouseReleasedEventsIntercepted
+ global keyReleasedEventsIntercepted
# Not expected any interceptions
- self.assertEqual(0, keymouseReleasedEventsIntercepted)
+ self.assertEqual(1, keyReleasedEventsIntercepted)
global mousePressedEventsIntercepted
self.assertEqual(2, mousePressedEventsIntercepted)
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index bacb184fded0..27d06f564c34 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -653,24 +653,27 @@ 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:
{
- if ( mpImpl->getKeyListeners().getLength() )
+ VclPtr<vcl::Window> pWin = GetWindow();
+ while (pWin)
{
- css::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent(
- *static_cast<KeyEvent*>(rVclWindowEvent.GetData()), *this
- ) );
- mpImpl->getKeyListeners().keyReleased( aEvent );
+ 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);
}
}
break;
More information about the Libreoffice-commits
mailing list