tst_QWidget/XCB: Use bottom/right corner of screen as safe cursor position.

Pushing the mouse rapidly to the top left corner causes KDE / KWin to
switch to "Present all Windows" (Ctrl+F9) mode, showing all windows.
This has been observed to be triggered programmatically by
QCursor::setPos(0, 0) if there is no other window beneath and apparently
depending on the perceived mouse "speed".
Suppress this by using the bottom right corner for XCB.

Change-Id: Id18d2f45a095ed4d4f365f010cf45a20b0d9435e
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
bb10
Friedemann Kleint 2016-04-21 13:24:02 +02:00
parent d7a3b61459
commit 3a8f895d35
1 changed files with 15 additions and 7 deletions

View File

@ -470,6 +470,7 @@ private:
const QString m_platform;
QSize m_testWidgetSize;
QPoint m_availableTopLeft;
QPoint m_safeCursorPos;
const bool m_windowsAnimationsEnabled;
};
@ -627,6 +628,7 @@ void tst_QWidget::getSetCheck()
tst_QWidget::tst_QWidget()
: m_platform(QGuiApplication::platformName().toLower())
, m_safeCursorPos(0, 0)
, m_windowsAnimationsEnabled(windowsAnimationsEnabled())
{
if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild()
@ -669,7 +671,13 @@ void tst_QWidget::initTestCase()
// to avoid Windows warnings about minimum size for decorated windows.
int width = 200;
const QScreen *screen = QGuiApplication::primaryScreen();
m_availableTopLeft = screen->availableGeometry().topLeft();
const QRect availableGeometry = screen->availableGeometry();
m_availableTopLeft = availableGeometry.topLeft();
// XCB: Determine "safe" cursor position at bottom/right corner of screen.
// Pushing the mouse rapidly to the top left corner can trigger KDE / KWin's
// "Present all Windows" (Ctrl+F9) feature also programmatically.
if (m_platform == QLatin1String("xcb"))
m_safeCursorPos = availableGeometry.bottomRight() - QPoint(40, 40);
const int screenWidth = screen->geometry().width();
if (screenWidth > 2000)
width = 100 * ((screenWidth + 500) / 1000);
@ -5669,7 +5677,7 @@ void tst_QWidget::setToolTip()
// Mouse over doesn't work on Windows mobile, so skip the rest of the test for that platform.
#ifndef Q_OS_WINCE_WM
for (int pass = 0; pass < 2; ++pass) {
QCursor::setPos(0, 0);
QCursor::setPos(m_safeCursorPos);
QScopedPointer<QWidget> popup(new QWidget(0, Qt::Popup));
popup->setObjectName(QString::fromLatin1("tst_qwidget setToolTip #%1").arg(pass));
popup->setWindowTitle(popup->objectName());
@ -6020,7 +6028,7 @@ void tst_QWidget::childEvents()
// Move away the cursor; otherwise it might result in an enter event if it's
// inside the widget when the widget is shown.
QCursor::setPos(qApp->desktop()->availableGeometry().bottomRight());
QCursor::setPos(m_safeCursorPos);
QTest::qWait(100);
{
@ -8883,7 +8891,7 @@ void tst_QWidget::syntheticEnterLeave()
int numLeaveEvents;
};
QCursor::setPos(QPoint(0,0));
QCursor::setPos(m_safeCursorPos);
MyWidget window;
window.setWindowFlags(Qt::WindowStaysOnTopHint);
@ -9003,7 +9011,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
int numEnterEvents, numMouseMoveEvents;
};
QCursor::setPos(QPoint(0,0));
QCursor::setPos(m_safeCursorPos);
SELParent parent;
parent.move(200, 200);
@ -10179,7 +10187,7 @@ void tst_QWidget::destroyedSignal()
void tst_QWidget::underMouse()
{
// Move the mouse cursor to a safe location
QCursor::setPos(0,0);
QCursor::setPos(m_safeCursorPos);
ColorWidget topLevelWidget(0, Qt::FramelessWindowHint, Qt::blue);
ColorWidget childWidget1(&topLevelWidget, Qt::Widget, Qt::yellow);
@ -10435,7 +10443,7 @@ public:
void tst_QWidget::taskQTBUG_27643_enterEvents()
{
// Move the mouse cursor to a safe location so it won't interfere
QCursor::setPos(0,0);
QCursor::setPos(m_safeCursorPos);
EnterTestMainDialog dialog;
QPushButton button(&dialog);