2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-04-11 15:24:08 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-04-11 15:24:08 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-04-11 15:24:08 +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-03-23 11:39:20 +00:00
|
|
|
#include "libkwineffects/kwineffects.h"
|
2023-02-09 13:07:56 +00:00
|
|
|
#include "pointer_input.h"
|
2016-04-11 15:24:08 +00:00
|
|
|
#include "screenedge.h"
|
2021-08-21 17:46:51 +00:00
|
|
|
#include "virtualdesktops.h"
|
2016-04-11 15:24:08 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
2022-04-22 17:54:31 +00:00
|
|
|
#include "x11window.h"
|
2016-04-11 15:24:08 +00:00
|
|
|
|
|
|
|
#include <KWayland/Client/compositor.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
|
|
|
|
#include <netwm.h>
|
|
|
|
#include <xcb/xcb_icccm.h>
|
|
|
|
|
2022-11-02 16:20:37 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::StrutRects)
|
|
|
|
|
2016-04-11 15:24:08 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_struts-0");
|
|
|
|
|
|
|
|
class StrutsTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
void testX11Struts_data();
|
|
|
|
void testX11Struts();
|
2016-06-02 07:29:53 +00:00
|
|
|
void test363804();
|
2016-07-13 05:59:18 +00:00
|
|
|
void testLeftScreenSmallerBottomAligned();
|
2017-07-08 06:41:16 +00:00
|
|
|
void testWindowMoveWithPanelBetweenScreens();
|
2016-04-11 15:24:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
void StrutsTest::initTestCase()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
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),
|
|
|
|
});
|
2016-04-11 15:24:08 +00:00
|
|
|
|
2017-08-08 17:56:24 +00:00
|
|
|
// set custom config which disables the Outline
|
|
|
|
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
|
|
|
KConfigGroup group = config->group("Outline");
|
|
|
|
group.writeEntry(QStringLiteral("QmlPath"), QString("/does/not/exist.qml"));
|
|
|
|
group.sync();
|
|
|
|
|
|
|
|
kwinApp()->setConfig(config);
|
|
|
|
|
2016-04-11 15:24:08 +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-04-11 15:24:08 +00:00
|
|
|
setenv("QT_QPA_PLATFORM", "wayland", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StrutsTest::init()
|
|
|
|
{
|
2023-05-23 08:02:59 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
2016-06-30 11:32:54 +00:00
|
|
|
m_compositor = Test::waylandCompositor();
|
2016-04-11 15:24:08 +00:00
|
|
|
|
2021-08-28 18:58:29 +00:00
|
|
|
workspace()->setActiveOutput(QPoint(640, 512));
|
2023-02-09 13:07:56 +00:00
|
|
|
input()->pointer()->warp(QPoint(640, 512));
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(waylandServer()->windows().isEmpty());
|
2016-04-11 15:24:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StrutsTest::cleanup()
|
|
|
|
{
|
2016-06-30 11:32:54 +00:00
|
|
|
Test::destroyWaylandConnection();
|
2016-06-09 08:01:05 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 15:24:08 +00:00
|
|
|
void StrutsTest::testX11Struts_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QRect>("windowGeometry");
|
|
|
|
QTest::addColumn<int>("leftStrut");
|
|
|
|
QTest::addColumn<int>("rightStrut");
|
|
|
|
QTest::addColumn<int>("topStrut");
|
|
|
|
QTest::addColumn<int>("bottomStrut");
|
|
|
|
QTest::addColumn<int>("leftStrutStart");
|
|
|
|
QTest::addColumn<int>("leftStrutEnd");
|
|
|
|
QTest::addColumn<int>("rightStrutStart");
|
|
|
|
QTest::addColumn<int>("rightStrutEnd");
|
|
|
|
QTest::addColumn<int>("topStrutStart");
|
|
|
|
QTest::addColumn<int>("topStrutEnd");
|
|
|
|
QTest::addColumn<int>("bottomStrutStart");
|
|
|
|
QTest::addColumn<int>("bottomStrutEnd");
|
2022-07-15 07:38:00 +00:00
|
|
|
QTest::addColumn<QRectF>("screen0Maximized");
|
|
|
|
QTest::addColumn<QRectF>("screen1Maximized");
|
|
|
|
QTest::addColumn<QRectF>("workArea");
|
2022-11-02 16:20:37 +00:00
|
|
|
QTest::addColumn<StrutRects>("restrictedMoveArea");
|
2016-04-11 15:24:08 +00:00
|
|
|
|
|
|
|
QTest::newRow("bottom panel/no strut") << QRect(0, 980, 1280, 44)
|
|
|
|
<< 0 << 0 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("bottom panel/strut") << QRect(0, 980, 1280, 44)
|
|
|
|
<< 0 << 0 << 0 << 44
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 1279
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 980)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 980)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(0, 980, 1279, 44)};
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("top panel/no strut") << QRect(0, 0, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("top panel/strut") << QRect(0, 0, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 44 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 1279
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 44, 1280, 980)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 44, 2560, 980)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(0, 0, 1279, 44)};
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("left panel/no strut") << QRect(0, 0, 60, 1024)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("left panel/strut") << QRect(0, 0, 60, 1024)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 60 << 0 << 0 << 0
|
|
|
|
<< 0 << 1023
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(60, 0, 1220, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(60, 0, 2500, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(0, 0, 60, 1023)};
|
2017-07-08 06:41:16 +00:00
|
|
|
QTest::newRow("right panel/no strut") << QRect(1220, 0, 60, 1024)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2017-07-08 06:41:16 +00:00
|
|
|
QTest::newRow("right panel/strut") << QRect(1220, 0, 60, 1024)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 1340 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 1023
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1220, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(1220, 0, 60, 1023)};
|
2016-04-11 15:24:08 +00:00
|
|
|
// second screen
|
|
|
|
QTest::newRow("bottom panel 1/no strut") << QRect(1280, 980, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("bottom panel 1/strut") << QRect(1280, 980, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 0 << 44
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 1280 << 2559
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 980)
|
|
|
|
<< QRectF(0, 0, 2560, 980)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(1280, 980, 1279, 44)};
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("top panel 1/no strut") << QRect(1280, 0, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("top panel 1 /strut") << QRect(1280, 0, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 44 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 1280 << 2559
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 44, 1280, 980)
|
|
|
|
<< QRectF(0, 44, 2560, 980)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(1280, 0, 1279, 44)};
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("left panel 1/no strut") << QRect(1280, 0, 60, 1024)
|
|
|
|
<< 0 << 0 << 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("left panel 1/strut") << QRect(1280, 0, 60, 1024)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 1340 << 0 << 0 << 0
|
|
|
|
<< 0 << 1023
|
|
|
|
<< 0 << 0
|
2016-04-11 15:24:08 +00:00
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1340, 0, 1220, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(1280, 0, 60, 1023)};
|
2022-03-23 10:13:38 +00:00
|
|
|
// invalid struts
|
|
|
|
QTest::newRow("bottom panel/ invalid strut") << QRect(0, 980, 1280, 44)
|
|
|
|
<< 1280 << 0 << 0 << 44
|
|
|
|
<< 980 << 1024
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 1279
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(0, 980, 1279, 44), StrutRect(0, 980, 1280, 44)};
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("top panel/ invalid strut") << QRect(0, 0, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 1280 << 0 << 44 << 0
|
|
|
|
<< 0 << 44
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 1279
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects{StrutRect(0, 0, 1279, 44), StrutRect(0, 0, 1280, 44)};
|
2016-04-11 15:24:08 +00:00
|
|
|
QTest::newRow("top panel/invalid strut 2") << QRect(0, 0, 1280, 44)
|
2022-03-23 10:13:38 +00:00
|
|
|
<< 0 << 0 << 1024 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 0
|
|
|
|
<< 0 << 1279
|
|
|
|
<< 0 << 0
|
2022-07-15 07:38:00 +00:00
|
|
|
<< QRectF(0, 0, 1280, 1024)
|
|
|
|
<< QRectF(1280, 0, 1280, 1024)
|
|
|
|
<< QRectF(0, 0, 2560, 1024)
|
2022-11-02 16:20:37 +00:00
|
|
|
<< StrutRects();
|
2016-04-11 15:24:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StrutsTest::testX11Struts()
|
|
|
|
{
|
|
|
|
// this test verifies that struts are applied correctly for X11 windows
|
|
|
|
|
2021-08-21 17:46:51 +00:00
|
|
|
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
|
2022-07-11 10:41:15 +00:00
|
|
|
const QList<Output *> outputs = workspace()->outputs();
|
2021-08-21 17:46:51 +00:00
|
|
|
|
2016-04-11 15:24:08 +00:00
|
|
|
// no, struts yet
|
|
|
|
// first screen
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MovementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeFullArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullScreenArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(ScreenArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
2016-04-11 15:24:08 +00:00
|
|
|
// second screen
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MovementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeFullArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullScreenArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(ScreenArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
2016-04-11 15:24:08 +00:00
|
|
|
// combined
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
|
2022-11-02 16:20:37 +00:00
|
|
|
QCOMPARE(workspace()->restrictedMoveArea(desktop), StrutRects());
|
2016-04-11 15:24:08 +00:00
|
|
|
|
|
|
|
// create an xcb window
|
2023-02-03 13:29:21 +00:00
|
|
|
Test::XcbConnectionPtr c = Test::createX11Connection();
|
2022-08-01 21:29:02 +00:00
|
|
|
QVERIFY(!xcb_connection_has_error(c.get()));
|
2016-04-11 15:24:08 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_window_t windowId = xcb_generate_id(c.get());
|
2016-04-11 15:24:08 +00:00
|
|
|
QFETCH(QRect, windowGeometry);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
|
2016-04-11 15:24:08 +00:00
|
|
|
windowGeometry.x(),
|
|
|
|
windowGeometry.y(),
|
|
|
|
windowGeometry.width(),
|
|
|
|
windowGeometry.height(),
|
|
|
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
|
|
|
xcb_size_hints_t hints;
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
|
|
|
|
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
|
|
|
|
NETWinInfo info(c.get(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
|
2016-04-11 15:24:08 +00:00
|
|
|
info.setWindowType(NET::Dock);
|
|
|
|
// set the extended strut
|
|
|
|
QFETCH(int, leftStrut);
|
|
|
|
QFETCH(int, rightStrut);
|
|
|
|
QFETCH(int, topStrut);
|
|
|
|
QFETCH(int, bottomStrut);
|
|
|
|
QFETCH(int, leftStrutStart);
|
|
|
|
QFETCH(int, leftStrutEnd);
|
|
|
|
QFETCH(int, rightStrutStart);
|
|
|
|
QFETCH(int, rightStrutEnd);
|
|
|
|
QFETCH(int, topStrutStart);
|
|
|
|
QFETCH(int, topStrutEnd);
|
|
|
|
QFETCH(int, bottomStrutStart);
|
|
|
|
QFETCH(int, bottomStrutEnd);
|
|
|
|
NETExtendedStrut strut;
|
|
|
|
strut.left_start = leftStrutStart;
|
|
|
|
strut.left_end = leftStrutEnd;
|
|
|
|
strut.left_width = leftStrut;
|
|
|
|
strut.right_start = rightStrutStart;
|
|
|
|
strut.right_end = rightStrutEnd;
|
|
|
|
strut.right_width = rightStrut;
|
|
|
|
strut.top_start = topStrutStart;
|
|
|
|
strut.top_end = topStrutEnd;
|
|
|
|
strut.top_width = topStrut;
|
|
|
|
strut.bottom_start = bottomStrutStart;
|
|
|
|
strut.bottom_end = bottomStrutEnd;
|
|
|
|
strut.bottom_width = bottomStrut;
|
|
|
|
info.setExtendedStrut(strut);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_map_window(c.get(), windowId);
|
|
|
|
xcb_flush(c.get());
|
2016-04-11 15:24:08 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// we should get a window for it
|
2022-04-23 08:33:23 +00:00
|
|
|
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
|
2016-04-11 15:24:08 +00:00
|
|
|
QVERIFY(windowCreatedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->window(), windowId);
|
|
|
|
QVERIFY(!window->isDecorated());
|
|
|
|
QCOMPARE(window->windowType(), NET::Dock);
|
|
|
|
QCOMPARE(window->frameGeometry(), windowGeometry);
|
2016-04-11 15:24:08 +00:00
|
|
|
|
|
|
|
// this should have affected the client area
|
|
|
|
// some props are independent of struts - those first
|
|
|
|
// screen 0
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(MovementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeFullArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullScreenArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(ScreenArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
2016-04-11 15:24:08 +00:00
|
|
|
// screen 1
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(MovementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeFullArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullScreenArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(ScreenArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
2016-04-11 15:24:08 +00:00
|
|
|
// combined
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
|
2016-04-11 15:24:08 +00:00
|
|
|
|
|
|
|
// now verify the actual updated client areas
|
2022-07-15 07:38:00 +00:00
|
|
|
QTEST(workspace()->clientArea(PlacementArea, outputs[0], desktop), "screen0Maximized");
|
|
|
|
QTEST(workspace()->clientArea(MaximizeArea, outputs[0], desktop), "screen0Maximized");
|
|
|
|
QTEST(workspace()->clientArea(PlacementArea, outputs[1], desktop), "screen1Maximized");
|
|
|
|
QTEST(workspace()->clientArea(MaximizeArea, outputs[1], desktop), "screen1Maximized");
|
|
|
|
QTEST(workspace()->clientArea(WorkArea, outputs[0], desktop), "workArea");
|
2021-08-21 17:46:51 +00:00
|
|
|
QTEST(workspace()->restrictedMoveArea(desktop), "restrictedMoveArea");
|
2016-04-11 15:24:08 +00:00
|
|
|
|
|
|
|
// and destroy the window again
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_unmap_window(c.get(), windowId);
|
|
|
|
xcb_destroy_window(c.get(), windowId);
|
|
|
|
xcb_flush(c.get());
|
2016-04-11 15:24:08 +00:00
|
|
|
c.reset();
|
|
|
|
|
2023-03-13 19:21:11 +00:00
|
|
|
QSignalSpy windowClosedSpy(window, &X11Window::closed);
|
2016-04-11 15:24:08 +00:00
|
|
|
QVERIFY(windowClosedSpy.wait());
|
|
|
|
|
|
|
|
// now struts should be removed again
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MovementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeFullArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullScreenArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(ScreenArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
|
2016-04-11 15:24:08 +00:00
|
|
|
// second screen
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MovementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeFullArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullScreenArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(ScreenArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
|
2016-04-11 15:24:08 +00:00
|
|
|
// combined
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
|
|
|
|
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
|
2022-11-02 16:20:37 +00:00
|
|
|
QCOMPARE(workspace()->restrictedMoveArea(desktop), StrutRects());
|
2016-04-11 15:24:08 +00:00
|
|
|
}
|
|
|
|
|
2016-06-02 07:29:53 +00:00
|
|
|
void StrutsTest::test363804()
|
|
|
|
{
|
|
|
|
// this test verifies the condition described in BUG 363804
|
|
|
|
// two screens in a vertical setup, aligned to right border with panel on the bottom screen
|
|
|
|
const QVector<QRect> geometries{QRect(0, 0, 1920, 1080), QRect(554, 1080, 1366, 768)};
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig(geometries);
|
2022-07-11 12:20:35 +00:00
|
|
|
QCOMPARE(workspace()->geometry(), QRect(0, 0, 1920, 1848));
|
2016-06-02 07:29:53 +00:00
|
|
|
|
2021-08-25 15:12:50 +00:00
|
|
|
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
|
2022-07-11 10:41:15 +00:00
|
|
|
const QList<Output *> outputs = workspace()->outputs();
|
2021-08-31 07:03:05 +00:00
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), geometries[0]);
|
|
|
|
QCOMPARE(outputs[1]->geometry(), geometries[1]);
|
2021-08-25 15:12:50 +00:00
|
|
|
|
2016-06-02 07:29:53 +00:00
|
|
|
// create an xcb window
|
2023-02-03 13:29:21 +00:00
|
|
|
Test::XcbConnectionPtr c = Test::createX11Connection();
|
2022-08-01 21:29:02 +00:00
|
|
|
QVERIFY(!xcb_connection_has_error(c.get()));
|
2016-06-02 07:29:53 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_window_t windowId = xcb_generate_id(c.get());
|
2016-06-02 07:29:53 +00:00
|
|
|
const QRect windowGeometry(554, 1812, 1366, 36);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
|
2016-06-02 07:29:53 +00:00
|
|
|
windowGeometry.x(),
|
|
|
|
windowGeometry.y(),
|
|
|
|
windowGeometry.width(),
|
|
|
|
windowGeometry.height(),
|
|
|
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
|
|
|
xcb_size_hints_t hints;
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
|
|
|
|
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
|
|
|
|
NETWinInfo info(c.get(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
|
2016-06-02 07:29:53 +00:00
|
|
|
info.setWindowType(NET::Dock);
|
|
|
|
NETExtendedStrut strut;
|
|
|
|
strut.left_start = 0;
|
|
|
|
strut.left_end = 0;
|
|
|
|
strut.left_width = 0;
|
|
|
|
strut.right_start = 0;
|
|
|
|
strut.right_end = 0;
|
|
|
|
strut.right_width = 0;
|
|
|
|
strut.top_start = 0;
|
|
|
|
strut.top_end = 0;
|
|
|
|
strut.top_width = 0;
|
|
|
|
strut.bottom_start = 554;
|
|
|
|
strut.bottom_end = 1919;
|
|
|
|
strut.bottom_width = 36;
|
|
|
|
info.setExtendedStrut(strut);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_map_window(c.get(), windowId);
|
|
|
|
xcb_flush(c.get());
|
2016-06-02 07:29:53 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// we should get a window for it
|
2022-04-23 08:33:23 +00:00
|
|
|
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
|
2016-06-02 07:29:53 +00:00
|
|
|
QVERIFY(windowCreatedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->window(), windowId);
|
|
|
|
QVERIFY(!window->isDecorated());
|
|
|
|
QCOMPARE(window->windowType(), NET::Dock);
|
|
|
|
QCOMPARE(window->frameGeometry(), windowGeometry);
|
2016-06-02 07:29:53 +00:00
|
|
|
|
|
|
|
// now verify the actual updated client areas
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), geometries.at(0));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), geometries.at(0));
|
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(554, 1080, 1366, 732));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(554, 1080, 1366, 732));
|
|
|
|
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 1920, 1812));
|
2016-06-02 07:29:53 +00:00
|
|
|
|
|
|
|
// and destroy the window again
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_unmap_window(c.get(), windowId);
|
|
|
|
xcb_destroy_window(c.get(), windowId);
|
|
|
|
xcb_flush(c.get());
|
2016-06-02 07:29:53 +00:00
|
|
|
c.reset();
|
|
|
|
|
2023-03-13 19:21:11 +00:00
|
|
|
QSignalSpy windowClosedSpy(window, &X11Window::closed);
|
2016-06-02 07:29:53 +00:00
|
|
|
QVERIFY(windowClosedSpy.wait());
|
|
|
|
}
|
|
|
|
|
2016-07-13 05:59:18 +00:00
|
|
|
void StrutsTest::testLeftScreenSmallerBottomAligned()
|
|
|
|
{
|
|
|
|
// this test verifies a two screen setup with the left screen smaller than the right and bottom aligned
|
|
|
|
// the panel is on the top of the left screen, thus not at 0/0
|
|
|
|
const QVector<QRect> geometries{QRect(0, 282, 1366, 768), QRect(1366, 0, 1680, 1050)};
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig(geometries);
|
2022-07-11 12:20:35 +00:00
|
|
|
QCOMPARE(workspace()->geometry(), QRect(0, 0, 3046, 1050));
|
2016-07-13 05:59:18 +00:00
|
|
|
|
2022-07-11 10:41:15 +00:00
|
|
|
const QList<Output *> outputs = workspace()->outputs();
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(outputs[0]->geometry(), geometries.at(0));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), geometries.at(1));
|
|
|
|
|
|
|
|
// the test window will be on the current desktop
|
|
|
|
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
|
|
|
|
|
2016-07-13 05:59:18 +00:00
|
|
|
// create the panel
|
2023-02-03 13:29:21 +00:00
|
|
|
Test::XcbConnectionPtr c = Test::createX11Connection();
|
2022-08-01 21:29:02 +00:00
|
|
|
QVERIFY(!xcb_connection_has_error(c.get()));
|
2016-07-13 05:59:18 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_window_t windowId = xcb_generate_id(c.get());
|
2016-07-13 05:59:18 +00:00
|
|
|
const QRect windowGeometry(0, 282, 1366, 24);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
|
2016-07-13 05:59:18 +00:00
|
|
|
windowGeometry.x(),
|
|
|
|
windowGeometry.y(),
|
|
|
|
windowGeometry.width(),
|
|
|
|
windowGeometry.height(),
|
|
|
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
|
|
|
xcb_size_hints_t hints;
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
|
|
|
|
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
|
|
|
|
NETWinInfo info(c.get(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
|
2016-07-13 05:59:18 +00:00
|
|
|
info.setWindowType(NET::Dock);
|
|
|
|
NETExtendedStrut strut;
|
|
|
|
strut.left_start = 0;
|
|
|
|
strut.left_end = 0;
|
|
|
|
strut.left_width = 0;
|
|
|
|
strut.right_start = 0;
|
|
|
|
strut.right_end = 0;
|
|
|
|
strut.right_width = 0;
|
|
|
|
strut.top_start = 0;
|
|
|
|
strut.top_end = 1365;
|
|
|
|
strut.top_width = 306;
|
|
|
|
strut.bottom_start = 0;
|
|
|
|
strut.bottom_end = 0;
|
|
|
|
strut.bottom_width = 0;
|
|
|
|
info.setExtendedStrut(strut);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_map_window(c.get(), windowId);
|
|
|
|
xcb_flush(c.get());
|
2016-07-13 05:59:18 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// we should get a window for it
|
2022-04-23 08:33:23 +00:00
|
|
|
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
|
2016-07-13 05:59:18 +00:00
|
|
|
QVERIFY(windowCreatedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->window(), windowId);
|
|
|
|
QVERIFY(!window->isDecorated());
|
|
|
|
QCOMPARE(window->windowType(), NET::Dock);
|
|
|
|
QCOMPARE(window->frameGeometry(), windowGeometry);
|
2016-07-13 05:59:18 +00:00
|
|
|
|
|
|
|
// now verify the actual updated client areas
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 306, 1366, 744));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 306, 1366, 744));
|
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), geometries.at(1));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), geometries.at(1));
|
|
|
|
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 3046, 1050));
|
2016-07-13 05:59:18 +00:00
|
|
|
|
|
|
|
// and destroy the window again
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_unmap_window(c.get(), windowId);
|
|
|
|
xcb_destroy_window(c.get(), windowId);
|
|
|
|
xcb_flush(c.get());
|
2016-07-13 05:59:18 +00:00
|
|
|
c.reset();
|
|
|
|
|
2023-03-13 19:21:11 +00:00
|
|
|
QSignalSpy windowClosedSpy(window, &X11Window::closed);
|
2016-07-13 05:59:18 +00:00
|
|
|
QVERIFY(windowClosedSpy.wait());
|
|
|
|
}
|
|
|
|
|
2017-07-08 06:41:16 +00:00
|
|
|
void StrutsTest::testWindowMoveWithPanelBetweenScreens()
|
|
|
|
{
|
|
|
|
// this test verifies the condition of BUG
|
|
|
|
// when moving a window with decorations in a restricted way it should pass from one screen
|
|
|
|
// to the other even if there is a panel in between.
|
|
|
|
|
|
|
|
// left screen must be smaller than right screen
|
|
|
|
const QVector<QRect> geometries{QRect(0, 282, 1366, 768), QRect(1366, 0, 1680, 1050)};
|
2023-05-08 10:16:00 +00:00
|
|
|
Test::setOutputConfig(geometries);
|
2022-07-11 12:20:35 +00:00
|
|
|
QCOMPARE(workspace()->geometry(), QRect(0, 0, 3046, 1050));
|
2017-07-08 06:41:16 +00:00
|
|
|
|
2022-07-11 10:41:15 +00:00
|
|
|
const QList<Output *> outputs = workspace()->outputs();
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(outputs[0]->geometry(), geometries.at(0));
|
|
|
|
QCOMPARE(outputs[1]->geometry(), geometries.at(1));
|
|
|
|
|
|
|
|
// all windows will be placed on the current desktop
|
|
|
|
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
|
|
|
|
|
2017-07-08 06:41:16 +00:00
|
|
|
// create the panel on the right screen, left edge
|
2023-02-03 13:29:21 +00:00
|
|
|
Test::XcbConnectionPtr c = Test::createX11Connection();
|
2022-08-01 21:29:02 +00:00
|
|
|
QVERIFY(!xcb_connection_has_error(c.get()));
|
2017-07-08 06:41:16 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_window_t windowId = xcb_generate_id(c.get());
|
2017-07-08 06:41:16 +00:00
|
|
|
const QRect windowGeometry(1366, 0, 24, 1050);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
|
2017-07-08 06:41:16 +00:00
|
|
|
windowGeometry.x(),
|
|
|
|
windowGeometry.y(),
|
|
|
|
windowGeometry.width(),
|
|
|
|
windowGeometry.height(),
|
|
|
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
|
|
|
xcb_size_hints_t hints;
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
|
|
|
|
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
|
|
|
|
NETWinInfo info(c.get(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
|
2017-07-08 06:41:16 +00:00
|
|
|
info.setWindowType(NET::Dock);
|
|
|
|
NETExtendedStrut strut;
|
|
|
|
strut.left_start = 0;
|
|
|
|
strut.left_end = 1050;
|
2022-03-23 10:13:38 +00:00
|
|
|
strut.left_width = 1366 + 24;
|
2017-07-08 06:41:16 +00:00
|
|
|
strut.right_start = 0;
|
|
|
|
strut.right_end = 0;
|
|
|
|
strut.right_width = 0;
|
|
|
|
strut.top_start = 0;
|
|
|
|
strut.top_end = 0;
|
|
|
|
strut.top_width = 0;
|
|
|
|
strut.bottom_start = 0;
|
|
|
|
strut.bottom_end = 0;
|
|
|
|
strut.bottom_width = 0;
|
|
|
|
info.setExtendedStrut(strut);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_map_window(c.get(), windowId);
|
|
|
|
xcb_flush(c.get());
|
2017-07-08 06:41:16 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// we should get a window for it
|
2022-04-23 08:33:23 +00:00
|
|
|
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
|
2017-07-08 06:41:16 +00:00
|
|
|
QVERIFY(windowCreatedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->window(), windowId);
|
|
|
|
QVERIFY(!window->isDecorated());
|
|
|
|
QCOMPARE(window->windowType(), NET::Dock);
|
|
|
|
QCOMPARE(window->frameGeometry(), windowGeometry);
|
2017-07-08 06:41:16 +00:00
|
|
|
|
|
|
|
// now verify the actual updated client areas
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 282, 1366, 768));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 282, 1366, 768));
|
|
|
|
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1390, 0, 1656, 1050));
|
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1390, 0, 1656, 1050));
|
|
|
|
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 3046, 1050));
|
2022-11-02 16:20:37 +00:00
|
|
|
QCOMPARE(workspace()->restrictedMoveArea(desktop), StrutRects{StrutRect(1366, 0, 24, 1050)});
|
2017-07-08 06:41:16 +00:00
|
|
|
|
|
|
|
// create another window and try to move it
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_window_t w2 = xcb_generate_id(c.get());
|
2017-07-08 06:41:16 +00:00
|
|
|
const QRect windowGeometry2(1500, 400, 200, 300);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, w2, rootWindow(),
|
2017-07-08 06:41:16 +00:00
|
|
|
windowGeometry2.x(),
|
|
|
|
windowGeometry2.y(),
|
|
|
|
windowGeometry2.width(),
|
|
|
|
windowGeometry2.height(),
|
|
|
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
|
|
|
xcb_size_hints_t hints2;
|
|
|
|
memset(&hints2, 0, sizeof(hints2));
|
|
|
|
xcb_icccm_size_hints_set_position(&hints2, 1, windowGeometry2.x(), windowGeometry2.y());
|
|
|
|
xcb_icccm_size_hints_set_min_size(&hints2, 200, 300);
|
2022-08-01 21:29:02 +00:00
|
|
|
xcb_icccm_set_wm_normal_hints(c.get(), w2, &hints2);
|
|
|
|
xcb_map_window(c.get(), w2);
|
|
|
|
xcb_flush(c.get());
|
2017-07-08 06:41:16 +00:00
|
|
|
QVERIFY(windowCreatedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
X11Window *window2 = windowCreatedSpy.last().first().value<X11Window *>();
|
|
|
|
QVERIFY(window2);
|
|
|
|
QVERIFY(window2 != window);
|
|
|
|
QVERIFY(window2->isDecorated());
|
|
|
|
QCOMPARE(window2->clientSize(), QSize(200, 300));
|
|
|
|
QCOMPARE(window2->pos(), QPoint(1500, 400));
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
const QRectF origGeo = window2->frameGeometry();
|
2023-02-09 13:07:56 +00:00
|
|
|
input()->pointer()->warp(origGeo.center());
|
2022-04-23 19:51:16 +00:00
|
|
|
workspace()->performWindowOperation(window2, Options::MoveOp);
|
|
|
|
QTRY_COMPARE(workspace()->moveResizeWindow(), window2);
|
|
|
|
QVERIFY(window2->isInteractiveMove());
|
2017-07-08 06:41:16 +00:00
|
|
|
// move to next screen - step is 8 pixel, so 800 pixel
|
|
|
|
for (int i = 0; i < 100; i++) {
|
2022-04-23 19:51:16 +00:00
|
|
|
window2->keyPressEvent(Qt::Key_Left);
|
2017-07-08 06:41:16 +00:00
|
|
|
}
|
2022-04-23 19:51:16 +00:00
|
|
|
window2->keyPressEvent(Qt::Key_Enter);
|
|
|
|
QCOMPARE(window2->isInteractiveMove(), false);
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(workspace()->moveResizeWindow() == nullptr);
|
2022-05-16 20:13:39 +00:00
|
|
|
QCOMPARE(window2->frameGeometry(), QRectF(origGeo.translated(-800, 0)));
|
2017-07-08 06:41:16 +00:00
|
|
|
}
|
|
|
|
|
2016-04-11 15:24:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WAYLANDTEST_MAIN(KWin::StrutsTest)
|
|
|
|
#include "struts_test.moc"
|