2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-02-05 14:39:04 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/output.h"
|
2023-11-17 08:59:08 +00:00
|
|
|
#include "effect/effects.h"
|
2022-04-22 17:45:19 +00:00
|
|
|
#include "internalwindow.h"
|
2023-02-09 13:07:56 +00:00
|
|
|
#include "pointer_input.h"
|
2023-09-13 05:52:59 +00:00
|
|
|
#include "wayland/surface.h"
|
2016-02-05 14:39:04 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QRasterWindow>
|
2023-07-03 19:28:19 +00:00
|
|
|
#include <QSignalSpy>
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2016-08-11 09:17:09 +00:00
|
|
|
#include <KWayland/Client/keyboard.h>
|
|
|
|
#include <KWayland/Client/seat.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <KWayland/Client/surface.h>
|
2019-01-13 16:50:32 +00:00
|
|
|
#include <KWindowSystem>
|
2016-08-11 09:17:09 +00:00
|
|
|
|
2016-02-05 14:39:04 +00:00
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_internal_window-0");
|
|
|
|
|
|
|
|
class InternalWindowTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
2016-08-11 09:17:09 +00:00
|
|
|
void cleanup();
|
2016-02-05 14:39:04 +00:00
|
|
|
void testEnterLeave();
|
|
|
|
void testPointerPressRelease();
|
|
|
|
void testPointerAxis();
|
2016-02-17 12:34:24 +00:00
|
|
|
void testKeyboard_data();
|
2016-02-08 14:03:21 +00:00
|
|
|
void testKeyboard();
|
2016-08-29 13:34:02 +00:00
|
|
|
void testKeyboardShowWithoutActivating();
|
2016-08-16 13:39:47 +00:00
|
|
|
void testKeyboardTriggersLeave();
|
2016-05-23 15:07:08 +00:00
|
|
|
void testTouch();
|
2017-01-03 06:28:29 +00:00
|
|
|
void testOpacity();
|
2017-01-04 16:53:46 +00:00
|
|
|
void testMove();
|
2017-01-11 19:00:40 +00:00
|
|
|
void testSkipCloseAnimation_data();
|
|
|
|
void testSkipCloseAnimation();
|
2018-02-11 09:49:31 +00:00
|
|
|
void testModifierClickUnrestrictedMove();
|
|
|
|
void testModifierScroll();
|
2019-01-05 10:10:33 +00:00
|
|
|
void testPopup();
|
2019-01-11 22:48:04 +00:00
|
|
|
void testScale();
|
2019-01-13 16:50:32 +00:00
|
|
|
void testEffectWindow();
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
void testReentrantMoveResize();
|
2021-01-30 20:29:55 +00:00
|
|
|
void testDismissPopup();
|
2016-02-05 14:39:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class HelperWindow : public QRasterWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
HelperWindow();
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~HelperWindow() override;
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QPoint latestGlobalMousePos() const
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
return m_latestGlobalMousePos;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
Qt::MouseButtons pressedButtons() const
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
return m_pressedButtons;
|
|
|
|
}
|
|
|
|
|
2016-02-05 14:39:04 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void entered();
|
|
|
|
void left();
|
|
|
|
void mouseMoved(const QPoint &global);
|
|
|
|
void mousePressed();
|
|
|
|
void mouseReleased();
|
|
|
|
void wheel();
|
2016-02-08 14:03:21 +00:00
|
|
|
void keyPressed();
|
|
|
|
void keyReleased();
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
bool event(QEvent *event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
|
|
void wheelEvent(QWheelEvent *event) override;
|
2016-02-08 14:03:21 +00:00
|
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
void keyReleaseEvent(QKeyEvent *event) override;
|
2016-05-23 15:07:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QPoint m_latestGlobalMousePos;
|
|
|
|
Qt::MouseButtons m_pressedButtons = Qt::MouseButtons();
|
2016-02-05 14:39:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
HelperWindow::HelperWindow()
|
|
|
|
: QRasterWindow(nullptr)
|
|
|
|
{
|
2016-05-09 12:48:10 +00:00
|
|
|
setFlags(Qt::FramelessWindowHint);
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HelperWindow::~HelperWindow() = default;
|
|
|
|
|
|
|
|
void HelperWindow::paintEvent(QPaintEvent *event)
|
|
|
|
{
|
|
|
|
QPainter p(this);
|
|
|
|
p.fillRect(0, 0, width(), height(), Qt::red);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HelperWindow::event(QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::Enter) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT entered();
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
if (event->type() == QEvent::Leave) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT left();
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
return QRasterWindow::event(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
m_latestGlobalMousePos = event->globalPos();
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT mouseMoved(event->globalPos());
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
m_latestGlobalMousePos = event->globalPos();
|
|
|
|
m_pressedButtons = event->buttons();
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT mousePressed();
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::mouseReleaseEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
m_latestGlobalMousePos = event->globalPos();
|
|
|
|
m_pressedButtons = event->buttons();
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT mouseReleased();
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::wheelEvent(QWheelEvent *event)
|
|
|
|
{
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT wheel();
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 14:03:21 +00:00
|
|
|
void HelperWindow::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT keyPressed();
|
2016-02-08 14:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::keyReleaseEvent(QKeyEvent *event)
|
|
|
|
{
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT keyReleased();
|
2016-02-08 14:03:21 +00:00
|
|
|
}
|
|
|
|
|
2016-02-05 14:39:04 +00:00
|
|
|
void InternalWindowTest::initTestCase()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2022-04-22 17:45:19 +00:00
|
|
|
qRegisterMetaType<KWin::InternalWindow *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig({
|
|
|
|
QRect(0, 0, 1280, 1024),
|
|
|
|
QRect(1280, 0, 1280, 1024),
|
|
|
|
});
|
2018-02-11 09:49:31 +00:00
|
|
|
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2022-07-11 10:41:15 +00:00
|
|
|
const auto outputs = workspace()->outputs();
|
2021-08-31 07:03:05 +00:00
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::init()
|
|
|
|
{
|
2023-02-09 13:07:56 +00:00
|
|
|
input()->pointer()->warp(QPoint(512, 512));
|
2016-12-03 13:31:14 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
|
2016-08-11 09:17:09 +00:00
|
|
|
QVERIFY(Test::waitForWaylandKeyboard());
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testEnterLeave()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-02-05 14:39:04 +00:00
|
|
|
HelperWindow win;
|
2019-08-26 07:44:04 +00:00
|
|
|
QVERIFY(!workspace()->findInternal(nullptr));
|
|
|
|
QVERIFY(!workspace()->findInternal(&win));
|
2016-02-05 14:39:04 +00:00
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
|
|
|
QVERIFY(!workspace()->activeWindow());
|
2022-04-23 19:51:16 +00:00
|
|
|
InternalWindow *window = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QVERIFY(window->isInternal());
|
|
|
|
QVERIFY(!window->isDecorated());
|
|
|
|
QCOMPARE(workspace()->findInternal(&win), window);
|
|
|
|
QCOMPARE(window->frameGeometry(), QRect(0, 0, 100, 100));
|
|
|
|
QVERIFY(window->isShown());
|
|
|
|
QVERIFY(workspace()->stackingOrder().contains(window));
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
QSignalSpy enterSpy(&win, &HelperWindow::entered);
|
|
|
|
QSignalSpy leaveSpy(&win, &HelperWindow::left);
|
|
|
|
QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved);
|
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(QPoint(50, 50), timestamp++);
|
2018-09-15 00:00:24 +00:00
|
|
|
QTRY_COMPARE(moveSpy.count(), 1);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(QPoint(60, 50), timestamp++);
|
2018-09-15 00:00:24 +00:00
|
|
|
QTRY_COMPARE(moveSpy.count(), 2);
|
|
|
|
QCOMPARE(moveSpy[1].first().toPoint(), QPoint(60, 50));
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(QPoint(101, 50), timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(leaveSpy.count(), 1);
|
2016-04-29 13:08:22 +00:00
|
|
|
|
|
|
|
// set a mask on the window
|
|
|
|
win.setMask(QRegion(10, 20, 30, 40));
|
|
|
|
// outside the mask we should not get an enter
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(QPoint(5, 5), timestamp++);
|
2016-04-29 13:08:22 +00:00
|
|
|
QVERIFY(!enterSpy.wait(100));
|
|
|
|
QCOMPARE(enterSpy.count(), 1);
|
|
|
|
// inside the mask we should still get an enter
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(QPoint(25, 27), timestamp++);
|
2016-04-29 13:08:22 +00:00
|
|
|
QTRY_COMPARE(enterSpy.count(), 2);
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testPointerPressRelease()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-02-05 14:39:04 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::mousePressed);
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased);
|
|
|
|
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(QPoint(50, 50), timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(pressSpy.count(), 1);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(releaseSpy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testPointerAxis()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-02-05 14:39:04 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy wheelSpy(&win, &HelperWindow::wheel);
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(QPoint(50, 50), timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerAxisVertical(5.0, timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(wheelSpy.count(), 1);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerAxisHorizontal(5.0, timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(wheelSpy.count(), 2);
|
|
|
|
}
|
|
|
|
|
2016-02-17 12:34:24 +00:00
|
|
|
void InternalWindowTest::testKeyboard_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QPoint>("cursorPos");
|
|
|
|
|
|
|
|
QTest::newRow("on Window") << QPoint(50, 50);
|
|
|
|
QTest::newRow("outside Window") << QPoint(250, 250);
|
|
|
|
}
|
|
|
|
|
2016-02-08 14:03:21 +00:00
|
|
|
void InternalWindowTest::testKeyboard()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-02-08 14:03:21 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QVERIFY(internalWindow->isInternal());
|
|
|
|
QVERIFY(internalWindow->readyForPainting());
|
2016-02-08 14:03:21 +00:00
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2016-02-17 12:34:24 +00:00
|
|
|
QFETCH(QPoint, cursorPos);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(cursorPos, timestamp++);
|
2016-02-08 14:03:21 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyPressed(KEY_A, timestamp++);
|
2016-02-08 14:03:21 +00:00
|
|
|
QTRY_COMPARE(pressSpy.count(), 1);
|
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyReleased(KEY_A, timestamp++);
|
2016-02-08 14:03:21 +00:00
|
|
|
QTRY_COMPARE(releaseSpy.count(), 1);
|
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
2016-08-16 13:39:47 +00:00
|
|
|
}
|
2016-08-11 09:17:09 +00:00
|
|
|
|
2016-08-29 13:34:02 +00:00
|
|
|
void InternalWindowTest::testKeyboardShowWithoutActivating()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-08-29 13:34:02 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setProperty("_q_showWithoutActivating", true);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QVERIFY(internalWindow->isInternal());
|
|
|
|
QVERIFY(internalWindow->readyForPainting());
|
2016-08-29 13:34:02 +00:00
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
|
|
|
const QPoint cursorPos = QPoint(50, 50);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(cursorPos, timestamp++);
|
2016-08-29 13:34:02 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyPressed(KEY_A, timestamp++);
|
2016-08-29 13:34:02 +00:00
|
|
|
QCOMPARE(pressSpy.count(), 0);
|
|
|
|
QVERIFY(!pressSpy.wait(100));
|
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyReleased(KEY_A, timestamp++);
|
2016-08-29 13:34:02 +00:00
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
|
|
|
QVERIFY(!releaseSpy.wait(100));
|
|
|
|
QCOMPARE(pressSpy.count(), 0);
|
|
|
|
}
|
|
|
|
|
2016-08-16 13:39:47 +00:00
|
|
|
void InternalWindowTest::testKeyboardTriggersLeave()
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
// this test verifies that a leave event is sent to a window when an internal window
|
2016-08-16 13:39:47 +00:00
|
|
|
// gets a key event
|
2022-11-07 21:33:00 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Keyboard> keyboard(Test::waylandSeat()->createKeyboard());
|
2022-08-01 21:29:02 +00:00
|
|
|
QVERIFY(keyboard != nullptr);
|
2016-08-11 09:17:09 +00:00
|
|
|
QVERIFY(keyboard->isValid());
|
2022-11-07 21:33:00 +00:00
|
|
|
QSignalSpy enteredSpy(keyboard.get(), &KWayland::Client::Keyboard::entered);
|
|
|
|
QSignalSpy leftSpy(keyboard.get(), &KWayland::Client::Keyboard::left);
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
2016-08-11 09:17:09 +00:00
|
|
|
|
|
|
|
// now let's render
|
2022-08-01 21:29:02 +00:00
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(window);
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
QVERIFY(!window->isInternal());
|
2016-08-11 09:17:09 +00:00
|
|
|
|
|
|
|
if (enteredSpy.isEmpty()) {
|
|
|
|
QVERIFY(enteredSpy.wait());
|
|
|
|
}
|
|
|
|
QCOMPARE(enteredSpy.count(), 1);
|
|
|
|
|
2016-08-16 13:39:47 +00:00
|
|
|
// create internal window
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-08-16 13:39:47 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
2016-08-11 09:17:09 +00:00
|
|
|
win.show();
|
2016-08-16 13:39:47 +00:00
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QVERIFY(internalWindow->isInternal());
|
|
|
|
QVERIFY(internalWindow->readyForPainting());
|
2016-08-16 13:39:47 +00:00
|
|
|
|
2016-08-11 09:17:09 +00:00
|
|
|
QVERIFY(leftSpy.isEmpty());
|
|
|
|
QVERIFY(!leftSpy.wait(100));
|
|
|
|
|
|
|
|
// now let's trigger a key, which should result in a leave
|
2016-08-16 13:39:47 +00:00
|
|
|
quint32 timestamp = 1;
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyPressed(KEY_A, timestamp++);
|
2016-08-11 09:17:09 +00:00
|
|
|
QVERIFY(leftSpy.wait());
|
2016-08-16 13:39:47 +00:00
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
2016-08-11 09:17:09 +00:00
|
|
|
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyReleased(KEY_A, timestamp++);
|
2016-08-16 13:39:47 +00:00
|
|
|
QTRY_COMPARE(releaseSpy.count(), 1);
|
2016-08-11 09:17:09 +00:00
|
|
|
|
|
|
|
// after hiding the internal window, next key press should trigger an enter
|
|
|
|
win.hide();
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyPressed(KEY_A, timestamp++);
|
2016-08-11 09:17:09 +00:00
|
|
|
QVERIFY(enteredSpy.wait());
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyReleased(KEY_A, timestamp++);
|
2019-09-23 19:57:50 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy the test window.
|
2019-09-23 19:57:50 +00:00
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2016-02-08 14:03:21 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 15:07:08 +00:00
|
|
|
void InternalWindowTest::testTouch()
|
|
|
|
{
|
|
|
|
// touch events for internal windows are emulated through mouse events
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-05-23 15:07:08 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2016-05-23 15:07:08 +00:00
|
|
|
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::mousePressed);
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased);
|
|
|
|
QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved);
|
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchDown(0, QPointF(50, 50), timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// further touch down should not trigger
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchDown(1, QPointF(75, 75), timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchUp(1, timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// another press
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchDown(1, QPointF(10, 10), timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// simulate the move
|
|
|
|
QCOMPARE(moveSpy.count(), 0);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchMotion(0, QPointF(80, 90), timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(moveSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// move on other ID should not do anything
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchMotion(1, QPointF(20, 30), timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(moveSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// now up our main point
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchUp(0, timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(releaseSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
|
|
|
|
|
|
|
|
// and up the additional point
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::touchUp(1, timestamp++);
|
2016-05-23 15:07:08 +00:00
|
|
|
QCOMPARE(releaseSpy.count(), 1);
|
|
|
|
QCOMPARE(moveSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
|
|
|
|
}
|
|
|
|
|
2017-01-03 06:28:29 +00:00
|
|
|
void InternalWindowTest::testOpacity()
|
|
|
|
{
|
2019-08-26 07:44:04 +00:00
|
|
|
// this test verifies that opacity is properly synced from QWindow to InternalClient
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2017-01-03 06:28:29 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setOpacity(0.5);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QVERIFY(internalWindow->isInternal());
|
|
|
|
QCOMPARE(internalWindow->opacity(), 0.5);
|
2017-01-03 06:28:29 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
QSignalSpy opacityChangedSpy(internalWindow, &InternalWindow::opacityChanged);
|
2017-01-03 06:28:29 +00:00
|
|
|
win.setOpacity(0.75);
|
|
|
|
QCOMPARE(opacityChangedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(internalWindow->opacity(), 0.75);
|
2017-01-03 06:28:29 +00:00
|
|
|
}
|
|
|
|
|
2017-01-04 16:53:46 +00:00
|
|
|
void InternalWindowTest::testMove()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2017-01-04 16:53:46 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setOpacity(0.5);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QCOMPARE(internalWindow->frameGeometry(), QRect(0, 0, 100, 100));
|
2017-01-04 16:53:46 +00:00
|
|
|
|
|
|
|
// normal move should be synced
|
2022-04-23 19:51:16 +00:00
|
|
|
internalWindow->move(QPoint(5, 10));
|
|
|
|
QCOMPARE(internalWindow->frameGeometry(), QRect(5, 10, 100, 100));
|
2017-09-06 18:45:51 +00:00
|
|
|
QTRY_COMPARE(win.geometry(), QRect(5, 10, 100, 100));
|
2017-01-04 16:53:46 +00:00
|
|
|
// another move should also be synced
|
2022-04-23 19:51:16 +00:00
|
|
|
internalWindow->move(QPoint(10, 20));
|
|
|
|
QCOMPARE(internalWindow->frameGeometry(), QRect(10, 20, 100, 100));
|
2017-09-06 18:45:51 +00:00
|
|
|
QTRY_COMPARE(win.geometry(), QRect(10, 20, 100, 100));
|
2017-01-04 16:53:46 +00:00
|
|
|
|
|
|
|
// now move with a Geometry update blocker
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
GeometryUpdatesBlocker blocker(internalWindow);
|
|
|
|
internalWindow->move(QPoint(5, 10));
|
2017-01-04 16:53:46 +00:00
|
|
|
// not synced!
|
|
|
|
QCOMPARE(win.geometry(), QRect(10, 20, 100, 100));
|
|
|
|
}
|
|
|
|
// after destroying the blocker it should be synced
|
2017-09-06 18:45:51 +00:00
|
|
|
QTRY_COMPARE(win.geometry(), QRect(5, 10, 100, 100));
|
2017-01-04 16:53:46 +00:00
|
|
|
}
|
|
|
|
|
2017-01-11 19:00:40 +00:00
|
|
|
void InternalWindowTest::testSkipCloseAnimation_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("initial");
|
|
|
|
|
|
|
|
QTest::newRow("set") << true;
|
|
|
|
QTest::newRow("not set") << false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testSkipCloseAnimation()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2017-01-11 19:00:40 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setOpacity(0.5);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
QFETCH(bool, initial);
|
|
|
|
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QCOMPARE(internalWindow->skipsCloseAnimation(), initial);
|
|
|
|
QSignalSpy skipCloseChangedSpy(internalWindow, &Window::skipCloseAnimationChanged);
|
2017-01-11 19:00:40 +00:00
|
|
|
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial);
|
|
|
|
QCOMPARE(skipCloseChangedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(internalWindow->skipsCloseAnimation(), !initial);
|
2017-01-11 19:00:40 +00:00
|
|
|
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial);
|
|
|
|
QCOMPARE(skipCloseChangedSpy.count(), 2);
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(internalWindow->skipsCloseAnimation(), initial);
|
2017-01-11 19:00:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-11 09:49:31 +00:00
|
|
|
void InternalWindowTest::testModifierClickUnrestrictedMove()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2018-02-11 09:49:31 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() & ~Qt::FramelessWindowHint);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QVERIFY(internalWindow->isDecorated());
|
2018-02-11 09:49:31 +00:00
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
|
2020-05-06 09:17:44 +00:00
|
|
|
group.writeEntry("CommandAllKey", "Meta");
|
2018-02-11 09:49:31 +00:00
|
|
|
group.writeEntry("CommandAll1", "Move");
|
|
|
|
group.writeEntry("CommandAll2", "Move");
|
|
|
|
group.writeEntry("CommandAll3", "Move");
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
2020-05-06 09:17:44 +00:00
|
|
|
QCOMPARE(options->commandAllModifier(), Qt::MetaModifier);
|
2018-02-11 09:49:31 +00:00
|
|
|
QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove);
|
|
|
|
QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove);
|
|
|
|
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
|
|
|
|
|
|
|
|
// move cursor on window
|
2023-02-09 13:07:56 +00:00
|
|
|
input()->pointer()->warp(internalWindow->frameGeometry().center());
|
2018-02-11 09:49:31 +00:00
|
|
|
|
|
|
|
// simulate modifier+click
|
|
|
|
quint32 timestamp = 1;
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(!internalWindow->isInteractiveMove());
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(internalWindow->isInteractiveMove());
|
2018-02-11 09:49:31 +00:00
|
|
|
// release modifier should not change it
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(internalWindow->isInteractiveMove());
|
2018-02-11 09:49:31 +00:00
|
|
|
// but releasing the key should end move/resize
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(!internalWindow->isInteractiveMove());
|
2018-02-11 09:49:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testModifierScroll()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2018-02-11 09:49:31 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() & ~Qt::FramelessWindowHint);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QVERIFY(internalWindow->isDecorated());
|
2018-02-11 09:49:31 +00:00
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
|
2020-05-06 09:17:44 +00:00
|
|
|
group.writeEntry("CommandAllKey", "Meta");
|
2018-02-11 09:49:31 +00:00
|
|
|
group.writeEntry("CommandAllWheel", "change opacity");
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
|
|
|
// move cursor on window
|
2023-02-09 13:07:56 +00:00
|
|
|
input()->pointer()->warp(internalWindow->frameGeometry().center());
|
2018-02-11 09:49:31 +00:00
|
|
|
|
|
|
|
// set the opacity to 0.5
|
2022-04-23 19:51:16 +00:00
|
|
|
internalWindow->setOpacity(0.5);
|
|
|
|
QCOMPARE(internalWindow->opacity(), 0.5);
|
2018-02-11 09:49:31 +00:00
|
|
|
quint32 timestamp = 1;
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
|
|
|
|
Test::pointerAxisVertical(-5, timestamp++);
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(internalWindow->opacity(), 0.6);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerAxisVertical(5, timestamp++);
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(internalWindow->opacity(), 0.5);
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
|
2018-02-11 09:49:31 +00:00
|
|
|
}
|
|
|
|
|
2019-01-05 10:10:33 +00:00
|
|
|
void InternalWindowTest::testPopup()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2019-01-05 10:10:33 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() | Qt::Popup);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QCOMPARE(internalWindow->isPopupWindow(), true);
|
2019-01-05 10:10:33 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 22:48:04 +00:00
|
|
|
void InternalWindowTest::testScale()
|
|
|
|
{
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig({
|
|
|
|
Test::OutputInfo{
|
|
|
|
.geometry = QRect(0, 0, 1280, 1024),
|
|
|
|
.scale = 2.0,
|
|
|
|
},
|
|
|
|
Test::OutputInfo{
|
|
|
|
.geometry = QRect(1280, 0, 1280, 1024),
|
|
|
|
.scale = 2.0,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2019-01-11 22:48:04 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() | Qt::Popup);
|
|
|
|
win.show();
|
|
|
|
QCOMPARE(win.devicePixelRatio(), 2.0);
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QCOMPARE(internalWindow->bufferScale(), 2);
|
2019-01-11 22:48:04 +00:00
|
|
|
}
|
|
|
|
|
2019-01-13 16:50:32 +00:00
|
|
|
void InternalWindowTest::testEffectWindow()
|
|
|
|
{
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2019-01-13 16:50:32 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(internalWindow);
|
|
|
|
QVERIFY(internalWindow->effectWindow());
|
|
|
|
QCOMPARE(internalWindow->effectWindow()->internalWindow(), &win);
|
2019-01-13 16:50:32 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
QCOMPARE(effects->findWindow(&win), internalWindow->effectWindow());
|
2019-01-13 16:50:32 +00:00
|
|
|
QCOMPARE(effects->findWindow(&win)->internalWindow(), &win);
|
|
|
|
}
|
2019-01-11 22:48:04 +00:00
|
|
|
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
void InternalWindowTest::testReentrantMoveResize()
|
2020-07-20 19:33:19 +00:00
|
|
|
{
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
// This test verifies that calling moveResize() from a slot connected directly
|
2020-07-20 19:33:19 +00:00
|
|
|
// to the frameGeometryChanged() signal won't cause an infinite recursion.
|
|
|
|
|
|
|
|
// Create an internal window.
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2020-07-20 19:33:19 +00:00
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
auto window = windowAddedSpy.first().first().value<InternalWindow *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->pos(), QPoint(0, 0));
|
2020-07-20 19:33:19 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Let's pretend that there is a script that really wants the window to be at (100, 100).
|
|
|
|
connect(window, &Window::frameGeometryChanged, this, [window]() {
|
2022-05-16 20:13:39 +00:00
|
|
|
window->moveResize(QRectF(QPointF(100, 100), window->size()));
|
2020-07-20 19:33:19 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Trigger the lambda above.
|
2022-04-23 19:51:16 +00:00
|
|
|
window->move(QPoint(40, 50));
|
2020-07-20 19:33:19 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Eventually, the window will end up at (100, 100).
|
|
|
|
QCOMPARE(window->pos(), QPoint(100, 100));
|
2020-07-20 19:33:19 +00:00
|
|
|
}
|
|
|
|
|
2021-01-30 20:29:55 +00:00
|
|
|
void InternalWindowTest::testDismissPopup()
|
|
|
|
{
|
|
|
|
// This test verifies that a popup window created by the compositor will be dismissed
|
|
|
|
// when user clicks another window.
|
|
|
|
|
|
|
|
// Create a toplevel window.
|
2023-03-13 11:54:38 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2021-01-30 20:29:55 +00:00
|
|
|
HelperWindow clientToplevel;
|
|
|
|
clientToplevel.setGeometry(0, 0, 100, 100);
|
|
|
|
clientToplevel.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 1);
|
|
|
|
auto serverToplevel = windowAddedSpy.last().first().value<InternalWindow *>();
|
2021-01-30 20:29:55 +00:00
|
|
|
QVERIFY(serverToplevel);
|
|
|
|
|
|
|
|
// Create a popup window.
|
|
|
|
QRasterWindow clientPopup;
|
|
|
|
clientPopup.setFlag(Qt::Popup);
|
|
|
|
clientPopup.setTransientParent(&clientToplevel);
|
|
|
|
clientPopup.setGeometry(0, 0, 50, 50);
|
|
|
|
clientPopup.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 2);
|
|
|
|
auto serverPopup = windowAddedSpy.last().first().value<InternalWindow *>();
|
2021-01-30 20:29:55 +00:00
|
|
|
QVERIFY(serverPopup);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
// Create the other window to click
|
2021-05-07 22:26:21 +00:00
|
|
|
HelperWindow otherClientToplevel;
|
|
|
|
otherClientToplevel.setGeometry(100, 100, 100, 100);
|
|
|
|
otherClientToplevel.show();
|
2022-04-23 08:33:23 +00:00
|
|
|
QTRY_COMPARE(windowAddedSpy.count(), 3);
|
|
|
|
auto serverOtherToplevel = windowAddedSpy.last().first().value<InternalWindow *>();
|
2021-05-07 22:26:21 +00:00
|
|
|
QVERIFY(serverOtherToplevel);
|
|
|
|
|
2021-01-30 20:29:55 +00:00
|
|
|
// Click somewhere outside the popup window.
|
2023-03-13 19:21:11 +00:00
|
|
|
QSignalSpy popupClosedSpy(serverPopup, &InternalWindow::closed);
|
2021-01-30 20:29:55 +00:00
|
|
|
quint32 timestamp = 0;
|
2022-03-10 10:27:35 +00:00
|
|
|
Test::pointerMotion(serverOtherToplevel->frameGeometry().center(), timestamp++);
|
|
|
|
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
|
2021-01-30 20:29:55 +00:00
|
|
|
QTRY_COMPARE(popupClosedSpy.count(), 1);
|
|
|
|
}
|
|
|
|
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 08:34:19 +00:00
|
|
|
WAYLANDTEST_MAIN(KWin::InternalWindowTest)
|
2016-02-05 14:39:04 +00:00
|
|
|
#include "internal_window.moc"
|