diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-11-11 10:52:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-11-11 22:31:47 +0100 |
commit | ec0df4a5049709dede6a9c92ed57b29e398ff737 (patch) | |
tree | 06b0c229ced422552a8702dc3f024e95c3f53bab /sw | |
parent | 1f01cf55897582ace26795f21ec548d3a5906c7c (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>
(cherry picked from commit aadc7ee973c1f28a0e17d551fef6b76e015a28ef)
Reviewed-on: https://gerrit.libreoffice.org/82433
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/uitest/writer_tests5/xwindow.py | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/sw/qa/uitest/writer_tests5/xwindow.py b/sw/qa/uitest/writer_tests5/xwindow.py index a1be89bf2981..49628776bf76 100644 --- a/sw/qa/uitest/writer_tests5/xwindow.py +++ b/sw/qa/uitest/writer_tests5/xwindow.py @@ -17,13 +17,13 @@ from com.sun.star.awt import XKeyListener mouseListenerCount = 0 -keyListenerCount = 0 +mouseEventsIntercepted = 0 mousePressedEventsIntercepted = 0 mouseReleasedEventsIntercepted = 0 mouseEnteredEventsIntercepted = 0 mouseExitedEventsIntercepted = 0 -keyPressedEventsIntercepted = 0 -keyReleasedEventsIntercepted = 0 +keymousePressedEventsIntercepted = 0 +keymouseReleasedEventsIntercepted = 0 class XMouseListenerExtended(unohelper.Base, XMouseListener): @@ -47,39 +47,37 @@ class XMouseListenerExtended(unohelper.Base, XMouseListener): # is invoked when the mouse enters a window. @classmethod def mouseEntered(self, xMouseEvent): - global mouseEnteredEventsIntercepted - mouseEnteredEventsIntercepted += 1 + global mouseEventsIntercepted + mouseEventsIntercepted += 1 + return super(XMouseListenerExtended, self).mouseEntered(xMouseEvent) # is invoked when the mouse exits a window. @classmethod def mouseExited(self, xMouseEvent): - global mouseExitedEventsIntercepted - mouseExitedEventsIntercepted += 1 + global mouseEventsIntercepted + mouseEventsIntercepted += 1 + return super(XMouseListenerExtended, self).mouseExited(xMouseEvent) 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 keyPressedEventsIntercepted - keyPressedEventsIntercepted += 1 + global keymousePressedEventsIntercepted + keymousePressedEventsIntercepted += 1 + return super(XKeyListenerExtended, self).keyPressed(xKeyEvent) # is invoked when a key has been released @classmethod def keyReleased(self, xKeyEvent): - global keyReleasedEventsIntercepted - keyReleasedEventsIntercepted += 1 + global keymouseReleasedEventsIntercepted + keymouseReleasedEventsIntercepted += 1 + return super(XKeyListenerExtended, self).keyReleased(xKeyEvent) # 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() @@ -100,7 +98,6 @@ class XWindow(UITestCase): xKeyListener = XKeyListenerExtended() self.assertIsNotNone(xKeyListener) xWindow.addKeyListener(xKeyListener) - self.assertEqual(1, keyListenerCount) # create dummy mouse event xMouseEvent = MouseEvent() @@ -121,6 +118,7 @@ class XWindow(UITestCase): xMouseEvent2.PopupTrigger = False xMouseEvent2.Source = xWindow + # send mouse event xToolkitRobot = xWindow.getToolkit() self.assertIsNotNone(xToolkitRobot) @@ -156,26 +154,23 @@ class XWindow(UITestCase): xWindow.removeKeyListener(xKeyListener) del xKeyListener - global keyPressedEventsIntercepted + global keymousePressedEventsIntercepted # Not expected any interceptions - self.assertEqual(1, keyPressedEventsIntercepted) + self.assertEqual(0, keymousePressedEventsIntercepted) - global keyReleasedEventsIntercepted + global keymouseReleasedEventsIntercepted # Not expected any interceptions - self.assertEqual(1, keyReleasedEventsIntercepted) + self.assertEqual(0, keymouseReleasedEventsIntercepted) global mousePressedEventsIntercepted - self.assertEqual(2, mousePressedEventsIntercepted) + self.assertEqual(0, mousePressedEventsIntercepted) global mouseReleasedEventsIntercepted - self.assertEqual(2, mouseReleasedEventsIntercepted) - - # Upon xMouseEvent, enter the vcl::Window with GetText() being "Standard", then upon - # xMouseEvent2, exit that vcl::Window and enter the one with get_id() being "writer_edit": - global mouseEnteredEventsIntercepted - self.assertEqual(2, mouseEnteredEventsIntercepted) - global mouseExitedEventsIntercepted - self.assertEqual(1, mouseExitedEventsIntercepted) + self.assertEqual(0, mouseReleasedEventsIntercepted) + + global mouseEventsIntercepted + # Not expected 3 interceptions + self.assertEqual(0, mouseEventsIntercepted) # close document self.ui_test.close_doc() |