kwin/autotests/integration/struts_test.cpp

1007 lines
52 KiB
C++
Raw Normal View History

2020-08-02 22:22:19 +00:00
/*
KWin - the KDE window manager
This file is part of the KDE project.
2020-08-02 22:22:19 +00:00
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
2020-08-02 22:22:19 +00:00
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "cursor.h"
#include "deleted.h"
#include "output.h"
#include "platform.h"
#include "screenedge.h"
#include "screens.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <kwineffects.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/surface.h>
#include <KDecoration2/Decoration>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
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 testWaylandStruts_data();
void testWaylandStruts();
void testMoveWaylandPanel();
void testWaylandMobilePanel();
void testX11Struts_data();
void testX11Struts();
void test363804();
void testLeftScreenSmallerBottomAligned();
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
void testWindowMoveWithPanelBetweenScreens();
private:
KWayland::Client::Compositor *m_compositor = nullptr;
KWayland::Client::PlasmaShell *m_plasmaShell = nullptr;
};
void StrutsTest::initTestCase()
{
2022-04-22 17:39:12 +00:00
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
// 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);
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
Test::initWaylandWorkspace();
}
void StrutsTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::PlasmaShell));
m_compositor = Test::waylandCompositor();
m_plasmaShell = Test::waylandPlasmaShell();
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
QVERIFY(waylandServer()->windows().isEmpty());
}
void StrutsTest::cleanup()
{
Test::destroyWaylandConnection();
}
void StrutsTest::testWaylandStruts_data()
{
QTest::addColumn<QVector<QRect>>("windowGeometries");
QTest::addColumn<QRect>("screen0Maximized");
QTest::addColumn<QRect>("screen1Maximized");
QTest::addColumn<QRect>("workArea");
QTest::addColumn<QRegion>("restrictedMoveArea");
QTest::newRow("bottom/0") << QVector<QRect>{QRect(0, 992, 1280, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(0, 992, 1280, 32);
QTest::newRow("bottom/1") << QVector<QRect>{QRect(1280, 992, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1280, 992, 1280, 32);
QTest::newRow("top/0") << QVector<QRect>{QRect(0, 0, 1280, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(0, 0, 1280, 32);
QTest::newRow("top/1") << QVector<QRect>{QRect(1280, 0, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1280, 0, 1280, 32);
QTest::newRow("left/0") << QVector<QRect>{QRect(0, 0, 32, 1024)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 0, 32, 1024);
QTest::newRow("left/1") << QVector<QRect>{QRect(1280, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 0, 32, 1024);
QTest::newRow("right/0") << QVector<QRect>{QRect(1248, 0, 32, 1024)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 0, 32, 1024);
QTest::newRow("right/1") << QVector<QRect>{QRect(2528, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 0, 32, 1024);
// same with partial panels not covering the whole area
QTest::newRow("part bottom/0") << QVector<QRect>{QRect(100, 992, 1080, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(100, 992, 1080, 32);
QTest::newRow("part bottom/1") << QVector<QRect>{QRect(1380, 992, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1380, 992, 1080, 32);
QTest::newRow("part top/0") << QVector<QRect>{QRect(100, 0, 1080, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(100, 0, 1080, 32);
QTest::newRow("part top/1") << QVector<QRect>{QRect(1380, 0, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1380, 0, 1080, 32);
QTest::newRow("part left/0") << QVector<QRect>{QRect(0, 100, 32, 824)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 100, 32, 824);
QTest::newRow("part left/1") << QVector<QRect>{QRect(1280, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 100, 32, 824);
QTest::newRow("part right/0") << QVector<QRect>{QRect(1248, 100, 32, 824)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 100, 32, 824);
QTest::newRow("part right/1") << QVector<QRect>{QRect(2528, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 100, 32, 824);
// multiple panels
QTest::newRow("two bottom panels") << QVector<QRect>{QRect(100, 992, 1080, 32), QRect(1380, 984, 1080, 40)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 984) << QRect(0, 0, 2560, 984) << QRegion(100, 992, 1080, 32).united(QRegion(1380, 984, 1080, 40));
QTest::newRow("two left panels") << QVector<QRect>{QRect(0, 10, 32, 390), QRect(0, 450, 40, 100)} << QRect(40, 0, 1240, 1024) << QRect(1280, 0, 1280, 1024) << QRect(40, 0, 2520, 1024) << QRegion(0, 10, 32, 390).united(QRegion(0, 450, 40, 100));
}
void StrutsTest::testWaylandStruts()
{
// this test verifies that struts on Wayland panels are handled correctly
using namespace KWayland::Client;
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
// no, struts yet
QVERIFY(waylandServer()->windows().isEmpty());
// first screen
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));
// second screen
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));
// combined
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
QCOMPARE(workspace()->restrictedMoveArea(desktop), QRegion());
QFETCH(QVector<QRect>, windowGeometries);
// create the panels
2022-04-23 19:51:16 +00:00
QHash<KWayland::Client::Surface *, Window *> windows;
for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) {
const QRect windowGeometry = *it;
KWayland::Client::Surface *surface = Test::createSurface(m_compositor);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface, Test::CreationSetup::CreateOnly, surface);
PlasmaShellSurface *plasmaSurface = m_plasmaShell->createSurface(surface, surface);
plasmaSurface->setPosition(windowGeometry.topLeft());
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
QSignalSpy configureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
QVERIFY(configureRequestedSpy.isValid());
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(configureRequestedSpy.wait());
// map the window
shellSurface->xdgSurface()->ack_configure(configureRequestedSpy.last().first().toUInt());
2022-04-23 19:51:16 +00:00
auto window = Test::renderAndWaitForShown(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32);
QVERIFY(window);
QVERIFY(!window->isActive());
QCOMPARE(window->frameGeometry(), windowGeometry);
QVERIFY(window->isDock());
QVERIFY(window->hasStrut());
windows.insert(surface, window);
}
// some props are independent of struts - those first
// screen 0
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));
// screen 1
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));
// combined
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
// now verify the actual updated client areas
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");
QTEST(workspace()->restrictedMoveArea(desktop), "restrictedMoveArea");
// delete all surfaces
2022-04-23 19:51:16 +00:00
for (auto it = windows.begin(); it != windows.end(); it++) {
QSignalSpy destroyedSpy(it.value(), &QObject::destroyed);
QVERIFY(destroyedSpy.isValid());
delete it.key();
QVERIFY(destroyedSpy.wait());
}
QCOMPARE(workspace()->restrictedMoveArea(desktop), QRegion());
}
void StrutsTest::testMoveWaylandPanel()
{
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
// this test verifies that repositioning a Wayland panel updates the client area
using namespace KWayland::Client;
const QRect windowGeometry(0, 1000, 1280, 24);
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data(), Test::CreationSetup::CreateOnly));
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
plasmaSurface->setPosition(windowGeometry.topLeft());
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
QSignalSpy configureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
QVERIFY(configureRequestedSpy.isValid());
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(configureRequestedSpy.wait());
// map the window
shellSurface->xdgSurface()->ack_configure(configureRequestedSpy.last().first().toUInt());
2022-04-23 19:51:16 +00:00
auto window = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
QVERIFY(window);
QVERIFY(!window->isActive());
QCOMPARE(window->frameGeometry(), windowGeometry);
QVERIFY(window->isDock());
QVERIFY(window->hasStrut());
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1000));
2022-04-23 19:51:16 +00:00
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
QVERIFY(frameGeometryChangedSpy.isValid());
plasmaSurface->setPosition(QPoint(1280, 1000));
QVERIFY(frameGeometryChangedSpy.wait());
2022-04-23 19:51:16 +00:00
QCOMPARE(window->frameGeometry(), QRect(1280, 1000, 1280, 24));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1000));
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1000));
}
void StrutsTest::testWaylandMobilePanel()
{
using namespace KWayland::Client;
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
// First enable maxmizing policy
KConfigGroup group = kwinApp()->config()->group("Windows");
group.writeEntry("Placement", "Maximizing");
group.sync();
workspace()->slotReconfigure();
// create first top panel
const QRect windowGeometry(0, 0, 1280, 60);
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data(), Test::CreationSetup::CreateOnly));
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
plasmaSurface->setPosition(windowGeometry.topLeft());
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
QSignalSpy configureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
QVERIFY(configureRequestedSpy.isValid());
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(configureRequestedSpy.wait());
// map the window
shellSurface->xdgSurface()->ack_configure(configureRequestedSpy.last().first().toUInt());
2022-04-23 19:51:16 +00:00
auto window = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
QVERIFY(window);
QVERIFY(!window->isActive());
QCOMPARE(window->frameGeometry(), windowGeometry);
QVERIFY(window->isDock());
QVERIFY(window->hasStrut());
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 60, 1280, 964));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 60, 1280, 964));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 60, 2560, 964));
// create another bottom panel
const QRect windowGeometry2(0, 874, 1280, 150);
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data(), Test::CreationSetup::CreateOnly));
QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data()));
plasmaSurface2->setPosition(windowGeometry2.topLeft());
plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel);
QSignalSpy configureRequestedSpy2(shellSurface2->xdgSurface(), &Test::XdgSurface::configureRequested);
QVERIFY(configureRequestedSpy2.isValid());
surface2->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(configureRequestedSpy2.wait());
// map the window
shellSurface2->xdgSurface()->ack_configure(configureRequestedSpy2.last().first().toUInt());
auto c1 = Test::renderAndWaitForShown(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32);
QVERIFY(c1);
QVERIFY(!c1->isActive());
QCOMPARE(c1->frameGeometry(), windowGeometry2);
QVERIFY(c1->isDock());
QVERIFY(c1->hasStrut());
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 60, 1280, 814));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 60, 1280, 814));
QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024));
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 60, 2560, 814));
2022-04-23 19:51:16 +00:00
// Destroy test windows.
shellSurface.reset();
2022-04-23 19:51:16 +00:00
QVERIFY(Test::waitForWindowDestroyed(window));
shellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(c1));
}
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");
QTest::addColumn<QRect>("screen0Maximized");
QTest::addColumn<QRect>("screen1Maximized");
QTest::addColumn<QRect>("workArea");
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
QTest::addColumn<QRegion>("restrictedMoveArea");
QTest::newRow("bottom panel/no strut") << QRect(0, 980, 1280, 44)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("bottom panel/strut") << QRect(0, 980, 1280, 44)
<< 0 << 0 << 0 << 44
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< QRect(0, 0, 1280, 980)
<< QRect(1280, 0, 1280, 1024)
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
<< QRect(0, 0, 2560, 980)
<< QRegion(0, 980, 1279, 44);
QTest::newRow("top panel/no strut") << QRect(0, 0, 1280, 44)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("top panel/strut") << QRect(0, 0, 1280, 44)
<< 0 << 0 << 44 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 44, 1280, 980)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 44, 2560, 980)
<< QRegion(0, 0, 1279, 44);
QTest::newRow("left panel/no strut") << QRect(0, 0, 60, 1024)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("left panel/strut") << QRect(0, 0, 60, 1024)
<< 60 << 0 << 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(60, 0, 1220, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(60, 0, 2500, 1024)
<< QRegion(0, 0, 60, 1023);
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
QTest::newRow("right panel/no strut") << QRect(1220, 0, 60, 1024)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
QTest::newRow("right panel/strut") << QRect(1220, 0, 60, 1024)
<< 0 << 1340 << 0 << 0
<< 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1220, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(1220, 0, 60, 1023);
// second screen
QTest::newRow("bottom panel 1/no strut") << QRect(1280, 980, 1280, 44)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("bottom panel 1/strut") << QRect(1280, 980, 1280, 44)
<< 0 << 0 << 0 << 44
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 1280 << 2559
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 980)
<< QRect(0, 0, 2560, 980)
<< QRegion(1280, 980, 1279, 44);
QTest::newRow("top panel 1/no strut") << QRect(1280, 0, 1280, 44)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("top panel 1 /strut") << QRect(1280, 0, 1280, 44)
<< 0 << 0 << 44 << 0
<< 0 << 0
<< 0 << 0
<< 1280 << 2559
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 44, 1280, 980)
<< QRect(0, 44, 2560, 980)
<< QRegion(1280, 0, 1279, 44);
QTest::newRow("left panel 1/no strut") << QRect(1280, 0, 60, 1024)
<< 0 << 0 << 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
<< QRect(0, 0, 2560, 1024)
<< QRegion();
QTest::newRow("left panel 1/strut") << QRect(1280, 0, 60, 1024)
<< 1340 << 0 << 0 << 0
<< 0 << 1023
<< 0 << 0
<< 0 << 0
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1340, 0, 1220, 1024)
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
<< QRect(0, 0, 2560, 1024)
<< QRegion(1280, 0, 60, 1023);
// 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
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(0, 980, 1280, 44);
QTest::newRow("top panel/ invalid strut") << QRect(0, 0, 1280, 44)
<< 1280 << 0 << 44 << 0
<< 0 << 44
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion(0, 0, 1280, 44);
QTest::newRow("top panel/invalid strut 2") << QRect(0, 0, 1280, 44)
<< 0 << 0 << 1024 << 0
<< 0 << 0
<< 0 << 0
<< 0 << 1279
<< 0 << 0
<< QRect(0, 0, 1280, 1024)
<< QRect(1280, 0, 1280, 1024)
<< QRect(0, 0, 2560, 1024)
<< QRegion();
}
struct XcbConnectionDeleter
{
static inline void cleanup(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void StrutsTest::testX11Struts()
{
// this test verifies that struts are applied correctly for X11 windows
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
// no, struts yet
// first screen
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));
// second screen
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));
// combined
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
QCOMPARE(workspace()->restrictedMoveArea(desktop), QRegion());
// create an xcb window
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id(c.data());
QFETCH(QRect, windowGeometry);
2022-04-23 19:51:16 +00:00
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
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-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints(c.data(), windowId, &hints);
NETWinInfo info(c.data(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
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-04-23 19:51:16 +00:00
xcb_map_window(c.data(), windowId);
xcb_flush(c.data());
2022-04-23 19:51:16 +00:00
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.isValid());
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);
// this should have affected the client area
// some props are independent of struts - those first
// screen 0
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));
// screen 1
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));
// combined
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
// now verify the actual updated client areas
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");
QTEST(workspace()->restrictedMoveArea(desktop), "restrictedMoveArea");
// and destroy the window again
2022-04-23 19:51:16 +00:00
xcb_unmap_window(c.data(), windowId);
xcb_destroy_window(c.data(), windowId);
xcb_flush(c.data());
c.reset();
2022-04-23 19:51:16 +00:00
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
// now struts should be removed again
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));
// second screen
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));
// combined
QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
QCOMPARE(workspace()->clientArea(FullArea, outputs[0], desktop), QRect(0, 0, 2560, 1024));
QCOMPARE(workspace()->restrictedMoveArea(desktop), QRegion());
}
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)};
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, 2),
Q_ARG(QVector<QRect>, geometries));
QCOMPARE(screens()->geometry(), QRect(0, 0, 1920, 1848));
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), geometries[0]);
QCOMPARE(outputs[1]->geometry(), geometries[1]);
// create an xcb window
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id(c.data());
const QRect windowGeometry(554, 1812, 1366, 36);
2022-04-23 19:51:16 +00:00
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
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-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints(c.data(), windowId, &hints);
NETWinInfo info(c.data(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
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-04-23 19:51:16 +00:00
xcb_map_window(c.data(), windowId);
xcb_flush(c.data());
2022-04-23 19:51:16 +00:00
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.isValid());
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);
// now verify the actual updated client areas
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));
// and destroy the window again
2022-04-23 19:51:16 +00:00
xcb_unmap_window(c.data(), windowId);
xcb_destroy_window(c.data(), windowId);
xcb_flush(c.data());
c.reset();
2022-04-23 19:51:16 +00:00
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
}
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
// what this test in addition tests is whether a window larger than the left screen is not placed into
// the dead area
const QVector<QRect> geometries{QRect(0, 282, 1366, 768), QRect(1366, 0, 1680, 1050)};
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, 2),
Q_ARG(QVector<QRect>, geometries));
QCOMPARE(screens()->geometry(), QRect(0, 0, 3046, 1050));
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
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();
// create the panel
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id(c.data());
const QRect windowGeometry(0, 282, 1366, 24);
2022-04-23 19:51:16 +00:00
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
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-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints(c.data(), windowId, &hints);
NETWinInfo info(c.data(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
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-04-23 19:51:16 +00:00
xcb_map_window(c.data(), windowId);
xcb_flush(c.data());
2022-04-23 19:51:16 +00:00
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.isValid());
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);
// now verify the actual updated client areas
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));
// now create a window which is larger than screen 0
xcb_window_t w2 = xcb_generate_id(c.data());
const QRect windowGeometry2(0, 26, 1280, 774);
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w2, rootWindow(),
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_min_size(&hints2, 868, 431);
xcb_icccm_set_wm_normal_hints(c.data(), w2, &hints2);
xcb_map_window(c.data(), w2);
xcb_flush(c.data());
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->frameGeometry(), QRect(0, 306, 1366, 744));
QCOMPARE(window2->maximizeMode(), KWin::MaximizeFull);
// destroy window again
2022-04-23 19:51:16 +00:00
QSignalSpy normalWindowClosedSpy(window2, &X11Window::windowClosed);
QVERIFY(normalWindowClosedSpy.isValid());
xcb_unmap_window(c.data(), w2);
xcb_destroy_window(c.data(), w2);
xcb_flush(c.data());
QVERIFY(normalWindowClosedSpy.wait());
// and destroy the window again
2022-04-23 19:51:16 +00:00
xcb_unmap_window(c.data(), windowId);
xcb_destroy_window(c.data(), windowId);
xcb_flush(c.data());
c.reset();
2022-04-23 19:51:16 +00:00
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
}
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
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)};
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs",
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
Qt::DirectConnection,
Q_ARG(int, 2),
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
Q_ARG(QVector<QRect>, geometries));
QCOMPARE(screens()->geometry(), QRect(0, 0, 3046, 1050));
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
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();
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
// create the panel on the right screen, left edge
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
2022-04-23 19:51:16 +00:00
xcb_window_t windowId = xcb_generate_id(c.data());
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
const QRect windowGeometry(1366, 0, 24, 1050);
2022-04-23 19:51:16 +00:00
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
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-04-23 19:51:16 +00:00
xcb_icccm_set_wm_normal_hints(c.data(), windowId, &hints);
NETWinInfo info(c.data(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
info.setWindowType(NET::Dock);
NETExtendedStrut strut;
strut.left_start = 0;
strut.left_end = 1050;
strut.left_width = 1366 + 24;
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
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-04-23 19:51:16 +00:00
xcb_map_window(c.data(), windowId);
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
xcb_flush(c.data());
2022-04-23 19:51:16 +00:00
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
QVERIFY(windowCreatedSpy.isValid());
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);
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
// now verify the actual updated client areas
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));
QCOMPARE(workspace()->restrictedMoveArea(desktop), QRegion(1366, 0, 24, 1050));
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
// create another window and try to move it
xcb_window_t w2 = xcb_generate_id(c.data());
const QRect windowGeometry2(1500, 400, 200, 300);
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w2, rootWindow(),
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);
xcb_icccm_set_wm_normal_hints(c.data(), w2, &hints2);
xcb_map_window(c.data(), w2);
xcb_flush(c.data());
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));
const QRect origGeo = window2->frameGeometry();
Cursors::self()->mouse()->setPos(origGeo.center());
2022-04-23 19:51:16 +00:00
workspace()->performWindowOperation(window2, Options::MoveOp);
QTRY_COMPARE(workspace()->moveResizeWindow(), window2);
QVERIFY(window2->isInteractiveMove());
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
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);
QTest::qWait(50);
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
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);
QVERIFY(workspace()->moveResizeWindow() == nullptr);
2022-04-23 19:51:16 +00:00
QCOMPARE(window2->frameGeometry(), QRect(origGeo.translated(-800, 0)));
Restrict move resize area only on the screen the strut window is on Summary: By allowing panels between screens in 5.8 to have a strut we created a "regression" in KWin. KWin always was wrong, just we didn't notice as neither Plasma nor previously Kicker set a strut on panels between shared screen edges. The strut is created from the edge of the overall screen setup. This means a panel on the left edge of a screen on the right has the strut starting from the left screen. KWin uses the strut to restrict the move resize area: a window decoration is not allowed to go below a strut. Thus it becomes impossible to move the window from the right to the left screen. This change tries to solve this problem by only restricting the move area on the screen the window with the strut is on. E.g. if the window is on the right screen, the left screen is not affected. Thus it's possible again to move a window from one screen to the other as the added test case shows. Unfortunately there are still corner cases where this won't work correctly. If the window is on both screens this won't work. It is also a rather heavy change for KWin and thus it's targeted for master and not for the 5.10 or the 5.8 branch. If we notice that the patch works well and doesn't create further issues, it should be considered for backporting. BUG: 371199 CCBUG: 370510 FIXED-IN: 5.11 Test Plan: Added test case Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D6562
2017-07-08 06:41:16 +00:00
}
}
WAYLANDTEST_MAIN(KWin::StrutsTest)
#include "struts_test.moc"