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>
This commit is contained in:
@@ -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
|
||||
|
@@ -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()
|
||||
|
@@ -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...
|
||||
|
Reference in New Issue
Block a user