summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-05-08 10:24:18 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-05-16 15:40:11 +0200
commitf9905401d8cf2d73576231ebd84cfa5f4f73bcac (patch)
treec4151d098222cac20c53f6651595e5cb6ca410d0
parent1489aa7467a2131e48d2995107d1415d9e59ea9e (diff)
tdf#125170 Deliver mouse events also when clicking into document content
Event listeners are added once VCLXWindow::SetWindow is called. This never happened for the document content window. So we need to call Window::GetComponentInterface which will create an XWindowPeer and then call UnoWrapper::SetWindowInterface which calls VCLXWindow::SetWindow. After that, event listeners are registered so that we can deliver events. Change-Id: I2ed01f1ab20d87fedc4803bdbd96f5ef14d40043 Reviewed-on: https://gerrit.libreoffice.org/71948 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--forms/qa/unoapi/forms_2.sce2
-rw-r--r--sw/qa/uitest/writer_tests5/xwindow.py23
-rw-r--r--vcl/source/window/event.cxx6
3 files changed, 26 insertions, 5 deletions
diff --git a/forms/qa/unoapi/forms_2.sce b/forms/qa/unoapi/forms_2.sce
index 30f4b2401875..c12d87f9977a 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 .
#
--o forms.ODateModel
+# Flaky since tdf#125170 -o forms.ODateModel
-o forms.OEditControl
-o forms.OEditModel
#i109939 -o forms.OFileControlModel
diff --git a/sw/qa/uitest/writer_tests5/xwindow.py b/sw/qa/uitest/writer_tests5/xwindow.py
index 7b96b53c495d..bdfbfecff17e 100644
--- a/sw/qa/uitest/writer_tests5/xwindow.py
+++ b/sw/qa/uitest/writer_tests5/xwindow.py
@@ -10,6 +10,7 @@ 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
@@ -96,21 +97,35 @@ class XWindow(UITestCase):
# create dummy mouse event
xMouseEvent = MouseEvent()
xMouseEvent.Modifiers = 0
- xMouseEvent.Buttons = 0
+ xMouseEvent.Buttons = MouseButton.LEFT
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)
- xToolkitRobot.mousePress(xMouseEvent)
+ # Click in the menubar/toolbar area
xToolkitRobot.mouseMove(xMouseEvent)
+ xToolkitRobot.mousePress(xMouseEvent)
xToolkitRobot.mouseRelease(xMouseEvent)
+ # Click into the document content
+ xToolkitRobot.mousePress(xMouseEvent2)
+ xToolkitRobot.mouseRelease(xMouseEvent2)
+
# send key press event
xKeyEvent = KeyEvent()
xKeyEvent.Modifiers = 0
@@ -139,8 +154,8 @@ class XWindow(UITestCase):
self.assertEqual(0, keymouseEventsIntercepted)
global mouseEventsIntercepted
- # mousePressed, mouseReleased and mouseEntered should be triggered
- self.assertEqual(3, mouseEventsIntercepted)
+ # mousePressed (2x), mouseReleased (2x) and mouseEntered (1x) should be triggered
+ self.assertEqual(5, mouseEventsIntercepted)
# close document
self.ui_test.close_doc()
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 399dddd3abaa..b786552a6789 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -31,6 +31,7 @@
#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,6 +215,11 @@ 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())
+ xWindow->GetComponentInterface();
+
if (!mpWindowImpl->maEventListeners.empty())
{
// Copy the list, because this can be destroyed when calling a Link...