summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-12 12:11:10 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-11-13 08:01:37 +0100
commite8aa0913baa7290f9d62843e2f46148ea3207246 (patch)
tree5c33c748ed511f7bbbec6262e119c458d1e29df2
parentac31e4443056bd09761cb9d57a87f0131adb4a84 (diff)
Revert "tdf#122920 Send UNO mouse/key events to parent window listeners as well"
This reverts commit 3b137aaaa1232f0f22730898fcfd1112f68af1bf. Change-Id: If4152d1992baa82cebbabff5b0f4567a7942d350 Reviewed-on: https://gerrit.libreoffice.org/82504 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--forms/qa/unoapi/forms_2.sce2
-rw-r--r--sw/qa/uitest/writer_tests/xwindow.py106
-rw-r--r--toolkit/source/awt/vclxwindow.cxx33
-rw-r--r--vcl/source/window/event.cxx6
4 files changed, 52 insertions, 95 deletions
diff --git a/forms/qa/unoapi/forms_2.sce b/forms/qa/unoapi/forms_2.sce
index c12d87f9977a..30f4b2401875 100644
--- a/forms/qa/unoapi/forms_2.sce
+++ b/forms/qa/unoapi/forms_2.sce
@@ -15,7 +15,7 @@
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-# Flaky since tdf#125170 -o forms.ODateModel
+-o forms.ODateModel
-o forms.OEditControl
-o forms.OEditModel
#i109939 -o forms.OFileControlModel
diff --git a/sw/qa/uitest/writer_tests/xwindow.py b/sw/qa/uitest/writer_tests/xwindow.py
index a1be89bf2981..428dd3723a05 100644
--- a/sw/qa/uitest/writer_tests/xwindow.py
+++ b/sw/qa/uitest/writer_tests/xwindow.py
@@ -10,20 +10,14 @@ import unohelper
from org.libreoffice.unotest import UnoInProcess
from com.sun.star.awt import XMouseListener
from com.sun.star.awt import XToolkitRobot
-from com.sun.star.awt import MouseButton
from com.sun.star.awt import MouseEvent
from com.sun.star.awt import KeyEvent
from com.sun.star.awt import XKeyListener
mouseListenerCount = 0
-keyListenerCount = 0
-mousePressedEventsIntercepted = 0
-mouseReleasedEventsIntercepted = 0
-mouseEnteredEventsIntercepted = 0
-mouseExitedEventsIntercepted = 0
-keyPressedEventsIntercepted = 0
-keyReleasedEventsIntercepted = 0
+mouseEventsIntercepted = 0
+keymouseEventsIntercepted = 0
class XMouseListenerExtended(unohelper.Base, XMouseListener):
@@ -35,54 +29,57 @@ class XMouseListenerExtended(unohelper.Base, XMouseListener):
# is invoked when a mouse button has been pressed on a window.
@classmethod
def mousePressed(self, xMouseEvent):
- global mousePressedEventsIntercepted
- mousePressedEventsIntercepted += 1
+ global mouseEventsIntercepted
+ mouseEventsIntercepted += 1
+ return super(XMouseListenerExtended, self).mousePressed(xMouseEvent)
# is invoked when a mouse button has been released on a window.
@classmethod
def mouseReleased(self, xMouseEvent):
- global mouseReleasedEventsIntercepted
- mouseReleasedEventsIntercepted += 1
+ global mouseEventsIntercepted
+ mouseEventsIntercepted += 1
+ return super(XMouseListenerExtended, self).mouseReleased(xMouseEvent)
# is invoked when the mouse enters a window.
@classmethod
def mouseEntered(self, xMouseEvent):
- global mouseEnteredEventsIntercepted
- mouseEnteredEventsIntercepted += 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 mouseExitedEventsIntercepted
- mouseExitedEventsIntercepted += 1
+ # doesn't work in UI tests
+ 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 keymouseEventsIntercepted
+ keymouseEventsIntercepted += 1
+ return super(XKeyListenerExtended, self).keyPressed(xKeyEvent)
# is invoked when a key has been released
@classmethod
def keyReleased(self, xKeyEvent):
- global keyReleasedEventsIntercepted
- keyReleasedEventsIntercepted += 1
-
-# Test that registered mouse/key listeners for top window receive mouse/key events
+ global keymouseEventsIntercepted
+ keymouseEventsIntercepted += 1
+ return super(XKeyListenerExtended, self).keyReleased(xKeyEvent)
+
+# registered mouse/key listeners for top window
+# do not receive any mouse/key events while
+# everything is passed only to focused child window
+# where we have no any registered mouse/key listeners
class XWindow(UITestCase):
def test_listeners(self):
global mouseListenerCount
- global keyListenerCount
- self.ui_test.create_doc_in_start_center("writer")
+ writer_doc = self.ui_test.create_doc_in_start_center("writer")
xDoc = self.ui_test.get_component()
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
# create new mouse listener
xFrame = xDoc.getCurrentController().getFrame()
@@ -100,39 +97,25 @@ class XWindow(UITestCase):
xKeyListener = XKeyListenerExtended()
self.assertIsNotNone(xKeyListener)
xWindow.addKeyListener(xKeyListener)
- self.assertEqual(1, keyListenerCount)
# create dummy mouse event
xMouseEvent = MouseEvent()
xMouseEvent.Modifiers = 0
- xMouseEvent.Buttons = MouseButton.LEFT
+ xMouseEvent.Buttons = 0
xMouseEvent.X = 10
xMouseEvent.Y = 10
xMouseEvent.ClickCount = 1
xMouseEvent.PopupTrigger = False
xMouseEvent.Source = xWindow
- xMouseEvent2 = MouseEvent()
- xMouseEvent2.Modifiers = 0
- xMouseEvent2.Buttons = MouseButton.LEFT
- xMouseEvent2.X = 300
- xMouseEvent2.Y = 300
- xMouseEvent2.ClickCount = 1
- xMouseEvent2.PopupTrigger = False
- xMouseEvent2.Source = xWindow
-
+ # send mouse event
xToolkitRobot = xWindow.getToolkit()
self.assertIsNotNone(xToolkitRobot)
- # Click in the menubar/toolbar area
- xToolkitRobot.mouseMove(xMouseEvent)
xToolkitRobot.mousePress(xMouseEvent)
+ xToolkitRobot.mouseMove(xMouseEvent)
xToolkitRobot.mouseRelease(xMouseEvent)
- # Click into the document content
- xToolkitRobot.mousePress(xMouseEvent2)
- xToolkitRobot.mouseRelease(xMouseEvent2)
-
# send key press event
xKeyEvent = KeyEvent()
xKeyEvent.Modifiers = 0
@@ -143,11 +126,7 @@ class XWindow(UITestCase):
xToolkitRobot.keyPress(xKeyEvent)
xToolkitRobot.keyRelease(xKeyEvent)
- # Wait for async events to be processed
- xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
- xToolkit.processEventsToIdle()
-
- # remove mouse listener
+ # remove moue listener
xWindow.removeMouseListener(xMouseListener)
self.assertEqual(1, mouseListenerCount)
del xMouseListener
@@ -156,26 +135,13 @@ class XWindow(UITestCase):
xWindow.removeKeyListener(xKeyListener)
del xKeyListener
- global keyPressedEventsIntercepted
- # Not expected any interceptions
- self.assertEqual(1, keyPressedEventsIntercepted)
-
- global keyReleasedEventsIntercepted
- # Not expected any interceptions
- self.assertEqual(1, keyReleasedEventsIntercepted)
-
- global mousePressedEventsIntercepted
- self.assertEqual(2, mousePressedEventsIntercepted)
-
- global mouseReleasedEventsIntercepted
- self.assertEqual(2, mouseReleasedEventsIntercepted)
+ global keymouseEventsIntercepted
+ # Not expected 2 interceptions
+ self.assertEqual(0, keymouseEventsIntercepted)
- # 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)
+ global 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 dc4cbe2d7309..31438dfec9e2 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -654,27 +654,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;
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 6f092ce3729a..d03d3d3c9540 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -30,7 +30,6 @@
#include <com/sun/star/awt/MouseEvent.hpp>
#include <com/sun/star/awt/KeyModifier.hpp>
#include <com/sun/star/awt/MouseButton.hpp>
-#include <com/sun/star/awt/XWindow.hpp>
#include <comphelper/scopeguard.hxx>
namespace vcl {
@@ -214,11 +213,6 @@ void Window::CallEventListeners( VclEventId nEvent, void* pData )
if ( xWindow->IsDisposed() )
return;
- // If maEventListeners is empty, the XVCLWindow has not yet been initialized.
- // Calling GetComponentInterface will do that.
- if (mpWindowImpl->maEventListeners.empty() && pData)
- xWindow->GetComponentInterface();
-
if (!mpWindowImpl->maEventListeners.empty())
{
// Copy the list, because this can be destroyed when calling a Link...