[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - 2 commits - forms/qa sw/qa toolkit/source vcl/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 13 07:02:15 UTC 2019
forms/qa/unoapi/forms_2.sce | 2
sw/qa/uitest/writer_tests/xwindow.py | 108 +++++++++++---------------------
toolkit/source/awt/vclxwindow.cxx | 117 ++++++++++++++---------------------
vcl/source/window/event.cxx | 6 -
4 files changed, 88 insertions(+), 145 deletions(-)
New commits:
commit 4a63cc1b639e5922425bfc6f82e84ddeaeb2bd0a
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Nov 12 12:11:46 2019 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Wed Nov 13 08:01:43 2019 +0100
Revert "tdf#122920 Send UNO mouse events to parent window listeners as well"
This reverts commit a2fcf51a77f4a37fb1c14f47bab450eea79a0dcb.
Change-Id: I427414a8814d055d5cd3c05dc094f4a8b5f17aec
Reviewed-on: https://gerrit.libreoffice.org/82505
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_tests/xwindow.py b/sw/qa/uitest/writer_tests/xwindow.py
index 428dd3723a05..d63df73c69ea 100644
--- a/sw/qa/uitest/writer_tests/xwindow.py
+++ b/sw/qa/uitest/writer_tests/xwindow.py
@@ -43,13 +43,15 @@ class XMouseListenerExtended(unohelper.Base, XMouseListener):
# is invoked when the mouse enters a window.
@classmethod
def mouseEntered(self, xMouseEvent):
- # doesn't work in UI tests
+ global mouseEventsIntercepted
+ mouseEventsIntercepted += 1
return super(XMouseListenerExtended, self).mouseEntered(xMouseEvent)
# is invoked when the mouse exits a window.
@classmethod
def mouseExited(self, xMouseEvent):
- # doesn't work in UI tests
+ global mouseEventsIntercepted
+ mouseEventsIntercepted += 1
return super(XMouseListenerExtended, self).mouseExited(xMouseEvent)
@@ -140,8 +142,8 @@ class XWindow(UITestCase):
self.assertEqual(0, keymouseEventsIntercepted)
global mouseEventsIntercepted
- # mousePressed, mouseReleased and mouseEntered should be triggered
- self.assertEqual(2, mouseEventsIntercepted)
+ # Not expected 3 interceptions
+ self.assertEqual(0, mouseEventsIntercepted)
# close document
self.ui_test.close_doc()
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index 31438dfec9e2..6d89c13f3697 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -704,66 +704,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;
commit e8aa0913baa7290f9d62843e2f46148ea3207246
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Nov 12 12:11:10 2019 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Wed Nov 13 08:01:37 2019 +0100
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 at cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
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...
More information about the Libreoffice-commits
mailing list