2016-02-05 14:39:04 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "kwin_wayland_test.h"
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.h"
|
2016-02-05 14:39:04 +00:00
|
|
|
#include "cursor.h"
|
2019-01-13 16:50:32 +00:00
|
|
|
#include "effects.h"
|
2019-01-27 19:48:00 +00:00
|
|
|
#include "internal_client.h"
|
2016-02-05 14:39:04 +00:00
|
|
|
#include "shell_client.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QRasterWindow>
|
|
|
|
|
2016-08-11 09:17:09 +00:00
|
|
|
#include <KWayland/Client/keyboard.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
#include <KWayland/Client/seat.h>
|
|
|
|
#include <KWayland/Client/shell.h>
|
2019-01-13 16:50:32 +00:00
|
|
|
#include <KWindowSystem>
|
2016-08-11 09:17:09 +00:00
|
|
|
|
2019-01-11 22:48:04 +00:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
|
2016-02-05 14:39:04 +00:00
|
|
|
#include <linux/input.h>
|
|
|
|
|
2016-08-11 09:17:09 +00:00
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
2019-01-13 16:50:32 +00:00
|
|
|
Q_DECLARE_METATYPE(NET::WindowType);
|
|
|
|
|
2016-02-05 14:39:04 +00:00
|
|
|
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 testWindowType_data();
|
|
|
|
void testWindowType();
|
|
|
|
void testChangeWindowType_data();
|
|
|
|
void testChangeWindowType();
|
|
|
|
void testEffectWindow();
|
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
|
|
|
|
2016-05-23 15:07:08 +00:00
|
|
|
QPoint latestGlobalMousePos() const {
|
|
|
|
return m_latestGlobalMousePos;
|
|
|
|
}
|
|
|
|
Qt::MouseButtons pressedButtons() const {
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
Q_UNUSED(event)
|
|
|
|
QPainter p(this);
|
|
|
|
p.fillRect(0, 0, width(), height(), Qt::red);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HelperWindow::event(QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::Enter) {
|
|
|
|
emit entered();
|
|
|
|
}
|
|
|
|
if (event->type() == QEvent::Leave) {
|
|
|
|
emit left();
|
|
|
|
}
|
|
|
|
return QRasterWindow::event(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
m_latestGlobalMousePos = event->globalPos();
|
2016-02-05 14:39:04 +00:00
|
|
|
emit mouseMoved(event->globalPos());
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
m_latestGlobalMousePos = event->globalPos();
|
|
|
|
m_pressedButtons = event->buttons();
|
2016-02-05 14:39:04 +00:00
|
|
|
emit mousePressed();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::mouseReleaseEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-05-23 15:07:08 +00:00
|
|
|
m_latestGlobalMousePos = event->globalPos();
|
|
|
|
m_pressedButtons = event->buttons();
|
2016-02-05 14:39:04 +00:00
|
|
|
emit mouseReleased();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::wheelEvent(QWheelEvent *event)
|
|
|
|
{
|
|
|
|
Q_UNUSED(event)
|
|
|
|
emit wheel();
|
|
|
|
}
|
|
|
|
|
2016-02-08 14:03:21 +00:00
|
|
|
void HelperWindow::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
Q_UNUSED(event)
|
|
|
|
emit keyPressed();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelperWindow::keyReleaseEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
Q_UNUSED(event)
|
|
|
|
emit keyReleased();
|
|
|
|
}
|
|
|
|
|
2016-02-05 14:39:04 +00:00
|
|
|
void InternalWindowTest::initTestCase()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<KWin::ShellClient*>();
|
|
|
|
qRegisterMetaType<KWin::AbstractClient*>();
|
|
|
|
QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated);
|
|
|
|
QVERIFY(workspaceCreatedSpy.isValid());
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2016-07-04 07:09:03 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
|
2019-08-26 21:16:53 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
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();
|
|
|
|
QVERIFY(workspaceCreatedSpy.wait());
|
|
|
|
QCOMPARE(screens()->count(), 2);
|
|
|
|
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
|
|
|
|
waylandServer()->initWorkspace();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::init()
|
|
|
|
{
|
|
|
|
Cursor::setPos(QPoint(1280, 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()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
2016-08-30 13:47:59 +00:00
|
|
|
QVERIFY(!workspace()->findToplevel(nullptr));
|
|
|
|
QVERIFY(!workspace()->findToplevel(&win));
|
2016-02-05 14:39:04 +00:00
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2016-02-05 14:39:04 +00:00
|
|
|
QVERIFY(!workspace()->activeClient());
|
|
|
|
ShellClient *c = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(c->isInternal());
|
2019-01-27 19:48:00 +00:00
|
|
|
QVERIFY(qobject_cast<InternalClient*>(c));
|
2018-02-04 13:19:23 +00:00
|
|
|
QCOMPARE(c->icon().name(), QStringLiteral("wayland"));
|
2018-02-11 09:49:31 +00:00
|
|
|
QVERIFY(!c->isDecorated());
|
2016-08-30 13:47:59 +00:00
|
|
|
QCOMPARE(workspace()->findToplevel(&win), c);
|
2016-02-05 14:39:04 +00:00
|
|
|
QCOMPARE(c->geometry(), QRect(0, 0, 100, 100));
|
2016-08-31 14:08:25 +00:00
|
|
|
QVERIFY(c->isShown(false));
|
|
|
|
QVERIFY(workspace()->xStackingOrder().contains(c));
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
QSignalSpy enterSpy(&win, &HelperWindow::entered);
|
|
|
|
QVERIFY(enterSpy.isValid());
|
|
|
|
QSignalSpy leaveSpy(&win, &HelperWindow::left);
|
|
|
|
QVERIFY(leaveSpy.isValid());
|
|
|
|
QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved);
|
|
|
|
QVERIFY(moveSpy.isValid());
|
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->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
|
|
|
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->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
|
|
|
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->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
|
|
|
|
kwinApp()->platform()->pointerMotion(QPoint(5, 5), timestamp++);
|
|
|
|
QVERIFY(!enterSpy.wait(100));
|
|
|
|
QCOMPARE(enterSpy.count(), 1);
|
|
|
|
// inside the mask we should still get an enter
|
|
|
|
kwinApp()->platform()->pointerMotion(QPoint(25, 27), timestamp++);
|
|
|
|
QTRY_COMPARE(enterSpy.count(), 2);
|
2016-08-31 14:08:25 +00:00
|
|
|
|
|
|
|
// hide the window, which should be removed from the stacking order
|
|
|
|
win.hide();
|
|
|
|
QTRY_VERIFY(!c->isShown(false));
|
|
|
|
QVERIFY(!workspace()->xStackingOrder().contains(c));
|
|
|
|
|
|
|
|
// show again
|
|
|
|
win.show();
|
|
|
|
QTRY_VERIFY(c->isShown(false));
|
|
|
|
QVERIFY(workspace()->xStackingOrder().contains(c));
|
2016-02-05 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testPointerPressRelease()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::mousePressed);
|
|
|
|
QVERIFY(pressSpy.isValid());
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased);
|
|
|
|
QVERIFY(releaseSpy.isValid());
|
|
|
|
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->pointerMotion(QPoint(50, 50), timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(pressSpy.count(), 1);
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(releaseSpy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testPointerAxis()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy wheelSpy(&win, &HelperWindow::wheel);
|
|
|
|
QVERIFY(wheelSpy.isValid());
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->pointerMotion(QPoint(50, 50), timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++);
|
2016-02-05 14:39:04 +00:00
|
|
|
QTRY_COMPARE(wheelSpy.count(), 1);
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->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()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
|
|
|
|
QVERIFY(pressSpy.isValid());
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
|
|
|
|
QVERIFY(releaseSpy.isValid());
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2016-08-11 09:17:09 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QVERIFY(internalClient->isInternal());
|
2016-08-16 10:43:29 +00:00
|
|
|
QVERIFY(internalClient->readyForPainting());
|
2016-02-08 14:03:21 +00:00
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
2016-02-17 12:34:24 +00:00
|
|
|
QFETCH(QPoint, cursorPos);
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->pointerMotion(cursorPos, timestamp++);
|
2016-02-08 14:03:21 +00:00
|
|
|
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++);
|
2016-02-08 14:03:21 +00:00
|
|
|
QTRY_COMPARE(pressSpy.count(), 1);
|
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
2016-04-07 06:28:35 +00:00
|
|
|
kwinApp()->platform()->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()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setProperty("_q_showWithoutActivating", true);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
|
|
|
|
QVERIFY(pressSpy.isValid());
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
|
|
|
|
QVERIFY(releaseSpy.isValid());
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2016-08-29 13:34:02 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QVERIFY(internalClient->isInternal());
|
|
|
|
QVERIFY(internalClient->readyForPainting());
|
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
|
|
|
const QPoint cursorPos = QPoint(50, 50);
|
|
|
|
kwinApp()->platform()->pointerMotion(cursorPos, timestamp++);
|
|
|
|
|
|
|
|
kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++);
|
|
|
|
QCOMPARE(pressSpy.count(), 0);
|
|
|
|
QVERIFY(!pressSpy.wait(100));
|
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
|
|
|
kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++);
|
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
|
|
|
QVERIFY(!releaseSpy.wait(100));
|
|
|
|
QCOMPARE(pressSpy.count(), 0);
|
|
|
|
}
|
|
|
|
|
2016-08-16 13:39:47 +00:00
|
|
|
void InternalWindowTest::testKeyboardTriggersLeave()
|
|
|
|
{
|
|
|
|
// this test verifies that a leave event is sent to a client when an internal window
|
|
|
|
// gets a key event
|
2016-08-11 09:17:09 +00:00
|
|
|
QScopedPointer<Keyboard> keyboard(Test::waylandSeat()->createKeyboard());
|
|
|
|
QVERIFY(!keyboard.isNull());
|
|
|
|
QVERIFY(keyboard->isValid());
|
|
|
|
QSignalSpy enteredSpy(keyboard.data(), &Keyboard::entered);
|
|
|
|
QVERIFY(enteredSpy.isValid());
|
|
|
|
QSignalSpy leftSpy(keyboard.data(), &Keyboard::left);
|
|
|
|
QVERIFY(leftSpy.isValid());
|
|
|
|
QScopedPointer<Surface> surface(Test::createSurface());
|
|
|
|
QScopedPointer<QObject> shellSurface(Test::createShellSurface(Test::ShellSurfaceType::WlShell, surface.data()));
|
|
|
|
|
|
|
|
// now let's render
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c);
|
|
|
|
QVERIFY(c->isActive());
|
2016-08-16 12:32:27 +00:00
|
|
|
QVERIFY(!c->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
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
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);
|
|
|
|
QVERIFY(pressSpy.isValid());
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
|
|
|
|
QVERIFY(releaseSpy.isValid());
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2016-08-16 13:39:47 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QVERIFY(internalClient->isInternal());
|
|
|
|
QVERIFY(internalClient->readyForPainting());
|
|
|
|
|
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;
|
2016-08-11 09:17:09 +00:00
|
|
|
kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++);
|
|
|
|
QVERIFY(leftSpy.wait());
|
2016-08-16 13:39:47 +00:00
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
2016-08-11 09:17:09 +00:00
|
|
|
|
|
|
|
kwinApp()->platform()->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();
|
|
|
|
kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++);
|
|
|
|
QVERIFY(enteredSpy.wait());
|
|
|
|
kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++);
|
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
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2016-05-23 15:07:08 +00:00
|
|
|
|
|
|
|
QSignalSpy pressSpy(&win, &HelperWindow::mousePressed);
|
|
|
|
QVERIFY(pressSpy.isValid());
|
|
|
|
QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased);
|
|
|
|
QVERIFY(releaseSpy.isValid());
|
|
|
|
QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved);
|
|
|
|
QVERIFY(moveSpy.isValid());
|
|
|
|
|
|
|
|
quint32 timestamp = 1;
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
|
|
|
|
kwinApp()->platform()->touchDown(0, QPointF(50, 50), timestamp++);
|
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// further touch down should not trigger
|
|
|
|
kwinApp()->platform()->touchDown(1, QPointF(75, 75), timestamp++);
|
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
|
|
|
kwinApp()->platform()->touchUp(1, timestamp++);
|
|
|
|
QCOMPARE(releaseSpy.count(), 0);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// another press
|
|
|
|
kwinApp()->platform()->touchDown(1, QPointF(10, 10), timestamp++);
|
|
|
|
QCOMPARE(pressSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// simulate the move
|
|
|
|
QCOMPARE(moveSpy.count(), 0);
|
|
|
|
kwinApp()->platform()->touchMotion(0, QPointF(80, 90), timestamp++);
|
|
|
|
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
|
|
|
|
kwinApp()->platform()->touchMotion(1, QPointF(20, 30), timestamp++);
|
|
|
|
QCOMPARE(moveSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
|
|
|
|
|
|
|
|
// now up our main point
|
|
|
|
kwinApp()->platform()->touchUp(0, timestamp++);
|
|
|
|
QCOMPARE(releaseSpy.count(), 1);
|
|
|
|
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
|
|
|
|
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
|
|
|
|
|
|
|
|
// and up the additional point
|
|
|
|
kwinApp()->platform()->touchUp(1, timestamp++);
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
// this test verifies that opacity is properly synced from QWindow to ShellClient
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setOpacity(0.5);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2017-01-03 06:28:29 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QVERIFY(internalClient->isInternal());
|
|
|
|
QCOMPARE(internalClient->opacity(), 0.5);
|
|
|
|
|
|
|
|
QSignalSpy opacityChangedSpy(internalClient, &ShellClient::opacityChanged);
|
|
|
|
QVERIFY(opacityChangedSpy.isValid());
|
|
|
|
win.setOpacity(0.75);
|
|
|
|
QCOMPARE(opacityChangedSpy.count(), 1);
|
|
|
|
QCOMPARE(internalClient->opacity(), 0.75);
|
|
|
|
}
|
|
|
|
|
2017-01-04 16:53:46 +00:00
|
|
|
void InternalWindowTest::testMove()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setOpacity(0.5);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2017-01-04 16:53:46 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QCOMPARE(internalClient->geometry(), QRect(0, 0, 100, 100));
|
|
|
|
|
|
|
|
// normal move should be synced
|
|
|
|
internalClient->move(5, 10);
|
|
|
|
QCOMPARE(internalClient->geometry(), 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
|
|
|
|
internalClient->move(10, 20);
|
|
|
|
QCOMPARE(internalClient->geometry(), 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
|
|
|
|
{
|
|
|
|
GeometryUpdatesBlocker blocker(internalClient);
|
|
|
|
internalClient->move(5, 10);
|
|
|
|
// 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()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setOpacity(0.5);
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
QFETCH(bool, initial);
|
|
|
|
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2017-01-11 19:00:40 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QCOMPARE(internalClient->skipsCloseAnimation(), initial);
|
|
|
|
QSignalSpy skipCloseChangedSpy(internalClient, &Toplevel::skipCloseAnimationChanged);
|
|
|
|
QVERIFY(skipCloseChangedSpy.isValid());
|
|
|
|
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial);
|
|
|
|
QCOMPARE(skipCloseChangedSpy.count(), 1);
|
|
|
|
QCOMPARE(internalClient->skipsCloseAnimation(), !initial);
|
|
|
|
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial);
|
|
|
|
QCOMPARE(skipCloseChangedSpy.count(), 2);
|
|
|
|
QCOMPARE(internalClient->skipsCloseAnimation(), initial);
|
|
|
|
}
|
|
|
|
|
2018-02-11 09:49:31 +00:00
|
|
|
void InternalWindowTest::testModifierClickUnrestrictedMove()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() & ~Qt::FramelessWindowHint);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2018-02-11 09:49:31 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QVERIFY(internalClient->isDecorated());
|
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
|
|
|
|
group.writeEntry("CommandAllKey", "Alt");
|
|
|
|
group.writeEntry("CommandAll1", "Move");
|
|
|
|
group.writeEntry("CommandAll2", "Move");
|
|
|
|
group.writeEntry("CommandAll3", "Move");
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
QCOMPARE(options->commandAllModifier(), Qt::AltModifier);
|
|
|
|
QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove);
|
|
|
|
QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove);
|
|
|
|
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
|
|
|
|
|
|
|
|
// move cursor on window
|
|
|
|
Cursor::setPos(internalClient->geometry().center());
|
|
|
|
|
|
|
|
// simulate modifier+click
|
|
|
|
quint32 timestamp = 1;
|
|
|
|
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++);
|
|
|
|
QVERIFY(!internalClient->isMove());
|
|
|
|
kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++);
|
|
|
|
QVERIFY(internalClient->isMove());
|
|
|
|
// release modifier should not change it
|
|
|
|
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++);
|
|
|
|
QVERIFY(internalClient->isMove());
|
|
|
|
// but releasing the key should end move/resize
|
|
|
|
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++);
|
|
|
|
QVERIFY(!internalClient->isMove());
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testModifierScroll()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() & ~Qt::FramelessWindowHint);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2018-02-11 09:49:31 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QVERIFY(internalClient->isDecorated());
|
|
|
|
|
|
|
|
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
|
|
|
|
group.writeEntry("CommandAllKey", "Alt");
|
|
|
|
group.writeEntry("CommandAllWheel", "change opacity");
|
|
|
|
group.sync();
|
|
|
|
workspace()->slotReconfigure();
|
|
|
|
|
|
|
|
// move cursor on window
|
|
|
|
Cursor::setPos(internalClient->geometry().center());
|
|
|
|
|
|
|
|
// set the opacity to 0.5
|
|
|
|
internalClient->setOpacity(0.5);
|
|
|
|
QCOMPARE(internalClient->opacity(), 0.5);
|
|
|
|
quint32 timestamp = 1;
|
|
|
|
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++);
|
|
|
|
kwinApp()->platform()->pointerAxisVertical(-5, timestamp++);
|
|
|
|
QCOMPARE(internalClient->opacity(), 0.6);
|
|
|
|
kwinApp()->platform()->pointerAxisVertical(5, timestamp++);
|
|
|
|
QCOMPARE(internalClient->opacity(), 0.5);
|
|
|
|
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++);
|
|
|
|
}
|
|
|
|
|
2019-01-05 10:10:33 +00:00
|
|
|
void InternalWindowTest::testPopup()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() | Qt::Popup);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2019-01-05 10:10:33 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QCOMPARE(internalClient->isPopupWindow(), true);
|
|
|
|
}
|
|
|
|
|
2019-01-11 22:48:04 +00:00
|
|
|
void InternalWindowTest::testScale()
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection,
|
|
|
|
Q_ARG(int, 2),
|
|
|
|
Q_ARG(QVector<QRect>, QVector<QRect>({QRect(0,0,1280, 1024), QRect(1280/2, 0, 1280, 1024)})),
|
|
|
|
Q_ARG(QVector<int>, QVector<int>({2,2})));
|
|
|
|
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.setFlags(win.flags() | Qt::Popup);
|
|
|
|
win.show();
|
|
|
|
QCOMPARE(win.devicePixelRatio(), 2.0);
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2019-01-11 22:48:04 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QCOMPARE(internalClient->surface()->scale(), 2);
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
|
|
|
}
|
|
|
|
|
2019-01-13 16:50:32 +00:00
|
|
|
void InternalWindowTest::testWindowType_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<NET::WindowType>("windowType");
|
|
|
|
|
|
|
|
QTest::newRow("normal") << NET::Normal;
|
|
|
|
QTest::newRow("desktop") << NET::Desktop;
|
|
|
|
QTest::newRow("Dock") << NET::Dock;
|
|
|
|
QTest::newRow("Toolbar") << NET::Toolbar;
|
|
|
|
QTest::newRow("Menu") << NET::Menu;
|
|
|
|
QTest::newRow("Dialog") << NET::Dialog;
|
|
|
|
QTest::newRow("Utility") << NET::Utility;
|
|
|
|
QTest::newRow("Splash") << NET::Splash;
|
|
|
|
QTest::newRow("DropdownMenu") << NET::DropdownMenu;
|
|
|
|
QTest::newRow("PopupMenu") << NET::PopupMenu;
|
|
|
|
QTest::newRow("Tooltip") << NET::Tooltip;
|
|
|
|
QTest::newRow("Notification") << NET::Notification;
|
|
|
|
QTest::newRow("ComboBox") << NET::ComboBox;
|
|
|
|
QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay;
|
2019-05-02 08:29:38 +00:00
|
|
|
QTest::newRow("CriticalNotification") << NET::CriticalNotification;
|
2019-01-13 16:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testWindowType()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
QFETCH(NET::WindowType, windowType);
|
|
|
|
KWindowSystem::setType(win.winId(), windowType);
|
|
|
|
win.show();
|
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QCOMPARE(internalClient->windowType(), windowType);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testChangeWindowType_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<NET::WindowType>("windowType");
|
|
|
|
|
|
|
|
QTest::newRow("desktop") << NET::Desktop;
|
|
|
|
QTest::newRow("Dock") << NET::Dock;
|
|
|
|
QTest::newRow("Toolbar") << NET::Toolbar;
|
|
|
|
QTest::newRow("Menu") << NET::Menu;
|
|
|
|
QTest::newRow("Dialog") << NET::Dialog;
|
|
|
|
QTest::newRow("Utility") << NET::Utility;
|
|
|
|
QTest::newRow("Splash") << NET::Splash;
|
|
|
|
QTest::newRow("DropdownMenu") << NET::DropdownMenu;
|
|
|
|
QTest::newRow("PopupMenu") << NET::PopupMenu;
|
|
|
|
QTest::newRow("Tooltip") << NET::Tooltip;
|
|
|
|
QTest::newRow("Notification") << NET::Notification;
|
|
|
|
QTest::newRow("ComboBox") << NET::ComboBox;
|
|
|
|
QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay;
|
2019-05-02 08:29:38 +00:00
|
|
|
QTest::newRow("CriticalNotification") << NET::CriticalNotification;
|
2019-01-13 16:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testChangeWindowType()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QCOMPARE(internalClient->windowType(), NET::Normal);
|
|
|
|
|
|
|
|
QFETCH(NET::WindowType, windowType);
|
|
|
|
KWindowSystem::setType(win.winId(), windowType);
|
|
|
|
QTRY_COMPARE(internalClient->windowType(), windowType);
|
|
|
|
|
|
|
|
KWindowSystem::setType(win.winId(), NET::Normal);
|
|
|
|
QTRY_COMPARE(internalClient->windowType(), NET::Normal);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalWindowTest::testEffectWindow()
|
|
|
|
{
|
|
|
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
|
|
|
QVERIFY(clientAddedSpy.isValid());
|
|
|
|
HelperWindow win;
|
|
|
|
win.setGeometry(0, 0, 100, 100);
|
|
|
|
win.show();
|
2019-06-27 16:23:07 +00:00
|
|
|
QTRY_COMPARE(clientAddedSpy.count(), 1);
|
2019-01-13 16:50:32 +00:00
|
|
|
auto internalClient = clientAddedSpy.first().first().value<ShellClient*>();
|
|
|
|
QVERIFY(internalClient);
|
|
|
|
QVERIFY(internalClient->effectWindow());
|
|
|
|
QCOMPARE(internalClient->effectWindow()->internalWindow(), &win);
|
|
|
|
|
|
|
|
QCOMPARE(effects->findWindow(&win), internalClient->effectWindow());
|
|
|
|
QCOMPARE(effects->findWindow(&win)->internalWindow(), &win);
|
|
|
|
}
|
2019-01-11 22:48:04 +00:00
|
|
|
|
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"
|