QQuickDrawer: fix multi-touch leaking through modal overlay
The first touch point was blocked as appropriate, but the consequent touch points were leaking through to other popups below Drawers' modal overlay. Task-number: QTBUG-61581 Change-Id: I1c3e28e3d25b7489c4a9b684107fd1b5158e1674 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
parent
7a09033636
commit
e841c0a252
|
@ -347,10 +347,10 @@ bool QQuickDrawerPrivate::grabMouse(QQuickItem *item, QMouseEvent *event)
|
|||
bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event)
|
||||
{
|
||||
Q_Q(QQuickDrawer);
|
||||
handleTouchEvent(item, event);
|
||||
bool handled = handleTouchEvent(item, event);
|
||||
|
||||
if (!window || !interactive || popupItem->keepTouchGrab() || !event->touchPointStates().testFlag(Qt::TouchPointMoved))
|
||||
return false;
|
||||
return handled;
|
||||
|
||||
bool overThreshold = false;
|
||||
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
|
||||
|
|
|
@ -383,8 +383,8 @@ bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event)
|
|||
case QEvent::TouchUpdate:
|
||||
case QEvent::TouchEnd:
|
||||
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
|
||||
if (!acceptTouch(point) && !blockInput(item, point.pos()))
|
||||
continue;
|
||||
if (!acceptTouch(point))
|
||||
return blockInput(item, point.pos());
|
||||
|
||||
switch (point.state()) {
|
||||
case Qt::TouchPointPressed:
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Controls 2.0
|
||||
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
width: 400
|
||||
height: 400
|
||||
|
||||
property alias drawer: drawer
|
||||
property alias popup: popup
|
||||
property alias button: button
|
||||
|
||||
Drawer {
|
||||
id: drawer
|
||||
width: window.width / 2
|
||||
height: parent.height
|
||||
dragMargin: parent.width
|
||||
}
|
||||
|
||||
Popup {
|
||||
id: popup
|
||||
x: 10; y: 10
|
||||
width: window.width - 10
|
||||
height: window.height - 10
|
||||
|
||||
Button {
|
||||
id: button
|
||||
text: "Button"
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,6 +86,8 @@ private slots:
|
|||
void touch_data();
|
||||
void touch();
|
||||
|
||||
void multiTouch();
|
||||
|
||||
void grabber();
|
||||
|
||||
void interactive_data();
|
||||
|
@ -813,6 +815,119 @@ void tst_Drawer::touch()
|
|||
QCOMPARE(drawer->position(), 0.0);
|
||||
}
|
||||
|
||||
void tst_Drawer::multiTouch()
|
||||
{
|
||||
QQuickApplicationHelper helper(this, QStringLiteral("multiTouch.qml"));
|
||||
QQuickWindow *window = helper.window;
|
||||
window->show();
|
||||
QVERIFY(QTest::qWaitForWindowActive(window));
|
||||
|
||||
QQuickOverlay *overlay = QQuickOverlay::overlay(window);
|
||||
QVERIFY(overlay);
|
||||
|
||||
QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>();
|
||||
QVERIFY(drawer);
|
||||
|
||||
QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
|
||||
QVERIFY(popup);
|
||||
|
||||
QQuickButton *button = window->property("button").value<QQuickButton *>();
|
||||
QVERIFY(button);
|
||||
|
||||
QSignalSpy overlayPressedSpy(overlay, SIGNAL(pressed()));
|
||||
QSignalSpy overlayReleasedSpy(overlay, SIGNAL(released()));
|
||||
QVERIFY(overlayPressedSpy.isValid());
|
||||
QVERIFY(overlayReleasedSpy.isValid());
|
||||
|
||||
QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened()));
|
||||
QVERIFY(drawerOpenedSpy.isValid());
|
||||
|
||||
QSignalSpy buttonPressedSpy(button, SIGNAL(pressed()));
|
||||
QSignalSpy buttonReleasedSpy(button, SIGNAL(released()));
|
||||
QVERIFY(buttonPressedSpy.isValid());
|
||||
QVERIFY(buttonReleasedSpy.isValid());
|
||||
|
||||
popup->open();
|
||||
QVERIFY(popup->isVisible());
|
||||
|
||||
drawer->open();
|
||||
QVERIFY(drawer->isVisible());
|
||||
QVERIFY(drawerOpenedSpy.wait());
|
||||
|
||||
// 1st press
|
||||
QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100));
|
||||
QVERIFY(popup->isVisible());
|
||||
QVERIFY(drawer->isVisible());
|
||||
QCOMPARE(buttonPressedSpy.count(), 0);
|
||||
QCOMPARE(overlayPressedSpy.count(), 1);
|
||||
|
||||
// 2nd press (blocked & ignored)
|
||||
QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200));
|
||||
QVERIFY(popup->isVisible());
|
||||
QVERIFY(drawer->isVisible());
|
||||
QCOMPARE(buttonPressedSpy.count(), 0);
|
||||
QCOMPARE(overlayPressedSpy.count(), 2);
|
||||
|
||||
// 2nd release (blocked & ignored)
|
||||
QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 200));
|
||||
QVERIFY(popup->isVisible());
|
||||
QVERIFY(drawer->isVisible());
|
||||
QCOMPARE(buttonPressedSpy.count(), 0);
|
||||
QCOMPARE(buttonReleasedSpy.count(), 0);
|
||||
QCOMPARE(overlayPressedSpy.count(), 2);
|
||||
QCOMPARE(overlayReleasedSpy.count(), 1);
|
||||
|
||||
// 1st release
|
||||
QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100));
|
||||
QVERIFY(popup->isVisible());
|
||||
QTRY_VERIFY(!drawer->isVisible());
|
||||
QCOMPARE(buttonPressedSpy.count(), 0);
|
||||
QCOMPARE(buttonReleasedSpy.count(), 0);
|
||||
QCOMPARE(overlayPressedSpy.count(), 2);
|
||||
QCOMPARE(overlayReleasedSpy.count(), 2);
|
||||
|
||||
drawer->open();
|
||||
QVERIFY(drawer->isVisible());
|
||||
QVERIFY(drawerOpenedSpy.wait());
|
||||
|
||||
// 1st drag
|
||||
QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100));
|
||||
QCOMPARE(buttonPressedSpy.count(), 0);
|
||||
QCOMPARE(overlayPressedSpy.count(), 3);
|
||||
for (int x = 300; x >= 100; x -= 10) {
|
||||
QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, 100));
|
||||
QVERIFY(popup->isVisible());
|
||||
QVERIFY(drawer->isVisible());
|
||||
}
|
||||
QCOMPARE(drawer->position(), 0.5);
|
||||
|
||||
// 2nd drag (blocked & ignored)
|
||||
QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200));
|
||||
QCOMPARE(buttonPressedSpy.count(), 0);
|
||||
QCOMPARE(overlayPressedSpy.count(), 4);
|
||||
for (int x = 300; x >= 0; x -= 10) {
|
||||
QTest::touchEvent(window, touchDevice.data()).stationary(0).move(1, QPoint(x, 200));
|
||||
QVERIFY(popup->isVisible());
|
||||
QVERIFY(drawer->isVisible());
|
||||
}
|
||||
QCOMPARE(drawer->position(), 0.5);
|
||||
|
||||
// 2nd release (blocked & ignored)
|
||||
QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 0));
|
||||
QVERIFY(popup->isVisible());
|
||||
QVERIFY(drawer->isVisible());
|
||||
QCOMPARE(drawer->position(), 0.5);
|
||||
QCOMPARE(buttonReleasedSpy.count(), 0);
|
||||
QCOMPARE(overlayReleasedSpy.count(), 3);
|
||||
|
||||
// 1st release
|
||||
QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100));
|
||||
QVERIFY(popup->isVisible());
|
||||
QTRY_VERIFY(!drawer->isVisible());
|
||||
QCOMPARE(buttonReleasedSpy.count(), 0);
|
||||
QCOMPARE(overlayReleasedSpy.count(), 4);
|
||||
}
|
||||
|
||||
void tst_Drawer::grabber()
|
||||
{
|
||||
QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml"));
|
||||
|
|
Loading…
Reference in New Issue