2020-08-02 22:22:19 +00:00
|
|
|
|
/*
|
|
|
|
|
KWin - the KDE window manager
|
|
|
|
|
This file is part of the KDE project.
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org>
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
2016-06-07 09:43:56 +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"
|
2019-06-11 13:24:24 +00:00
|
|
|
|
#include "decorations/decorationbridge.h"
|
|
|
|
|
#include "decorations/settings.h"
|
2023-02-09 13:07:56 +00:00
|
|
|
|
#include "pointer_input.h"
|
2021-08-12 14:16:08 +00:00
|
|
|
|
#include "virtualdesktops.h"
|
2022-04-22 09:27:33 +00:00
|
|
|
|
#include "wayland/clientconnection.h"
|
|
|
|
|
#include "wayland/display.h"
|
2016-06-07 09:43:56 +00:00
|
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
|
#include "window.h"
|
2016-06-14 11:46:28 +00:00
|
|
|
|
#include "workspace.h"
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2019-06-11 13:24:24 +00:00
|
|
|
|
#include <KDecoration2/DecoratedClient>
|
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
|
#include <KDecoration2/DecorationSettings>
|
2017-12-22 17:23:44 +00:00
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
#include <KWayland/Client/appmenu.h>
|
2016-06-07 09:43:56 +00:00
|
|
|
|
#include <KWayland/Client/compositor.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
|
#include <KWayland/Client/connection_thread.h>
|
2017-08-24 16:57:30 +00:00
|
|
|
|
#include <KWayland/Client/output.h>
|
2020-07-14 11:34:25 +00:00
|
|
|
|
#include <KWayland/Client/pointer.h>
|
|
|
|
|
#include <KWayland/Client/seat.h>
|
2019-10-03 19:43:28 +00:00
|
|
|
|
#include <KWayland/Client/subsurface.h>
|
2016-06-07 09:43:56 +00:00
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
2019-06-11 13:24:24 +00:00
|
|
|
|
#include <QDBusConnection>
|
|
|
|
|
|
2016-11-15 15:48:20 +00:00
|
|
|
|
// system
|
|
|
|
|
#include <sys/socket.h>
|
2022-03-23 10:13:38 +00:00
|
|
|
|
#include <sys/types.h>
|
2016-11-15 15:48:20 +00:00
|
|
|
|
#include <unistd.h>
|
2019-07-09 19:19:26 +00:00
|
|
|
|
|
|
|
|
|
#include <csignal>
|
2016-11-15 15:48:20 +00:00
|
|
|
|
|
2016-06-07 09:43:56 +00:00
|
|
|
|
using namespace KWin;
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_xdgshellwindow-0");
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
class TestXdgShellWindow : public QObject
|
2016-06-07 09:43:56 +00:00
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
|
void initTestCase();
|
|
|
|
|
void init();
|
|
|
|
|
void cleanup();
|
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
|
void testMapUnmap();
|
2017-08-24 16:57:30 +00:00
|
|
|
|
void testWindowOutputs();
|
2016-08-11 15:08:08 +00:00
|
|
|
|
void testMinimizeActiveWindow();
|
2016-09-12 10:03:18 +00:00
|
|
|
|
void testFullscreen_data();
|
|
|
|
|
void testFullscreen();
|
2017-10-07 09:41:17 +00:00
|
|
|
|
void testUserCanSetFullscreen();
|
2022-09-14 07:52:57 +00:00
|
|
|
|
void testSendFullScreenWindowToAnotherOutput();
|
2019-08-27 15:01:14 +00:00
|
|
|
|
|
2020-09-10 10:59:56 +00:00
|
|
|
|
void testMaximizeHorizontal();
|
|
|
|
|
void testMaximizeVertical();
|
|
|
|
|
void testMaximizeFull();
|
2019-08-27 15:01:14 +00:00
|
|
|
|
void testMaximizedToFullscreen_data();
|
|
|
|
|
void testMaximizedToFullscreen();
|
2022-09-14 07:52:57 +00:00
|
|
|
|
void testSendMaximizedWindowToAnotherOutput();
|
2024-03-10 11:42:53 +00:00
|
|
|
|
void testInteractiveMoveUnmaximizeFull();
|
|
|
|
|
void testInteractiveMoveUnmaximizeInitiallyFull();
|
|
|
|
|
void testInteractiveMoveUnmaximizeHorizontal();
|
|
|
|
|
void testInteractiveMoveUnmaximizeVertical();
|
2020-11-23 18:24:37 +00:00
|
|
|
|
void testFullscreenMultipleOutputs();
|
2016-10-11 14:24:10 +00:00
|
|
|
|
void testHidden();
|
2016-10-27 13:59:08 +00:00
|
|
|
|
void testDesktopFileName();
|
2016-10-31 14:50:14 +00:00
|
|
|
|
void testCaptionSimplified();
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
void testUnresponsiveWindow_data();
|
|
|
|
|
void testUnresponsiveWindow();
|
2017-12-22 14:22:24 +00:00
|
|
|
|
void testAppMenu();
|
2018-12-12 17:25:51 +00:00
|
|
|
|
void testSendClientWithTransientToDesktop();
|
2018-12-13 16:47:10 +00:00
|
|
|
|
void testMinimizeWindowWithTransients();
|
2019-01-01 17:37:18 +00:00
|
|
|
|
void testXdgDecoration_data();
|
|
|
|
|
void testXdgDecoration();
|
2019-02-26 13:41:07 +00:00
|
|
|
|
void testXdgNeverCommitted();
|
|
|
|
|
void testXdgInitialState();
|
|
|
|
|
void testXdgInitiallyMaximised();
|
2019-10-11 08:46:08 +00:00
|
|
|
|
void testXdgInitiallyFullscreen();
|
2019-02-26 13:41:07 +00:00
|
|
|
|
void testXdgInitiallyMinimized();
|
2019-10-03 19:43:28 +00:00
|
|
|
|
void testXdgWindowGeometryIsntSet();
|
|
|
|
|
void testXdgWindowGeometryAttachBuffer();
|
|
|
|
|
void testXdgWindowGeometryAttachSubSurface();
|
|
|
|
|
void testXdgWindowGeometryInteractiveResize();
|
|
|
|
|
void testXdgWindowGeometryFullScreen();
|
|
|
|
|
void testXdgWindowGeometryMaximize();
|
2023-08-16 18:41:50 +00:00
|
|
|
|
void testXdgPopupReactive_data();
|
|
|
|
|
void testXdgPopupReactive();
|
|
|
|
|
void testXdgPopupReposition();
|
2020-07-14 11:34:25 +00:00
|
|
|
|
void testPointerInputTransform();
|
2020-07-20 19:33:19 +00:00
|
|
|
|
void testReentrantSetFrameGeometry();
|
2020-10-14 18:53:07 +00:00
|
|
|
|
void testDoubleMaximize();
|
2022-01-24 13:16:45 +00:00
|
|
|
|
void testDoubleFullscreenSeparatedByCommit();
|
2021-12-07 07:32:33 +00:00
|
|
|
|
void testMaximizeAndChangeDecorationModeAfterInitialCommit();
|
|
|
|
|
void testFullScreenAndChangeDecorationModeAfterInitialCommit();
|
2021-12-07 07:47:39 +00:00
|
|
|
|
void testChangeDecorationModeAfterInitialCommit();
|
2023-07-11 06:49:59 +00:00
|
|
|
|
void testModal();
|
|
|
|
|
void testCloseModal();
|
|
|
|
|
void testCloseInactiveModal();
|
2016-06-07 09:43:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-08-16 18:41:50 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgPopupReactive_data()
|
2021-01-06 01:08:25 +00:00
|
|
|
|
{
|
2023-08-16 18:41:50 +00:00
|
|
|
|
QTest::addColumn<bool>("reactive");
|
|
|
|
|
QTest::addColumn<QPointF>("parentPos");
|
|
|
|
|
QTest::addColumn<QPointF>("popupPos");
|
|
|
|
|
|
|
|
|
|
QTest::addRow("reactive") << true << QPointF(0, 1024) << QPointF(50, 1024 - 10);
|
|
|
|
|
QTest::addRow("not reactive") << false << QPointF(0, 1024) << QPointF(50, 1024 + 40);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestXdgShellWindow::testXdgPopupReactive()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies the behavior of reactive popups. If a popup is not reactive,
|
|
|
|
|
// it only has to move together with its parent. If a popup is reactive, it moves
|
|
|
|
|
// with its parent and it's reconstrained as needed.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<Test::XdgPositioner> positioner(Test::createXdgPositioner());
|
2021-01-06 01:08:25 +00:00
|
|
|
|
positioner->set_size(10, 10);
|
|
|
|
|
positioner->set_anchor_rect(10, 10, 10, 10);
|
2023-08-16 18:41:50 +00:00
|
|
|
|
positioner->set_anchor_rect(0, 0, 50, 40);
|
|
|
|
|
positioner->set_anchor(Test::XdgPositioner::anchor_bottom_right);
|
|
|
|
|
positioner->set_gravity(Test::XdgPositioner::gravity_bottom_right);
|
|
|
|
|
positioner->set_constraint_adjustment(Test::XdgPositioner::constraint_adjustment_slide_y);
|
|
|
|
|
|
|
|
|
|
QFETCH(bool, reactive);
|
|
|
|
|
if (reactive) {
|
|
|
|
|
positioner->set_reactive();
|
|
|
|
|
}
|
2021-01-06 01:08:25 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> rootSurface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> root(Test::createXdgToplevelSurface(rootSurface.get()));
|
|
|
|
|
auto rootWindow = Test::renderAndWaitForShown(rootSurface.get(), QSize(100, 100), Qt::cyan);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(rootWindow);
|
2021-10-07 20:11:41 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> childSurface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgPopup> popup(Test::createXdgPopupSurface(childSurface.get(), root->xdgSurface(), positioner.get()));
|
|
|
|
|
auto childWindow = Test::renderAndWaitForShown(childSurface.get(), QSize(10, 10), Qt::cyan);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(childWindow);
|
2021-01-06 01:08:25 +00:00
|
|
|
|
|
2023-08-16 18:41:50 +00:00
|
|
|
|
QFETCH(QPointF, parentPos);
|
|
|
|
|
QFETCH(QPointF, popupPos);
|
2021-01-06 01:08:25 +00:00
|
|
|
|
|
2023-08-16 18:41:50 +00:00
|
|
|
|
QSignalSpy popupConfigureRequested(popup.get(), &Test::XdgPopup::configureRequested);
|
|
|
|
|
rootWindow->move(parentPos);
|
2021-02-01 07:59:02 +00:00
|
|
|
|
QVERIFY(popupConfigureRequested.wait());
|
|
|
|
|
QCOMPARE(popupConfigureRequested.count(), 1);
|
2023-08-16 18:41:50 +00:00
|
|
|
|
|
|
|
|
|
QCOMPARE(childWindow->pos(), popupPos);
|
2021-01-06 01:08:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-16 18:41:50 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgPopupReposition()
|
2021-01-06 01:08:25 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<Test::XdgPositioner> positioner(Test::createXdgPositioner());
|
2021-01-06 01:08:25 +00:00
|
|
|
|
positioner->set_size(10, 10);
|
|
|
|
|
positioner->set_anchor_rect(10, 10, 10, 10);
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<Test::XdgPositioner> otherPositioner(Test::createXdgPositioner());
|
2021-01-06 01:08:25 +00:00
|
|
|
|
otherPositioner->set_size(50, 50);
|
|
|
|
|
otherPositioner->set_anchor_rect(10, 10, 10, 10);
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> rootSurface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> root(Test::createXdgToplevelSurface(rootSurface.get()));
|
|
|
|
|
auto rootWindow = Test::renderAndWaitForShown(rootSurface.get(), QSize(100, 100), Qt::cyan);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(rootWindow);
|
2021-10-07 20:11:41 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> childSurface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgPopup> popup(Test::createXdgPopupSurface(childSurface.get(), root->xdgSurface(), positioner.get()));
|
|
|
|
|
auto childWindow = Test::renderAndWaitForShown(childSurface.get(), QSize(10, 10), Qt::cyan);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(childWindow);
|
2021-01-06 01:08:25 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy reconfigureSpy(popup.get(), &Test::XdgPopup::configureRequested);
|
2021-01-06 01:08:25 +00:00
|
|
|
|
|
|
|
|
|
popup->reposition(otherPositioner->object(), 500000);
|
|
|
|
|
|
|
|
|
|
QVERIFY(reconfigureSpy.wait());
|
|
|
|
|
QCOMPARE(reconfigureSpy.count(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::initTestCase()
|
2016-06-07 09:43:56 +00:00
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2022-03-23 10:13:38 +00:00
|
|
|
|
qRegisterMetaType<KWayland::Client::Output *>();
|
2017-08-24 16:57:30 +00:00
|
|
|
|
|
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-06-07 09:43:56 +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-06-07 09:43:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::init()
|
2016-06-07 09:43:56 +00:00
|
|
|
|
{
|
2023-07-11 06:49:59 +00:00
|
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::XdgDecorationV1 | Test::AdditionalWaylandInterface::AppMenu | Test::AdditionalWaylandInterface::XdgDialogV1));
|
2020-07-14 11:34:25 +00:00
|
|
|
|
QVERIFY(Test::waitForWaylandPointer());
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2021-08-28 18:58:29 +00:00
|
|
|
|
workspace()->setActiveOutput(QPoint(640, 512));
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// put mouse in the middle of screen one
|
2023-02-09 13:07:56 +00:00
|
|
|
|
KWin::input()->pointer()->warp(QPoint(640, 512));
|
2016-06-07 09:43:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::cleanup()
|
2016-06-07 09:43:56 +00:00
|
|
|
|
{
|
2016-06-30 11:32:54 +00:00
|
|
|
|
Test::destroyWaylandConnection();
|
2016-06-07 09:43:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMapUnmap()
|
2016-04-22 12:13:37 +00:00
|
|
|
|
{
|
2022-04-22 18:11:29 +00:00
|
|
|
|
// This test verifies that the compositor destroys XdgToplevelWindow when the
|
2020-05-07 14:29:41 +00:00
|
|
|
|
// associated xdg_toplevel surface is unmapped.
|
2016-04-22 12:13:37 +00:00
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
|
// Create a wl_surface and an xdg_toplevel, but don't commit them yet!
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
2016-04-22 12:13:37 +00:00
|
|
|
|
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy configureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
|
// Tell the compositor that we want to map the surface.
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-05-07 14:29:41 +00:00
|
|
|
|
|
|
|
|
|
// The compositor will respond with a configure event.
|
|
|
|
|
QVERIFY(configureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(configureRequestedSpy.count(), 1);
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
|
// Now we can attach a buffer with actual data to the surface.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QVERIFY(windowAddedSpy.wait());
|
|
|
|
|
QCOMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
Window *window = windowAddedSpy.last().first().value<Window *>();
|
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QCOMPARE(window->readyForPainting(), true);
|
2020-05-07 14:29:41 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// When the window becomes active, the compositor will send another configure event.
|
2020-05-07 14:29:41 +00:00
|
|
|
|
QVERIFY(configureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(configureRequestedSpy.count(), 2);
|
|
|
|
|
|
|
|
|
|
// Unmap the xdg_toplevel surface by committing a null buffer.
|
2022-11-07 21:33:00 +00:00
|
|
|
|
surface->attachBuffer(KWayland::Client::Buffer::Ptr());
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2020-05-07 14:29:41 +00:00
|
|
|
|
|
|
|
|
|
// Tell the compositor that we want to re-map the xdg_toplevel surface.
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-05-07 14:29:41 +00:00
|
|
|
|
|
|
|
|
|
// The compositor will respond with a configure event.
|
|
|
|
|
QVERIFY(configureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(configureRequestedSpy.count(), 3);
|
|
|
|
|
|
|
|
|
|
// Now we can attach a buffer with actual data to the surface.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QVERIFY(windowAddedSpy.wait());
|
|
|
|
|
QCOMPARE(windowAddedSpy.count(), 2);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
window = windowAddedSpy.last().first().value<Window *>();
|
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QCOMPARE(window->readyForPainting(), true);
|
2016-06-07 09:43:56 +00:00
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
|
// The compositor will respond with a configure event.
|
|
|
|
|
QVERIFY(configureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(configureRequestedSpy.count(), 4);
|
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Destroy the test window.
|
2016-06-07 09:43:56 +00:00
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2016-06-07 09:43:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testWindowOutputs()
|
2017-08-24 16:57:30 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
2022-03-23 10:13:38 +00:00
|
|
|
|
auto size = QSize(200, 200);
|
2017-08-24 16:57:30 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy outputEnteredSpy(surface.get(), &KWayland::Client::Surface::outputEntered);
|
|
|
|
|
QSignalSpy outputLeftSpy(surface.get(), &KWayland::Client::Surface::outputLeft);
|
2017-08-24 16:57:30 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), size, Qt::blue);
|
2022-08-31 12:50:13 +00:00
|
|
|
|
// assumption: window is initially placed on first screen
|
|
|
|
|
QVERIFY(outputEnteredSpy.wait());
|
|
|
|
|
QCOMPARE(outputEnteredSpy.count(), 1);
|
2017-08-24 16:57:30 +00:00
|
|
|
|
QCOMPARE(surface->outputs().count(), 1);
|
2022-03-23 10:13:38 +00:00
|
|
|
|
QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(0, 0));
|
2017-08-24 16:57:30 +00:00
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// move to overlapping both first and second screen
|
2022-04-23 19:51:16 +00:00
|
|
|
|
window->moveResize(QRect(QPoint(1250, 100), size));
|
2017-08-24 16:57:30 +00:00
|
|
|
|
QVERIFY(outputEnteredSpy.wait());
|
2022-08-31 12:50:13 +00:00
|
|
|
|
QCOMPARE(outputEnteredSpy.count(), 2);
|
2017-08-24 16:57:30 +00:00
|
|
|
|
QCOMPARE(outputLeftSpy.count(), 0);
|
|
|
|
|
QCOMPARE(surface->outputs().count(), 2);
|
|
|
|
|
QVERIFY(surface->outputs()[0] != surface->outputs()[1]);
|
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// move entirely into second screen
|
2022-04-23 19:51:16 +00:00
|
|
|
|
window->moveResize(QRect(QPoint(1400, 100), size));
|
2017-08-24 16:57:30 +00:00
|
|
|
|
QVERIFY(outputLeftSpy.wait());
|
2022-08-31 12:50:13 +00:00
|
|
|
|
QCOMPARE(outputEnteredSpy.count(), 2);
|
2017-08-24 16:57:30 +00:00
|
|
|
|
QCOMPARE(outputLeftSpy.count(), 1);
|
|
|
|
|
QCOMPARE(surface->outputs().count(), 1);
|
2022-03-23 10:13:38 +00:00
|
|
|
|
QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280, 0));
|
2017-08-24 16:57:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMinimizeActiveWindow()
|
2016-08-11 15:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that when minimizing the active window it gets deactivated
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<QObject> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), window);
|
|
|
|
|
QVERIFY(window->wantsInput());
|
|
|
|
|
QVERIFY(window->wantsTabFocus());
|
|
|
|
|
QVERIFY(window->isShown());
|
2016-08-11 15:08:08 +00:00
|
|
|
|
|
|
|
|
|
workspace()->slotWindowMinimize();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(!window->isShown());
|
|
|
|
|
QVERIFY(window->wantsInput());
|
|
|
|
|
QVERIFY(window->wantsTabFocus());
|
|
|
|
|
QVERIFY(!window->isActive());
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QVERIFY(!workspace()->activeWindow());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->isMinimized());
|
2016-08-18 08:30:27 +00:00
|
|
|
|
|
|
|
|
|
// unminimize again
|
2023-03-07 10:45:02 +00:00
|
|
|
|
window->setMinimized(false);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(!window->isMinimized());
|
2022-05-17 10:41:16 +00:00
|
|
|
|
QVERIFY(!window->isActive());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->wantsInput());
|
|
|
|
|
QVERIFY(window->wantsTabFocus());
|
|
|
|
|
QVERIFY(window->isShown());
|
2022-05-17 10:41:16 +00:00
|
|
|
|
QCOMPARE(workspace()->activeWindow(), nullptr);
|
2016-08-11 15:08:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testFullscreen_data()
|
2016-09-12 10:03:18 +00:00
|
|
|
|
{
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QTest::addColumn<Test::XdgToplevelDecorationV1::mode>("decoMode");
|
2016-09-12 10:03:18 +00:00
|
|
|
|
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QTest::newRow("client-side deco") << Test::XdgToplevelDecorationV1::mode_client_side;
|
|
|
|
|
QTest::newRow("server-side deco") << Test::XdgToplevelDecorationV1::mode_server_side;
|
2016-09-12 10:03:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testFullscreen()
|
2016-09-12 10:03:18 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that a window can be properly fullscreened
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
Test::XdgToplevel::States states;
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
std::unique_ptr<Test::XdgToplevelDecorationV1> decoration(Test::createXdgToplevelDecorationV1(shellSurface.get()));
|
|
|
|
|
QSignalSpy decorationConfigureRequestedSpy(decoration.get(), &Test::XdgToplevelDecorationV1::configureRequested);
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
|
|
|
|
|
// Initialize the xdg-toplevel surface.
|
|
|
|
|
QFETCH(Test::XdgToplevelDecorationV1::mode, decoMode);
|
|
|
|
|
decoration->set_mode(decoMode);
|
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
2016-09-12 12:14:20 +00:00
|
|
|
|
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2023-08-23 19:51:18 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(500, 250), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QCOMPARE(window->layer(), NormalLayer);
|
|
|
|
|
QVERIFY(!window->isFullScreen());
|
2023-08-23 19:51:18 +00:00
|
|
|
|
QCOMPARE(window->clientSize(), QSize(500, 250));
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->isDecorated(), decoMode == Test::XdgToplevelDecorationV1::mode_server_side);
|
|
|
|
|
QCOMPARE(window->clientSizeToFrameSize(window->clientSize()), window->size());
|
|
|
|
|
|
|
|
|
|
QSignalSpy fullScreenChangedSpy(window, &Window::fullScreenChanged);
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2018-10-05 14:27:05 +00:00
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
|
// Wait for the compositor to send a configure event with the Activated state.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states & Test::XdgToplevel::State::Activated);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
|
|
// Ask the compositor to show the window in full screen mode.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_fullscreen(nullptr);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states & Test::XdgToplevel::State::Fullscreen);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), window->output()->geometry().size());
|
2016-09-12 10:03:18 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
|
|
QVERIFY(fullScreenChangedSpy.wait());
|
|
|
|
|
QCOMPARE(fullScreenChangedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->isFullScreen());
|
|
|
|
|
QVERIFY(!window->isDecorated());
|
|
|
|
|
QCOMPARE(window->layer(), ActiveLayer);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRect(QPoint(0, 0), window->output()->geometry().size()));
|
2016-09-12 10:03:18 +00:00
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
|
// Ask the compositor to show the window in normal mode.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->unset_fullscreen();
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 4);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!(states & Test::XdgToplevel::State::Fullscreen));
|
2023-08-23 19:51:18 +00:00
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(500, 250));
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::blue);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
|
|
QVERIFY(fullScreenChangedSpy.wait());
|
|
|
|
|
QCOMPARE(fullScreenChangedSpy.count(), 2);
|
2023-08-23 19:51:18 +00:00
|
|
|
|
QCOMPARE(window->clientSize(), QSize(500, 250));
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(!window->isFullScreen());
|
|
|
|
|
QCOMPARE(window->isDecorated(), decoMode == Test::XdgToplevelDecorationV1::mode_server_side);
|
|
|
|
|
QCOMPARE(window->layer(), NormalLayer);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Destroy the window.
|
2020-02-17 18:39:17 +00:00
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2016-09-12 12:41:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testUserCanSetFullscreen()
|
2017-10-07 09:41:17 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QVERIFY(!window->isFullScreen());
|
2023-02-06 14:47:57 +00:00
|
|
|
|
QVERIFY(window->isFullScreenable());
|
2017-10-07 09:41:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 07:52:57 +00:00
|
|
|
|
void TestXdgShellWindow::testSendFullScreenWindowToAnotherOutput()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that the fullscreen window will have correct geometry restore
|
|
|
|
|
// after it's sent to another output.
|
|
|
|
|
|
|
|
|
|
const auto outputs = workspace()->outputs();
|
|
|
|
|
|
|
|
|
|
// Create the window.
|
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the activated state.
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
|
|
// Move the window to the left monitor.
|
|
|
|
|
window->move(QPointF(10, 20));
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(10, 20, 100, 50));
|
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
|
|
|
|
|
|
// Make the window fullscreen.
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
|
shellSurface->set_fullscreen(nullptr);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->isFullScreen(), true);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 1280, 1024));
|
|
|
|
|
QCOMPARE(window->fullscreenGeometryRestore(), QRectF(10, 20, 100, 50));
|
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
|
|
|
|
|
|
// Send the window to another output.
|
2024-06-06 15:28:52 +00:00
|
|
|
|
window->sendToOutput(outputs[1]);
|
2022-09-14 07:52:57 +00:00
|
|
|
|
QCOMPARE(window->isFullScreen(), true);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
|
QCOMPARE(window->fullscreenGeometryRestore(), QRectF(1280 + 10, 20, 100, 50));
|
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMaximizedToFullscreen_data()
|
2019-01-29 12:28:52 +00:00
|
|
|
|
{
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QTest::addColumn<Test::XdgToplevelDecorationV1::mode>("decoMode");
|
2019-01-29 12:28:52 +00:00
|
|
|
|
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QTest::newRow("client-side deco") << Test::XdgToplevelDecorationV1::mode_client_side;
|
|
|
|
|
QTest::newRow("server-side deco") << Test::XdgToplevelDecorationV1::mode_server_side;
|
2016-09-12 12:41:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMaximizedToFullscreen()
|
2016-09-12 12:41:03 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that a window can be properly fullscreened after maximizing
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
Test::XdgToplevel::States states;
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
std::unique_ptr<Test::XdgToplevelDecorationV1> decoration(Test::createXdgToplevelDecorationV1(shellSurface.get()));
|
|
|
|
|
QSignalSpy decorationConfigureRequestedSpy(decoration.get(), &Test::XdgToplevelDecorationV1::configureRequested);
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
|
|
|
|
|
// Initialize the xdg-toplevel surface.
|
|
|
|
|
QFETCH(Test::XdgToplevelDecorationV1::mode, decoMode);
|
|
|
|
|
decoration->set_mode(decoMode);
|
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
2016-09-12 12:41:03 +00:00
|
|
|
|
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QVERIFY(!window->isFullScreen());
|
|
|
|
|
QCOMPARE(window->clientSize(), QSize(100, 50));
|
|
|
|
|
QCOMPARE(window->isDecorated(), decoMode == Test::XdgToplevelDecorationV1::mode_server_side);
|
|
|
|
|
|
|
|
|
|
QSignalSpy fullscreenChangedSpy(window, &Window::fullScreenChanged);
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the Activated state.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states & Test::XdgToplevel::State::Activated);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
|
|
// Ask the compositor to maximize the window.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_maximized();
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states & Test::XdgToplevel::State::Maximized);
|
|
|
|
|
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
[wayland] Asyncronously update maximise flags
Summary:
A window maximising is an async operation. We work out what size we want
the client to be, then request the client to update. The window isn't
really maximised until we get that new buffer with the new size.
This patch splits the requested, pending and current state, updating as
appropriate.
Things are a bit complex with things like borders. Technically we
shouldn't update them till we get a response, but we also need to have
the correct geometry of the full size window in our request. For now
they behave as before, updating when we request the change.
X code is untouched.
This hopefully fixes maximise animations on wayland as now we update the
geometry before emitting maximisedChanged.
Test Plan:
Maximised a window with the button and double clicking title bar.
I get only the following events on maximise/restore:
19:51:39.156 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(47,24 640x509) QRect(0,0 716x573)
19:51:39.157 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised true true
19:51:40.522 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(0,0 716x573) QRect(47,24 640x509)
19:51:40.522 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised false false
BUG: 382698
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15150
2018-10-05 14:36:02 +00:00
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
|
// Ask the compositor to show the window in full screen mode.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_fullscreen(nullptr);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 4);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), window->output()->geometry().size());
|
2021-05-11 05:26:51 +00:00
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states & Test::XdgToplevel::State::Maximized);
|
|
|
|
|
QVERIFY(states & Test::XdgToplevel::State::Fullscreen);
|
2016-09-12 12:41:03 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
2018-11-16 11:59:39 +00:00
|
|
|
|
|
2021-05-01 15:07:11 +00:00
|
|
|
|
QVERIFY(fullscreenChangedSpy.wait());
|
|
|
|
|
QCOMPARE(fullscreenChangedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QVERIFY(window->isFullScreen());
|
|
|
|
|
QVERIFY(!window->isDecorated());
|
2016-09-12 12:41:03 +00:00
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
|
// Switch back to normal mode.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->unset_fullscreen();
|
|
|
|
|
shellSurface->unset_maximized();
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
wayland: Properly handle async xdg-decoration updates
Currently, if a window switches between SSD and CSD, it is possible to
encounter a "corrupted" state where the server-side decoration is wrapped
around the window while it still has the client-side decoration.
The xdg-decoration protocol fixes this problem by saying that decoration
updates are bound to xdg_surface configure events.
At the moment, kwin sort of applies decoration updates immediately. With
this change, decoration updates will be done according to the spec.
If the compositor wants to create a decoration, it will send a configure
event and apply the decoration when the configure event is acked by the
client. In order to send the configure event with a good window geometry
size, kwin will create the decoration to query the border size but not
assign it to the client yet. As is, KDecoration api doesn't make
querying the border size ahead of time easy. The decoration plugin can
assign arbitrary border sizes to windows as it pleases it. We could change
that, but it effectively means starting KDecoration3 and setting existing
window deco ecosystem around kwin on fire the second time, that's off the
table.
If the compositor wants to remove the decoration, it will send a
configure event. When the configure event is acked and the surface is
committed, the window decoration will be destroyed.
Sync'ing decoration updates to configure events ensures that we cannot
end up with having both client-side and server-side decoration. It also
helps us to fix a bunch of geometry related issues caused by creating
and destroying the decoration without any surface buffer attached yet.
BUG: 445259
2021-01-27 15:35:13 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 5);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(100, 50));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!(states & Test::XdgToplevel::State::Maximized));
|
|
|
|
|
QVERIFY(!(states & Test::XdgToplevel::State::Fullscreen));
|
|
|
|
|
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(!window->isFullScreen());
|
|
|
|
|
QCOMPARE(window->isDecorated(), decoMode == Test::XdgToplevelDecorationV1::mode_server_side);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Destroy the window.
|
2020-02-17 18:39:17 +00:00
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2016-09-12 10:03:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testFullscreenMultipleOutputs()
|
2020-11-23 18:24:37 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that kwin will place fullscreen windows in the outputs its instructed to
|
|
|
|
|
|
2022-07-11 10:41:15 +00:00
|
|
|
|
const auto outputs = workspace()->outputs();
|
2022-09-05 12:29:56 +00:00
|
|
|
|
for (KWin::Output *output : outputs) {
|
2021-05-11 05:26:51 +00:00
|
|
|
|
Test::XdgToplevel::States states;
|
2020-11-23 18:24:37 +00:00
|
|
|
|
|
2022-08-16 11:43:33 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
|
2020-11-23 18:24:37 +00:00
|
|
|
|
QVERIFY(surface);
|
2023-03-20 13:16:37 +00:00
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
2020-11-23 18:24:37 +00:00
|
|
|
|
QVERIFY(shellSurface);
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QVERIFY(!window->isFullScreen());
|
|
|
|
|
QCOMPARE(window->clientSize(), QSize(100, 50));
|
|
|
|
|
QVERIFY(!window->isDecorated());
|
2020-11-23 18:24:37 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy fullscreenChangedSpy(window, &Window::fullScreenChanged);
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2020-11-23 18:24:37 +00:00
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the Activated state.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
|
2020-11-23 18:24:37 +00:00
|
|
|
|
|
|
|
|
|
// Ask the compositor to show the window in full screen mode.
|
2022-09-05 12:29:56 +00:00
|
|
|
|
shellSurface->set_fullscreen(*Test::waylandOutput(output->name()));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
2022-09-05 12:29:56 +00:00
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), output->geometry().size());
|
2020-11-23 18:24:37 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
2020-11-23 18:24:37 +00:00
|
|
|
|
|
|
|
|
|
QVERIFY(!fullscreenChangedSpy.isEmpty() || fullscreenChangedSpy.wait());
|
|
|
|
|
QCOMPARE(fullscreenChangedSpy.count(), 1);
|
|
|
|
|
|
|
|
|
|
QVERIFY(!frameGeometryChangedSpy.isEmpty() || frameGeometryChangedSpy.wait());
|
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->isFullScreen());
|
2020-11-23 18:24:37 +00:00
|
|
|
|
|
2022-09-05 12:29:56 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry(), output->geometry());
|
2020-11-23 18:24:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testHidden()
|
2016-10-11 14:24:10 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that when hiding window it doesn't get shown
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<QObject> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), window);
|
|
|
|
|
QVERIFY(window->wantsInput());
|
|
|
|
|
QVERIFY(window->wantsTabFocus());
|
|
|
|
|
QVERIFY(window->isShown());
|
|
|
|
|
|
2023-06-01 10:31:04 +00:00
|
|
|
|
window->setHidden(true);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(!window->isShown());
|
|
|
|
|
QVERIFY(!window->isActive());
|
|
|
|
|
QVERIFY(window->wantsInput());
|
|
|
|
|
QVERIFY(window->wantsTabFocus());
|
2016-10-11 14:24:10 +00:00
|
|
|
|
|
|
|
|
|
// unhide again
|
2023-06-01 10:31:04 +00:00
|
|
|
|
window->setHidden(false);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->isShown());
|
|
|
|
|
QVERIFY(window->wantsInput());
|
|
|
|
|
QVERIFY(window->wantsTabFocus());
|
2016-10-11 14:24:10 +00:00
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// QCOMPARE(workspace()->activeClient(), c);
|
2016-10-11 14:24:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testDesktopFileName()
|
2016-10-27 13:59:08 +00:00
|
|
|
|
{
|
2016-10-31 13:16:23 +00:00
|
|
|
|
QIcon::setThemeName(QStringLiteral("breeze"));
|
2016-10-27 13:59:08 +00:00
|
|
|
|
// this test verifies that desktop file name is passed correctly to the window
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-10-27 13:59:08 +00:00
|
|
|
|
// only xdg-shell as ShellSurface misses the setter
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_app_id(QStringLiteral("org.kde.foo"));
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
2022-10-21 14:57:16 +00:00
|
|
|
|
QCOMPARE(window->desktopFileName(), QStringLiteral("org.kde.foo"));
|
2022-10-21 14:24:42 +00:00
|
|
|
|
QCOMPARE(window->resourceClass(), QStringLiteral("org.kde.foo"));
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->resourceName().startsWith("testXdgShellWindow"));
|
2016-10-27 13:59:08 +00:00
|
|
|
|
// the desktop file does not exist, so icon should be generic Wayland
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->icon().name(), QStringLiteral("wayland"));
|
2016-10-27 13:59:08 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy desktopFileNameChangedSpy(window, &Window::desktopFileNameChanged);
|
|
|
|
|
QSignalSpy iconChangedSpy(window, &Window::iconChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_app_id(QStringLiteral("org.kde.bar"));
|
2016-10-27 13:59:08 +00:00
|
|
|
|
QVERIFY(desktopFileNameChangedSpy.wait());
|
2022-10-21 14:57:16 +00:00
|
|
|
|
QCOMPARE(window->desktopFileName(), QStringLiteral("org.kde.bar"));
|
2022-10-21 14:24:42 +00:00
|
|
|
|
QCOMPARE(window->resourceClass(), QStringLiteral("org.kde.bar"));
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->resourceName().startsWith("testXdgShellWindow"));
|
2016-10-27 13:59:08 +00:00
|
|
|
|
// icon should still be wayland
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->icon().name(), QStringLiteral("wayland"));
|
2016-10-27 13:59:08 +00:00
|
|
|
|
QVERIFY(iconChangedSpy.isEmpty());
|
|
|
|
|
|
|
|
|
|
const QString dfPath = QFINDTESTDATA("data/example.desktop");
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_app_id(dfPath.toUtf8());
|
2016-10-27 13:59:08 +00:00
|
|
|
|
QVERIFY(desktopFileNameChangedSpy.wait());
|
|
|
|
|
QCOMPARE(iconChangedSpy.count(), 1);
|
2022-10-21 14:57:16 +00:00
|
|
|
|
QCOMPARE(window->desktopFileName(), dfPath);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->icon().name(), QStringLiteral("kwin"));
|
2016-10-27 13:59:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testCaptionSimplified()
|
2016-10-31 14:50:14 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that caption is properly trimmed
|
|
|
|
|
// see BUG 323798 comment #12
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-10-31 14:50:14 +00:00
|
|
|
|
// only done for xdg-shell as ShellSurface misses the setter
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
2016-10-31 14:50:14 +00:00
|
|
|
|
const QString origTitle = QString::fromUtf8(QByteArrayLiteral("Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies Hübner - Mozilla Firefox"));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_title(origTitle);
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->caption() != origTitle);
|
|
|
|
|
QCOMPARE(window->caption(), origTitle.simplified());
|
2016-10-31 14:50:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testUnresponsiveWindow_data()
|
2016-11-15 15:48:20 +00:00
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
|
QTest::addColumn<QString>("shellInterface"); // see env selection in qwaylandintegration.cpp
|
2016-11-15 15:48:20 +00:00
|
|
|
|
QTest::addColumn<bool>("socketMode");
|
|
|
|
|
|
2020-03-18 09:14:37 +00:00
|
|
|
|
QTest::newRow("xdg display") << "xdg-shell" << false;
|
|
|
|
|
QTest::newRow("xdg socket") << "xdg-shell" << true;
|
2016-11-15 15:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testUnresponsiveWindow()
|
2016-11-15 15:48:20 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that killWindow properly terminates a process
|
|
|
|
|
// for this an external binary is launched
|
2017-08-25 16:18:20 +00:00
|
|
|
|
const QString kill = QFINDTESTDATA(QStringLiteral("kill"));
|
2016-11-15 15:48:20 +00:00
|
|
|
|
QVERIFY(!kill.isEmpty());
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
2016-11-15 15:48:20 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<QProcess> process(new QProcess);
|
2016-11-15 15:48:20 +00:00
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
|
|
|
|
|
QFETCH(QString, shellInterface);
|
2016-11-15 15:48:20 +00:00
|
|
|
|
QFETCH(bool, socketMode);
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
env.insert("QT_WAYLAND_SHELL_INTEGRATION", shellInterface);
|
2016-11-15 15:48:20 +00:00
|
|
|
|
if (socketMode) {
|
|
|
|
|
int sx[2];
|
|
|
|
|
QVERIFY(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) >= 0);
|
|
|
|
|
waylandServer()->display()->createClient(sx[0]);
|
|
|
|
|
int socket = dup(sx[1]);
|
|
|
|
|
QVERIFY(socket != -1);
|
|
|
|
|
env.insert(QStringLiteral("WAYLAND_SOCKET"), QByteArray::number(socket));
|
|
|
|
|
env.remove("WAYLAND_DISPLAY");
|
|
|
|
|
} else {
|
|
|
|
|
env.insert("WAYLAND_DISPLAY", s_socketName);
|
|
|
|
|
}
|
|
|
|
|
process->setProcessEnvironment(env);
|
|
|
|
|
process->setProcessChannelMode(QProcess::ForwardedChannels);
|
|
|
|
|
process->setProgram(kill);
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy processStartedSpy{process.get(), &QProcess::started};
|
2016-11-15 15:48:20 +00:00
|
|
|
|
process->start();
|
2018-12-23 06:58:29 +00:00
|
|
|
|
QVERIFY(processStartedSpy.wait());
|
2016-11-15 15:48:20 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
Window *killWindow = nullptr;
|
2022-04-23 08:33:23 +00:00
|
|
|
|
if (windowAddedSpy.isEmpty()) {
|
|
|
|
|
QVERIFY(windowAddedSpy.wait());
|
2018-12-23 06:58:29 +00:00
|
|
|
|
}
|
2019-02-28 02:09:16 +00:00
|
|
|
|
::kill(process->processId(), SIGUSR1); // send a signal to freeze the process
|
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
killWindow = windowAddedSpy.first().first().value<Window *>();
|
|
|
|
|
QVERIFY(killWindow);
|
|
|
|
|
QSignalSpy unresponsiveSpy(killWindow, &Window::unresponsiveChanged);
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy killedSpy(process.get(), static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy deletedSpy(killWindow, &QObject::destroyed);
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
|
|
|
|
|
qint64 startTime = QDateTime::currentMSecsSinceEpoch();
|
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// wait for the process to be frozen
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
QTest::qWait(10);
|
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// pretend the user clicked the close button
|
2022-04-23 19:51:16 +00:00
|
|
|
|
killWindow->closeWindow();
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// window should not yet be marked unresponsive nor killed
|
|
|
|
|
QVERIFY(!killWindow->unresponsive());
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
QVERIFY(killedSpy.isEmpty());
|
|
|
|
|
|
|
|
|
|
QVERIFY(unresponsiveSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// window should be marked unresponsive but not killed
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
auto elapsed1 = QDateTime::currentMSecsSinceEpoch() - startTime;
|
2023-11-23 13:48:17 +00:00
|
|
|
|
const int timeout = options->killPingTimeout() / 2; // first timeout at half the time is for "unresponsive".
|
2023-11-23 13:48:04 +00:00
|
|
|
|
QVERIFY(elapsed1 > timeout - 200 && elapsed1 < timeout + 200); // coarse timers on a test across two processes means we need a fuzzy compare
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(killWindow->unresponsive());
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
QVERIFY(killedSpy.isEmpty());
|
|
|
|
|
|
2023-11-23 13:48:17 +00:00
|
|
|
|
// TODO verify that kill prompt works.
|
|
|
|
|
killWindow->killWindow();
|
|
|
|
|
process->kill();
|
|
|
|
|
|
|
|
|
|
QVERIFY(killedSpy.wait());
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
|
|
2023-11-23 13:48:17 +00:00
|
|
|
|
if (deletedSpy.isEmpty()) {
|
|
|
|
|
QVERIFY(deletedSpy.wait());
|
|
|
|
|
}
|
2016-11-15 15:48:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testAppMenu()
|
2017-12-22 14:22:24 +00:00
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// register a faux appmenu client
|
|
|
|
|
QVERIFY(QDBusConnection::sessionBus().registerService("org.kde.kappmenu"));
|
2017-12-22 17:23:44 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
2022-11-07 21:33:00 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::AppMenu> menu(Test::waylandAppMenuManager()->create(surface.get()));
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy spy(window, &Window::hasApplicationMenuChanged);
|
2017-12-22 14:22:24 +00:00
|
|
|
|
menu->setAddress("service.name", "object/path");
|
|
|
|
|
spy.wait();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->hasApplicationMenu(), true);
|
|
|
|
|
QCOMPARE(window->applicationMenuServiceName(), QString("service.name"));
|
|
|
|
|
QCOMPARE(window->applicationMenuObjectPath(), QString("object/path"));
|
2017-12-22 17:23:44 +00:00
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
QVERIFY(QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu"));
|
2017-12-22 14:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testSendClientWithTransientToDesktop()
|
2018-12-12 17:25:51 +00:00
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// this test verifies that when sending a window to a desktop all transients are also send to that desktop
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
2021-08-17 07:19:46 +00:00
|
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
|
|
|
|
vds->setCount(2);
|
2023-10-19 06:50:15 +00:00
|
|
|
|
const QList<VirtualDesktop *> desktops = vds->desktops();
|
2021-08-17 07:19:46 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface{Test::createSurface()};
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
|
|
|
|
// let's create a transient window
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> transientSurface{Test::createSurface()};
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> transientShellSurface(Test::createXdgToplevelSurface(transientSurface.get()));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
transientShellSurface->set_parent(shellSurface->object());
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto transient = Test::renderAndWaitForShown(transientSurface.get(), QSize(100, 50), Qt::blue);
|
2018-12-12 17:25:51 +00:00
|
|
|
|
QVERIFY(transient);
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QCOMPARE(workspace()->activeWindow(), transient);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(transient->transientFor(), window);
|
|
|
|
|
QVERIFY(window->transients().contains(transient));
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
2021-08-17 07:19:46 +00:00
|
|
|
|
// initially, the parent and the transient are on the first virtual desktop
|
2023-10-19 06:50:15 +00:00
|
|
|
|
QCOMPARE(window->desktops(), QList<VirtualDesktop *>{desktops[0]});
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(!window->isOnAllDesktops());
|
2023-10-19 06:50:15 +00:00
|
|
|
|
QCOMPARE(transient->desktops(), QList<VirtualDesktop *>{desktops[0]});
|
2018-12-12 17:25:51 +00:00
|
|
|
|
QVERIFY(!transient->isOnAllDesktops());
|
|
|
|
|
|
2021-08-17 07:19:46 +00:00
|
|
|
|
// send the transient to the second virtual desktop
|
|
|
|
|
workspace()->slotWindowToDesktop(desktops[1]);
|
2023-10-19 06:50:15 +00:00
|
|
|
|
QCOMPARE(window->desktops(), QList<VirtualDesktop *>{desktops[0]});
|
|
|
|
|
QCOMPARE(transient->desktops(), QList<VirtualDesktop *>{desktops[1]});
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
|
|
|
|
// activate c
|
2022-04-23 19:51:16 +00:00
|
|
|
|
workspace()->activateWindow(window);
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), window);
|
|
|
|
|
QVERIFY(window->isActive());
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
|
|
|
|
// and send it to the desktop it's already on
|
2023-10-19 06:50:15 +00:00
|
|
|
|
QCOMPARE(window->desktops(), QList<VirtualDesktop *>{desktops[0]});
|
|
|
|
|
QCOMPARE(transient->desktops(), QList<VirtualDesktop *>{desktops[1]});
|
2021-08-17 07:19:46 +00:00
|
|
|
|
workspace()->slotWindowToDesktop(desktops[0]);
|
2018-12-12 17:25:51 +00:00
|
|
|
|
|
|
|
|
|
// which should move the transient back to the desktop
|
2023-10-19 06:50:15 +00:00
|
|
|
|
QCOMPARE(window->desktops(), QList<VirtualDesktop *>{desktops[0]});
|
|
|
|
|
QCOMPARE(transient->desktops(), QList<VirtualDesktop *>{desktops[0]});
|
2018-12-12 17:25:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMinimizeWindowWithTransients()
|
2018-12-13 16:47:10 +00:00
|
|
|
|
{
|
|
|
|
|
// this test verifies that when minimizing/unminimizing a window all its
|
|
|
|
|
// transients will be minimized/unminimized as well
|
|
|
|
|
|
|
|
|
|
// create the main window
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(!window->isMinimized());
|
2018-12-13 16:47:10 +00:00
|
|
|
|
|
|
|
|
|
// create a transient window
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> transientSurface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> transientShellSurface(Test::createXdgToplevelSurface(transientSurface.get()));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
transientShellSurface->set_parent(shellSurface->object());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto transient = Test::renderAndWaitForShown(transientSurface.get(), QSize(100, 50), Qt::red);
|
2018-12-13 16:47:10 +00:00
|
|
|
|
QVERIFY(transient);
|
|
|
|
|
QVERIFY(!transient->isMinimized());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(transient->transientFor(), window);
|
|
|
|
|
QVERIFY(window->hasTransient(transient, false));
|
2018-12-13 16:47:10 +00:00
|
|
|
|
|
|
|
|
|
// minimize the main window, the transient should be minimized as well
|
2023-03-07 10:45:02 +00:00
|
|
|
|
window->setMinimized(true);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->isMinimized());
|
2018-12-13 16:47:10 +00:00
|
|
|
|
QVERIFY(transient->isMinimized());
|
|
|
|
|
|
|
|
|
|
// unminimize the main window, the transient should be unminimized as well
|
2023-03-07 10:45:02 +00:00
|
|
|
|
window->setMinimized(false);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(!window->isMinimized());
|
2018-12-13 16:47:10 +00:00
|
|
|
|
QVERIFY(!transient->isMinimized());
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgDecoration_data()
|
2019-01-01 17:37:18 +00:00
|
|
|
|
{
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QTest::addColumn<Test::XdgToplevelDecorationV1::mode>("requestedMode");
|
|
|
|
|
QTest::addColumn<Test::XdgToplevelDecorationV1::mode>("expectedMode");
|
2019-01-01 17:37:18 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QTest::newRow("client side requested") << Test::XdgToplevelDecorationV1::mode_client_side << Test::XdgToplevelDecorationV1::mode_client_side;
|
2022-03-23 10:13:38 +00:00
|
|
|
|
QTest::newRow("server side requested") << Test::XdgToplevelDecorationV1::mode_server_side << Test::XdgToplevelDecorationV1::mode_server_side;
|
2019-01-01 17:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgDecoration()
|
2019-01-01 17:37:18 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
std::unique_ptr<Test::XdgToplevelDecorationV1> deco(Test::createXdgToplevelDecorationV1(shellSurface.get()));
|
2019-01-01 17:37:18 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy decorationConfigureRequestedSpy(deco.get(), &Test::XdgToplevelDecorationV1::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2019-01-01 17:37:18 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QFETCH(Test::XdgToplevelDecorationV1::mode, requestedMode);
|
|
|
|
|
QFETCH(Test::XdgToplevelDecorationV1::mode, expectedMode);
|
2019-01-01 17:37:18 +00:00
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// request a mode
|
2021-05-11 05:26:51 +00:00
|
|
|
|
deco->set_mode(requestedMode);
|
2019-01-01 17:37:18 +00:00
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// kwin will send a configure
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
2019-01-01 17:37:18 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QCOMPARE(decorationConfigureRequestedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(decorationConfigureRequestedSpy.last()[0].value<Test::XdgToplevelDecorationV1::mode>(), expectedMode);
|
|
|
|
|
QVERIFY(decorationConfigureRequestedSpy.count() > 0);
|
2019-01-01 17:37:18 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last()[0].toInt());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->isDecorated(), expectedMode == Test::XdgToplevelDecorationV1::mode_server_side);
|
2019-01-01 17:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgNeverCommitted()
|
2019-02-26 13:41:07 +00:00
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
|
// check we don't crash if we create a shell object but delete the XdgShellClient before committing it
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
2019-02-26 13:41:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgInitialState()
|
2019-02-26 13:41:07 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
surfaceConfigureRequestedSpy.wait();
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
const auto size = toplevelConfigureRequestedSpy.first()[0].value<QSize>();
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(size, QSize(0, 0)); // window should chose it's preferred size
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.first()[0].toUInt());
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->size(), QSize(200, 100));
|
2019-02-26 13:41:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgInitiallyMaximised()
|
2019-02-26 13:41:07 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_maximized();
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
surfaceConfigureRequestedSpy.wait();
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
const auto size = toplevelConfigureRequestedSpy.first()[0].value<QSize>();
|
|
|
|
|
const auto state = toplevelConfigureRequestedSpy.first()[1].value<Test::XdgToplevel::States>();
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
|
|
|
|
QCOMPARE(size, QSize(1280, 1024));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(state & Test::XdgToplevel::State::Maximized);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.first()[0].toUInt());
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), size, Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->size(), QSize(1280, 1024));
|
2019-10-11 08:46:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgInitiallyFullscreen()
|
2019-10-11 08:46:08 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_fullscreen(nullptr);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
surfaceConfigureRequestedSpy.wait();
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
const auto size = toplevelConfigureRequestedSpy.first()[0].value<QSize>();
|
|
|
|
|
const auto state = toplevelConfigureRequestedSpy.first()[1].value<Test::XdgToplevel::States>();
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
|
|
|
|
QCOMPARE(size, QSize(1280, 1024));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(state & Test::XdgToplevel::State::Fullscreen);
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.first()[0].toUInt());
|
2019-10-11 08:46:08 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), size, Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->isFullScreen(), true);
|
|
|
|
|
QCOMPARE(window->size(), QSize(1280, 1024));
|
2019-02-26 13:41:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgInitiallyMinimized()
|
2019-02-26 13:41:07 +00:00
|
|
|
|
{
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
shellSurface->set_minimized();
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
surfaceConfigureRequestedSpy.wait();
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
const auto size = toplevelConfigureRequestedSpy.first()[0].value<QSize>();
|
|
|
|
|
const auto state = toplevelConfigureRequestedSpy.first()[1].value<Test::XdgToplevel::States>();
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
|
|
|
|
QCOMPARE(size, QSize(0, 0));
|
|
|
|
|
QCOMPARE(state, 0);
|
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.first()[0].toUInt());
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
|
|
|
|
QEXPECT_FAIL("", "Client created in a minimised state is not exposed to kwin bug 404838", Abort);
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), size, Qt::blue, QImage::Format_ARGB32, 10);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isMinimized());
|
2019-02-26 13:41:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgWindowGeometryIsntSet()
|
2019-05-17 14:13:54 +00:00
|
|
|
|
{
|
2019-10-03 19:43:28 +00:00
|
|
|
|
// This test verifies that the effective window geometry corresponds to the
|
|
|
|
|
// bounding rectangle of the main surface and its sub-surfaces if no window
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// geometry is set by the window.
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
|
const QPointF oldPosition = window->pos();
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(100, 50), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(100, 50));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(100, 50));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> childSurface(Test::createSurface());
|
2022-11-07 21:33:00 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::SubSurface> subSurface(Test::createSubSurface(childSurface.get(), surface.get()));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
QVERIFY(subSurface);
|
|
|
|
|
subSurface->setPosition(QPoint(-20, -10));
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(childSurface.get(), QSize(100, 50), Qt::blue);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(120, 60));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition + QPoint(20, 10));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(100, 50));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgWindowGeometryAttachBuffer()
|
2019-10-03 19:43:28 +00:00
|
|
|
|
{
|
|
|
|
|
// This test verifies that the effective window geometry remains the same when
|
|
|
|
|
// a new buffer is attached and xdg_surface.set_window_geometry is not called
|
|
|
|
|
// again. Notice that the window geometry must remain the same even if the new
|
|
|
|
|
// buffer is smaller.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
|
const QPointF oldPosition = window->pos();
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 180, 80);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(frameGeometryChangedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(100, 50), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(frameGeometryChangedSpy.count(), 2);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(90, 40));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(100, 50));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(0, 0, 100, 50);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(frameGeometryChangedSpy.count(), 3);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(100, 50));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(100, 50));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgWindowGeometryAttachSubSurface()
|
2019-10-03 19:43:28 +00:00
|
|
|
|
{
|
|
|
|
|
// This test verifies that the effective window geometry remains the same
|
|
|
|
|
// when a new sub-surface is added and xdg_surface.set_window_geometry is
|
|
|
|
|
// not called again.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
|
const QPointF oldPosition = window->pos();
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 180, 80);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> childSurface(Test::createSurface());
|
2022-11-07 21:33:00 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::SubSurface> subSurface(Test::createSubSurface(childSurface.get(), surface.get()));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
QVERIFY(subSurface);
|
|
|
|
|
subSurface->setPosition(QPoint(-20, -20));
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(childSurface.get(), QSize(100, 50), Qt::blue);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(-15, -15, 50, 40);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().topLeft(), oldPosition);
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(50, 40));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().topLeft(), oldPosition - QPoint(-15, -15));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgWindowGeometryInteractiveResize()
|
2019-10-03 19:43:28 +00:00
|
|
|
|
{
|
|
|
|
|
// This test verifies that correct window geometry is provided along each
|
|
|
|
|
// configure event when an xdg-shell is being interactively resized.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 180, 80);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2023-02-18 11:38:08 +00:00
|
|
|
|
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
|
|
|
|
|
QSignalSpy interactiveMoveResizeSteppedSpy(window, &Window::interactiveMoveResizeStepped);
|
|
|
|
|
QSignalSpy interactiveMoveResizeFinishedSpy(window, &Window::interactiveMoveResizeFinished);
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Start interactively resizing the window.
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QCOMPARE(workspace()->moveResizeWindow(), nullptr);
|
2019-10-03 19:43:28 +00:00
|
|
|
|
workspace()->slotWindowResize();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(workspace()->moveResizeWindow(), window);
|
2023-02-18 11:38:08 +00:00
|
|
|
|
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 1);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
|
|
|
|
Test::XdgToplevel::States states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Resizing));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
// Go right.
|
2023-02-19 23:35:44 +00:00
|
|
|
|
QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
window->keyPressEvent(Qt::Key_Right);
|
|
|
|
|
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
2020-04-02 16:18:01 +00:00
|
|
|
|
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Resizing));
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(188, 80));
|
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 188, 80);
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(208, 100), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2023-02-18 11:38:08 +00:00
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(208, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(188, 80));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
// Go down.
|
2020-04-02 16:18:01 +00:00
|
|
|
|
cursorPos = KWin::Cursors::self()->mouse()->pos();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
window->keyPressEvent(Qt::Key_Down);
|
|
|
|
|
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
2020-04-02 16:18:01 +00:00
|
|
|
|
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(0, 8));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 4);
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Resizing));
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(188, 88));
|
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 188, 88);
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(208, 108), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2023-02-18 11:38:08 +00:00
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 2);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(208, 108));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(188, 88));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Finish resizing the window.
|
|
|
|
|
window->keyPressEvent(Qt::Key_Enter);
|
2023-02-18 11:38:08 +00:00
|
|
|
|
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 1);
|
2022-04-23 08:33:23 +00:00
|
|
|
|
QCOMPARE(workspace()->moveResizeWindow(), nullptr);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 5);
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Resizing));
|
2019-05-17 14:13:54 +00:00
|
|
|
|
|
2019-10-03 19:43:28 +00:00
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
}
|
2019-05-17 14:13:54 +00:00
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgWindowGeometryFullScreen()
|
2019-10-03 19:43:28 +00:00
|
|
|
|
{
|
|
|
|
|
// This test verifies that an xdg-shell receives correct window geometry when
|
|
|
|
|
// its fullscreen state gets changed.
|
2019-05-17 14:13:54 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2019-05-17 14:13:54 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 180, 80);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
2019-05-17 14:13:54 +00:00
|
|
|
|
|
2019-10-03 19:43:28 +00:00
|
|
|
|
workspace()->slotWindowFullScreen();
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024));
|
|
|
|
|
Test::XdgToplevel::States states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Fullscreen));
|
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(0, 0, 1280, 1024);
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(1280, 1024), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(1280, 1024));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
workspace()->slotWindowFullScreen();
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(180, 80));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Fullscreen));
|
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 180, 80);
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(200, 100), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testXdgWindowGeometryMaximize()
|
2019-10-03 19:43:28 +00:00
|
|
|
|
{
|
|
|
|
|
// This test verifies that an xdg-shell receives correct window geometry when
|
|
|
|
|
// its maximized state gets changed.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 180, 80);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
workspace()->slotWindowMaximize();
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024));
|
|
|
|
|
Test::XdgToplevel::States states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Maximized));
|
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(0, 0, 1280, 1024);
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(1280, 1024), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(1280, 1024));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
workspace()->slotWindowMaximize();
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(180, 80));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 10, 180, 80);
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(200, 100), Qt::blue);
|
2020-02-05 09:28:50 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(180, 80));
|
2019-10-03 19:43:28 +00:00
|
|
|
|
|
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2019-05-17 14:13:54 +00:00
|
|
|
|
}
|
2019-02-26 13:41:07 +00:00
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testPointerInputTransform()
|
2020-07-14 11:34:25 +00:00
|
|
|
|
{
|
2022-04-22 18:11:29 +00:00
|
|
|
|
// This test verifies that XdgToplevelWindow provides correct input transform matrix.
|
2020-07-14 11:34:25 +00:00
|
|
|
|
// The input transform matrix is used by seat to map pointer events from the global
|
|
|
|
|
// screen coordinates to the surface-local coordinates.
|
|
|
|
|
|
|
|
|
|
// Get a wl_pointer object on the client side.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Pointer> pointer(Test::waylandSeat()->createPointer());
|
2020-07-14 11:34:25 +00:00
|
|
|
|
QVERIFY(pointer);
|
|
|
|
|
QVERIFY(pointer->isValid());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy pointerEnteredSpy(pointer.get(), &KWayland::Client::Pointer::entered);
|
|
|
|
|
QSignalSpy pointerMotionSpy(pointer.get(), &KWayland::Client::Pointer::motion);
|
2020-07-14 11:34:25 +00:00
|
|
|
|
|
|
|
|
|
// Create an xdg_toplevel surface and wait for the compositor to catch up.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
2020-07-14 11:34:25 +00:00
|
|
|
|
|
|
|
|
|
// Enter the surface.
|
|
|
|
|
quint32 timestamp = 0;
|
2022-04-23 19:51:16 +00:00
|
|
|
|
Test::pointerMotion(window->pos(), timestamp++);
|
2020-07-14 11:34:25 +00:00
|
|
|
|
QVERIFY(pointerEnteredSpy.wait());
|
|
|
|
|
|
|
|
|
|
// Move the pointer to (10, 5) relative to the upper left frame corner, which is located
|
|
|
|
|
// at (0, 0) in the surface-local coordinates.
|
2022-10-21 21:44:43 +00:00
|
|
|
|
Test::pointerMotion(window->pos() + QPointF(10, 5), timestamp++);
|
2020-07-14 11:34:25 +00:00
|
|
|
|
QVERIFY(pointerMotionSpy.wait());
|
2022-10-21 21:44:43 +00:00
|
|
|
|
QCOMPARE(pointerMotionSpy.last().first().toPointF(), QPointF(10, 5));
|
2020-07-14 11:34:25 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Let's pretend that the window has changed the extents of the client-side drop-shadow
|
2020-07-14 11:34:25 +00:00
|
|
|
|
// but the frame geometry didn't change.
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QSignalSpy bufferGeometryChangedSpy(window, &Window::bufferGeometryChanged);
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->set_window_geometry(10, 20, 200, 100);
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(220, 140), Qt::blue);
|
2020-07-14 11:34:25 +00:00
|
|
|
|
QVERIFY(bufferGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(frameGeometryChangedSpy.count(), 0);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->frameGeometry().size(), QSize(200, 100));
|
|
|
|
|
QCOMPARE(window->bufferGeometry().size(), QSize(220, 140));
|
2020-07-14 11:34:25 +00:00
|
|
|
|
|
|
|
|
|
// Move the pointer to (20, 50) relative to the upper left frame corner, which is located
|
|
|
|
|
// at (10, 20) in the surface-local coordinates.
|
2022-10-21 21:44:43 +00:00
|
|
|
|
Test::pointerMotion(window->pos() + QPointF(20, 50), timestamp++);
|
2020-07-14 11:34:25 +00:00
|
|
|
|
QVERIFY(pointerMotionSpy.wait());
|
2022-10-21 21:44:43 +00:00
|
|
|
|
QCOMPARE(pointerMotionSpy.last().first().toPointF(), QPointF(10, 20) + QPointF(20, 50));
|
2020-07-14 11:34:25 +00:00
|
|
|
|
|
|
|
|
|
// Destroy the xdg-toplevel surface.
|
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2020-07-14 11:34:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testReentrantSetFrameGeometry()
|
2020-07-20 19:33:19 +00:00
|
|
|
|
{
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
|
// This test verifies that calling moveResize() from a slot connected directly
|
2020-07-20 19:33:19 +00:00
|
|
|
|
// to the frameGeometryChanged() signal won't cause an infinite recursion.
|
|
|
|
|
|
|
|
|
|
// Create an xdg-toplevel surface and wait for the compositor to catch up.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(200, 100), Qt::red);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QCOMPARE(window->pos(), QPoint(0, 0));
|
2020-07-20 19:33:19 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Let's pretend that there is a script that really wants the window to be at (100, 100).
|
|
|
|
|
connect(window, &Window::frameGeometryChanged, this, [window]() {
|
2022-05-16 20:13:39 +00:00
|
|
|
|
window->moveResize(QRectF(QPointF(100, 100), window->size()));
|
2020-07-20 19:33:19 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Trigger the lambda above.
|
2022-04-23 19:51:16 +00:00
|
|
|
|
window->move(QPoint(40, 50));
|
2020-07-20 19:33:19 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Eventually, the window will end up at (100, 100).
|
|
|
|
|
QCOMPARE(window->pos(), QPoint(100, 100));
|
2020-07-20 19:33:19 +00:00
|
|
|
|
|
|
|
|
|
// Destroy the xdg-toplevel surface.
|
|
|
|
|
shellSurface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2020-07-20 19:33:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testDoubleMaximize()
|
2020-10-14 18:53:07 +00:00
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// This test verifies that the case where a window issues two set_maximized() requests
|
2020-10-14 18:53:07 +00:00
|
|
|
|
// separated by the initial commit is handled properly.
|
|
|
|
|
|
|
|
|
|
// Create the test surface.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_maximized();
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-10-14 18:53:07 +00:00
|
|
|
|
|
|
|
|
|
// Wait for the compositor to respond with a configure event.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
|
|
|
|
|
|
|
|
|
QSize size = toplevelConfigureRequestedSpy.last().at(0).toSize();
|
2020-10-14 18:53:07 +00:00
|
|
|
|
QCOMPARE(size, QSize(1280, 1024));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
Test::XdgToplevel::States states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-10-14 18:53:07 +00:00
|
|
|
|
|
|
|
|
|
// Send another set_maximized() request, but do not attach any buffer yet.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->set_maximized();
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-10-14 18:53:07 +00:00
|
|
|
|
|
|
|
|
|
// The compositor must respond with another configure event even if the state hasn't changed.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
|
|
|
|
size = toplevelConfigureRequestedSpy.last().at(0).toSize();
|
2020-10-14 18:53:07 +00:00
|
|
|
|
QCOMPARE(size, QSize(1280, 1024));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-10-14 18:53:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testDoubleFullscreenSeparatedByCommit()
|
2022-01-24 13:16:45 +00:00
|
|
|
|
{
|
|
|
|
|
// Some applications do weird things at startup and this is one of them. This test verifies
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// that the window will have good frame geometry if the window has issued several
|
2022-01-24 13:16:45 +00:00
|
|
|
|
// xdg_toplevel.set_fullscreen requests and they are separated by a surface commit with
|
|
|
|
|
// no attached buffer.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2022-01-24 13:16:45 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
|
|
|
|
|
// Tell the compositor that we want the window to be shown in fullscreen mode.
|
|
|
|
|
shellSurface->set_fullscreen(nullptr);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
|
|
|
|
|
QVERIFY(toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>() & Test::XdgToplevel::State::Fullscreen);
|
|
|
|
|
|
|
|
|
|
// Ask again.
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
|
|
|
shellSurface->set_fullscreen(nullptr);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
|
|
|
|
|
QVERIFY(toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>() & Test::XdgToplevel::State::Fullscreen);
|
|
|
|
|
|
|
|
|
|
// Map the window.
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window->isFullScreen());
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRect(0, 0, 1280, 1024));
|
2022-01-24 13:16:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMaximizeHorizontal()
|
2020-09-10 10:59:56 +00:00
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Create the test window.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
|
|
|
|
// Wait for the initial configure event.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
Test::XdgToplevel::States states;
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(0, 0));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Activated));
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Map the window.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(800, 600), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QVERIFY(window->isMaximizable());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeMode::MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeMode::MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->size(), QSize(800, 600));
|
|
|
|
|
|
|
|
|
|
// We should receive a configure event when the window becomes active.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Maximize the test window in horizontal direction.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
workspace()->slotWindowMaximizeHorizontal();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(1280, 600));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Draw contents of the maximized window.
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(1280, 600), Qt::blue);
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->size(), QSize(1280, 600));
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeHorizontal);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Restore the window.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
workspace()->slotWindowMaximizeHorizontal();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeHorizontal);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 4);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(800, 600));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Draw contents of the restored window.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(800, 600), Qt::blue);
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->size(), QSize(800, 600));
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Destroy the window.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
shellSurface.reset();
|
|
|
|
|
surface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMaximizeVertical()
|
2020-09-10 10:59:56 +00:00
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Create the test window.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
|
|
|
|
// Wait for the initial configure event.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
Test::XdgToplevel::States states;
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(0, 0));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Activated));
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Map the window.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(800, 600), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QVERIFY(window->isMaximizable());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeMode::MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeMode::MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->size(), QSize(800, 600));
|
|
|
|
|
|
|
|
|
|
// We should receive a configure event when the window becomes active.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Maximize the test window in vertical direction.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
workspace()->slotWindowMaximizeVertical();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(800, 1024));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Draw contents of the maximized window.
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(800, 1024), Qt::blue);
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->size(), QSize(800, 1024));
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeVertical);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Restore the window.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
workspace()->slotWindowMaximizeVertical();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeVertical);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 4);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(800, 600));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Draw contents of the restored window.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(800, 600), Qt::blue);
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->size(), QSize(800, 600));
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Destroy the window.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
shellSurface.reset();
|
|
|
|
|
surface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMaximizeFull()
|
2020-09-10 10:59:56 +00:00
|
|
|
|
{
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Create the test window.
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
2021-05-11 05:26:51 +00:00
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
2021-09-03 17:54:03 +00:00
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
|
|
|
|
// Wait for the initial configure event.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
Test::XdgToplevel::States states;
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(0, 0));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Activated));
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Map the window.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(800, 600), Qt::blue);
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QVERIFY(window);
|
|
|
|
|
QVERIFY(window->isActive());
|
|
|
|
|
QVERIFY(window->isMaximizable());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeMode::MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeMode::MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->size(), QSize(800, 600));
|
|
|
|
|
|
|
|
|
|
// We should receive a configure event when the window becomes active.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Maximize the test window.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
workspace()->slotWindowMaximize();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Draw contents of the maximized window.
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(1280, 1024), Qt::blue);
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->size(), QSize(1280, 1024));
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Restore the window.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
workspace()->slotWindowMaximize();
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
2021-05-11 05:26:51 +00:00
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 4);
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(800, 600));
|
|
|
|
|
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
|
|
|
|
|
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Draw contents of the restored window.
|
2021-05-11 05:26:51 +00:00
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
2022-08-01 21:29:02 +00:00
|
|
|
|
Test::render(surface.get(), QSize(800, 600), Qt::blue);
|
2023-02-15 19:26:30 +00:00
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2022-04-23 19:51:16 +00:00
|
|
|
|
QCOMPARE(window->size(), QSize(800, 600));
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
2020-09-10 10:59:56 +00:00
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// Destroy the window.
|
2020-09-10 10:59:56 +00:00
|
|
|
|
shellSurface.reset();
|
|
|
|
|
surface.reset();
|
2023-04-21 20:28:48 +00:00
|
|
|
|
QVERIFY(Test::waitForWindowClosed(window));
|
2020-09-10 10:59:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 07:52:57 +00:00
|
|
|
|
void TestXdgShellWindow::testSendMaximizedWindowToAnotherOutput()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that the maximized window will have correct geometry restore
|
|
|
|
|
// after it's sent to another output.
|
|
|
|
|
|
|
|
|
|
const auto outputs = workspace()->outputs();
|
|
|
|
|
|
|
|
|
|
// Create the window.
|
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
|
QVERIFY(window);
|
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the activated state.
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
|
|
// Move the window to the left monitor.
|
|
|
|
|
window->move(QPointF(10, 20));
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(10, 20, 100, 50));
|
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
|
|
|
|
|
|
// Make the window maximized.
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
|
shellSurface->set_maximized();
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 1280, 1024));
|
|
|
|
|
QCOMPARE(window->geometryRestore(), QRectF(10, 20, 100, 50));
|
|
|
|
|
QCOMPARE(window->output(), outputs[0]);
|
|
|
|
|
|
|
|
|
|
// Send the window to another output.
|
2024-06-06 15:28:52 +00:00
|
|
|
|
window->sendToOutput(outputs[1]);
|
2022-09-14 07:52:57 +00:00
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
|
|
|
|
QCOMPARE(window->geometryRestore(), QRectF(1280 + 10, 20, 100, 50));
|
|
|
|
|
QCOMPARE(window->output(), outputs[1]);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-10 11:42:53 +00:00
|
|
|
|
void TestXdgShellWindow::testInteractiveMoveUnmaximizeFull()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that a maximized xdg-toplevel is going to be properly unmaximized when it's dragged.
|
|
|
|
|
|
|
|
|
|
// Create the window.
|
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the activated state.
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
|
|
// Make the window maximized.
|
|
|
|
|
const QRectF originalGeometry = window->frameGeometry();
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
|
window->maximize(MaximizeFull);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
|
|
|
|
|
|
// Start interactive move.
|
|
|
|
|
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
|
|
|
|
|
QSignalSpy interactiveMoveResizeSteppedSpy(window, &Window::interactiveMoveResizeStepped);
|
|
|
|
|
QSignalSpy interactiveMoveResizeFinishedSpy(window, &Window::interactiveMoveResizeFinished);
|
|
|
|
|
const qreal xOffset = 0.25;
|
|
|
|
|
const qreal yOffset = 0.5;
|
|
|
|
|
quint32 timestamp = 0;
|
|
|
|
|
Test::pointerMotion(QPointF(window->x() + window->width() * xOffset, window->y() + window->height() * yOffset), timestamp++);
|
|
|
|
|
window->performMouseCommand(Options::MouseMove, input()->pointer()->pos());
|
|
|
|
|
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
|
|
|
|
|
|
// Move the window to unmaximize it.
|
|
|
|
|
const QRectF maximizedGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 100), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 0);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry);
|
|
|
|
|
|
|
|
|
|
// Move the window a tiny bit more.
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 10), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 0);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry);
|
|
|
|
|
|
|
|
|
|
// Render the window at the new size.
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(input()->pointer()->pos() - QPointF(originalGeometry.width() * xOffset, originalGeometry.height() * yOffset), originalGeometry.size()));
|
|
|
|
|
|
|
|
|
|
// Move the window again.
|
|
|
|
|
const QRectF normalGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 10), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), normalGeometry.translated(0, 10));
|
|
|
|
|
|
|
|
|
|
// Finish interactive move.
|
|
|
|
|
window->keyPressEvent(Qt::Key_Enter);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestXdgShellWindow::testInteractiveMoveUnmaximizeInitiallyFull()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that an initially maximized xdg-toplevel will be properly unmaximized when it's dragged.
|
|
|
|
|
|
|
|
|
|
// Create the window.
|
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), [](Test::XdgToplevel *toplevel) {
|
|
|
|
|
toplevel->set_maximized();
|
|
|
|
|
}));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the activated state.
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
|
|
// Start interactive move.
|
|
|
|
|
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
|
|
|
|
|
QSignalSpy interactiveMoveResizeSteppedSpy(window, &Window::interactiveMoveResizeStepped);
|
|
|
|
|
QSignalSpy interactiveMoveResizeFinishedSpy(window, &Window::interactiveMoveResizeFinished);
|
|
|
|
|
const qreal xOffset = 0.25;
|
|
|
|
|
const qreal yOffset = 0.5;
|
|
|
|
|
quint32 timestamp = 0;
|
|
|
|
|
Test::pointerMotion(QPointF(window->x() + window->width() * xOffset, window->y() + window->height() * yOffset), timestamp++);
|
|
|
|
|
window->performMouseCommand(Options::MouseMove, input()->pointer()->pos());
|
|
|
|
|
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
|
|
|
|
|
|
|
|
|
// Move the window to unmaximize it.
|
|
|
|
|
const QRectF maximizedGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 100), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 0);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry);
|
|
|
|
|
|
|
|
|
|
// Move the window a tiny bit more.
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 10), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 0);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry);
|
|
|
|
|
|
|
|
|
|
// Render the window at the new size.
|
|
|
|
|
const QSize restoredSize(100, 50);
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0));
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), restoredSize, Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(input()->pointer()->pos() - QPointF(restoredSize.width() * xOffset, restoredSize.height() * yOffset), restoredSize));
|
|
|
|
|
|
|
|
|
|
// Move the window again.
|
|
|
|
|
const QRectF normalGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 10), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), normalGeometry.translated(0, 10));
|
|
|
|
|
|
|
|
|
|
// Finish interactive move.
|
|
|
|
|
window->keyPressEvent(Qt::Key_Enter);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestXdgShellWindow::testInteractiveMoveUnmaximizeHorizontal()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that a maximized horizontally xdg-toplevel is going to be properly unmaximized when it's dragged horizontally.
|
|
|
|
|
|
|
|
|
|
// Create the window.
|
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the activated state.
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
|
|
// Make the window maximized.
|
|
|
|
|
const QRectF originalGeometry = window->frameGeometry();
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
|
window->maximize(MaximizeHorizontal);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeHorizontal);
|
|
|
|
|
|
|
|
|
|
// Start interactive move.
|
|
|
|
|
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
|
|
|
|
|
QSignalSpy interactiveMoveResizeSteppedSpy(window, &Window::interactiveMoveResizeStepped);
|
|
|
|
|
QSignalSpy interactiveMoveResizeFinishedSpy(window, &Window::interactiveMoveResizeFinished);
|
|
|
|
|
const qreal xOffset = 0.25;
|
|
|
|
|
const qreal yOffset = 0.5;
|
|
|
|
|
quint32 timestamp = 0;
|
|
|
|
|
Test::pointerMotion(QPointF(window->x() + window->width() * xOffset, window->y() + window->height() * yOffset), timestamp++);
|
|
|
|
|
window->performMouseCommand(Options::MouseMove, input()->pointer()->pos());
|
|
|
|
|
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeHorizontal);
|
|
|
|
|
|
|
|
|
|
// Move the window vertically, it's not going to be unmaximized.
|
|
|
|
|
const QRectF maximizedGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 100), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry.translated(0, 100));
|
|
|
|
|
|
|
|
|
|
// Move the window horizontally.
|
|
|
|
|
Test::pointerMotionRelative(QPointF(100, 0), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry.translated(0, 100));
|
|
|
|
|
|
|
|
|
|
// Move the window to the right a bit more.
|
|
|
|
|
Test::pointerMotionRelative(QPointF(10, 0), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeHorizontal);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry.translated(0, 100));
|
|
|
|
|
|
|
|
|
|
// Render the window at the new size.
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(input()->pointer()->pos() - QPointF(originalGeometry.width() * xOffset, originalGeometry.height() * yOffset), originalGeometry.size()));
|
|
|
|
|
|
|
|
|
|
// Move the window again.
|
|
|
|
|
const QRectF normalGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(10, 0), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 2);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), normalGeometry.translated(10, 0));
|
|
|
|
|
|
|
|
|
|
// Finish interactive move.
|
|
|
|
|
window->keyPressEvent(Qt::Key_Enter);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestXdgShellWindow::testInteractiveMoveUnmaximizeVertical()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that a maximized vertically xdg-toplevel is going to be properly unmaximized when it's dragged vertically.
|
|
|
|
|
|
|
|
|
|
// Create the window.
|
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
|
|
|
|
|
|
|
|
|
// Wait for the compositor to send a configure event with the activated state.
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
|
|
|
|
|
// Make the window maximized.
|
|
|
|
|
const QRectF originalGeometry = window->frameGeometry();
|
|
|
|
|
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
|
|
|
|
window->maximize(MaximizeVertical);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeVertical);
|
|
|
|
|
|
|
|
|
|
// Start interactive move.
|
|
|
|
|
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
|
|
|
|
|
QSignalSpy interactiveMoveResizeSteppedSpy(window, &Window::interactiveMoveResizeStepped);
|
|
|
|
|
QSignalSpy interactiveMoveResizeFinishedSpy(window, &Window::interactiveMoveResizeFinished);
|
|
|
|
|
const qreal xOffset = 0.25;
|
|
|
|
|
const qreal yOffset = 0.5;
|
|
|
|
|
quint32 timestamp = 0;
|
|
|
|
|
Test::pointerMotion(QPointF(window->x() + window->width() * xOffset, window->y() + window->height() * yOffset), timestamp++);
|
|
|
|
|
window->performMouseCommand(Options::MouseMove, input()->pointer()->pos());
|
|
|
|
|
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeVertical);
|
|
|
|
|
|
|
|
|
|
// Move the window to the right, it's not going to be unmaximized.
|
|
|
|
|
const QRectF maximizedGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(100, 0), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry.translated(100, 0));
|
|
|
|
|
|
|
|
|
|
// Move the window vertically.
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 100), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry.translated(100, 0));
|
|
|
|
|
|
|
|
|
|
// Move the window down a bit more.
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 10), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 1);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeVertical);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), maximizedGeometry.translated(100, 0));
|
|
|
|
|
|
|
|
|
|
// Render the window at the new size.
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
|
|
|
|
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), Qt::red);
|
|
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), QRectF(input()->pointer()->pos() - QPointF(originalGeometry.width() * xOffset, originalGeometry.height() * yOffset), originalGeometry.size()));
|
|
|
|
|
|
|
|
|
|
// Move the window again.
|
|
|
|
|
const QRectF normalGeometry = window->frameGeometry();
|
|
|
|
|
Test::pointerMotionRelative(QPointF(0, 10), timestamp++);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeSteppedSpy.count(), 2);
|
|
|
|
|
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
|
|
|
|
QCOMPARE(window->frameGeometry(), normalGeometry.translated(0, 10));
|
|
|
|
|
|
|
|
|
|
// Finish interactive move.
|
|
|
|
|
window->keyPressEvent(Qt::Key_Enter);
|
|
|
|
|
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 1);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testMaximizeAndChangeDecorationModeAfterInitialCommit()
|
2021-12-07 07:32:33 +00:00
|
|
|
|
{
|
|
|
|
|
// Ideally, the app would initialize the xdg-toplevel surface before the initial commit, but
|
|
|
|
|
// many don't do it. They initialize the surface after the first commit.
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// This test verifies that the window will receive a configure event with correct size
|
2021-12-07 07:32:33 +00:00
|
|
|
|
// if an xdg-toplevel surface is set maximized and decoration mode changes after initial commit.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
std::unique_ptr<Test::XdgToplevelDecorationV1> decoration(Test::createXdgToplevelDecorationV1(shellSurface.get()));
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-12-07 07:32:33 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
|
2021-12-08 09:52:04 +00:00
|
|
|
|
// Commit the initial state.
|
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0));
|
|
|
|
|
|
2021-12-07 07:32:33 +00:00
|
|
|
|
// Request maximized mode and set decoration mode, i.e. perform late initialization.
|
|
|
|
|
shellSurface->set_maximized();
|
|
|
|
|
decoration->set_mode(Test::XdgToplevelDecorationV1::mode_client_side);
|
|
|
|
|
|
|
|
|
|
// The compositor will respond with a new configure event, which should contain maximized state.
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>(), Test::XdgToplevel::State::Maximized);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testFullScreenAndChangeDecorationModeAfterInitialCommit()
|
2021-12-07 07:32:33 +00:00
|
|
|
|
{
|
|
|
|
|
// Ideally, the app would initialize the xdg-toplevel surface before the initial commit, but
|
|
|
|
|
// many don't do it. They initialize the surface after the first commit.
|
2022-04-23 19:51:16 +00:00
|
|
|
|
// This test verifies that the window will receive a configure event with correct size
|
2021-12-07 07:32:33 +00:00
|
|
|
|
// if an xdg-toplevel surface is set fullscreen and decoration mode changes after initial commit.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
std::unique_ptr<Test::XdgToplevelDecorationV1> decoration(Test::createXdgToplevelDecorationV1(shellSurface.get()));
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-12-07 07:32:33 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
|
2021-12-08 09:52:04 +00:00
|
|
|
|
// Commit the initial state.
|
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0));
|
|
|
|
|
|
2021-12-07 07:32:33 +00:00
|
|
|
|
// Request fullscreen mode and set decoration mode, i.e. perform late initialization.
|
|
|
|
|
shellSurface->set_fullscreen(nullptr);
|
|
|
|
|
decoration->set_mode(Test::XdgToplevelDecorationV1::mode_client_side);
|
|
|
|
|
|
|
|
|
|
// The compositor will respond with a new configure event, which should contain fullscreen state.
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>(), Test::XdgToplevel::State::Fullscreen);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
void TestXdgShellWindow::testChangeDecorationModeAfterInitialCommit()
|
2021-12-07 07:47:39 +00:00
|
|
|
|
{
|
|
|
|
|
// This test verifies that the compositor will respond with a good configure event when
|
|
|
|
|
// the decoration mode changes after the first surface commit but before the surface is mapped.
|
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
|
|
|
|
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
|
|
|
|
|
std::unique_ptr<Test::XdgToplevelDecorationV1> decoration(Test::createXdgToplevelDecorationV1(shellSurface.get()));
|
|
|
|
|
QSignalSpy decorationConfigureRequestedSpy(decoration.get(), &Test::XdgToplevelDecorationV1::configureRequested);
|
|
|
|
|
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
2021-12-07 07:47:39 +00:00
|
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
|
|
|
|
|
|
// Perform the initial commit.
|
|
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0));
|
|
|
|
|
QCOMPARE(decorationConfigureRequestedSpy.last().at(0).value<Test::XdgToplevelDecorationV1::mode>(), Test::XdgToplevelDecorationV1::mode_server_side);
|
|
|
|
|
|
|
|
|
|
// Change decoration mode.
|
|
|
|
|
decoration->set_mode(Test::XdgToplevelDecorationV1::mode_client_side);
|
|
|
|
|
|
|
|
|
|
// The configure event should still have 0x0 size.
|
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
|
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0));
|
|
|
|
|
QCOMPARE(decorationConfigureRequestedSpy.last().at(0).value<Test::XdgToplevelDecorationV1::mode>(), Test::XdgToplevelDecorationV1::mode_client_side);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 06:49:59 +00:00
|
|
|
|
void TestXdgShellWindow::testModal()
|
|
|
|
|
{
|
|
|
|
|
auto parentSurface = Test::createSurface();
|
|
|
|
|
auto parentToplevel = Test::createXdgToplevelSurface(parentSurface.get());
|
|
|
|
|
auto parentWindow = Test::renderAndWaitForShown(parentSurface.get(), {200, 200}, Qt::cyan);
|
|
|
|
|
QVERIFY(parentWindow);
|
|
|
|
|
|
|
|
|
|
auto childSurface = Test::createSurface();
|
|
|
|
|
auto childToplevel = Test::createXdgToplevelSurface(childSurface.get(), [&parentToplevel](Test::XdgToplevel *toplevel) {
|
|
|
|
|
toplevel->set_parent(parentToplevel->object());
|
|
|
|
|
});
|
|
|
|
|
auto childWindow = Test::renderAndWaitForShown(childSurface.get(), {200, 200}, Qt::yellow);
|
|
|
|
|
QVERIFY(childWindow);
|
|
|
|
|
QVERIFY(!childWindow->isModal());
|
|
|
|
|
QCOMPARE(childWindow->transientFor(), parentWindow);
|
|
|
|
|
|
|
|
|
|
auto dialog = Test::createXdgDialogV1(childToplevel.get());
|
|
|
|
|
QVERIFY(Test::waylandSync());
|
|
|
|
|
QVERIFY(dialog);
|
|
|
|
|
QVERIFY(!childWindow->isModal());
|
|
|
|
|
|
|
|
|
|
QSignalSpy modalChangedSpy(childWindow, &Window::modalChanged);
|
|
|
|
|
|
|
|
|
|
dialog->set_modal();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(modalChangedSpy.wait());
|
|
|
|
|
QVERIFY(childWindow->isModal());
|
|
|
|
|
|
|
|
|
|
dialog->unset_modal();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(modalChangedSpy.wait());
|
|
|
|
|
QVERIFY(!childWindow->isModal());
|
|
|
|
|
|
|
|
|
|
dialog->set_modal();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(modalChangedSpy.wait());
|
|
|
|
|
Workspace::self()->activateWindow(parentWindow);
|
|
|
|
|
QCOMPARE(Workspace::self()->activeWindow(), childWindow);
|
|
|
|
|
|
|
|
|
|
dialog.reset();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(modalChangedSpy.wait());
|
|
|
|
|
QVERIFY(!childWindow->isModal());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestXdgShellWindow::testCloseModal()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that the parent window will be activated when an active modal dialog is closed.
|
|
|
|
|
|
|
|
|
|
// Create a parent and a child windows.
|
|
|
|
|
auto parentSurface = Test::createSurface();
|
|
|
|
|
auto parentToplevel = Test::createXdgToplevelSurface(parentSurface.get());
|
|
|
|
|
auto parent = Test::renderAndWaitForShown(parentSurface.get(), {200, 200}, Qt::cyan);
|
|
|
|
|
QVERIFY(parent);
|
|
|
|
|
|
|
|
|
|
auto childSurface = Test::createSurface();
|
|
|
|
|
auto childToplevel = Test::createXdgToplevelSurface(childSurface.get(), [&parentToplevel](Test::XdgToplevel *toplevel) {
|
|
|
|
|
toplevel->set_parent(parentToplevel->object());
|
|
|
|
|
});
|
|
|
|
|
auto child = Test::renderAndWaitForShown(childSurface.get(), {200, 200}, Qt::yellow);
|
|
|
|
|
QVERIFY(child);
|
|
|
|
|
QVERIFY(!child->isModal());
|
|
|
|
|
QCOMPARE(child->transientFor(), parent);
|
|
|
|
|
|
|
|
|
|
// Set modal state.
|
|
|
|
|
auto dialog = Test::createXdgDialogV1(childToplevel.get());
|
|
|
|
|
QSignalSpy modalChangedSpy(child, &Window::modalChanged);
|
|
|
|
|
dialog->set_modal();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(modalChangedSpy.wait());
|
|
|
|
|
QVERIFY(child->isModal());
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), child);
|
|
|
|
|
|
|
|
|
|
// Close the child.
|
|
|
|
|
QSignalSpy childClosedSpy(child, &Window::closed);
|
|
|
|
|
childToplevel.reset();
|
|
|
|
|
childSurface.reset();
|
|
|
|
|
dialog.reset();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(childClosedSpy.wait());
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestXdgShellWindow::testCloseInactiveModal()
|
|
|
|
|
{
|
|
|
|
|
// This test verifies that the parent window will not be activated when an inactive modal dialog is closed.
|
|
|
|
|
|
|
|
|
|
// Create a parent and a child windows.
|
|
|
|
|
auto parentSurface = Test::createSurface();
|
|
|
|
|
auto parentToplevel = Test::createXdgToplevelSurface(parentSurface.get());
|
|
|
|
|
auto parent = Test::renderAndWaitForShown(parentSurface.get(), {200, 200}, Qt::cyan);
|
|
|
|
|
QVERIFY(parent);
|
|
|
|
|
|
|
|
|
|
auto childSurface = Test::createSurface();
|
|
|
|
|
auto childToplevel = Test::createXdgToplevelSurface(childSurface.get(), [&parentToplevel](Test::XdgToplevel *toplevel) {
|
|
|
|
|
toplevel->set_parent(parentToplevel->object());
|
|
|
|
|
});
|
|
|
|
|
auto child = Test::renderAndWaitForShown(childSurface.get(), {200, 200}, Qt::yellow);
|
|
|
|
|
QVERIFY(child);
|
|
|
|
|
QVERIFY(!child->isModal());
|
|
|
|
|
QCOMPARE(child->transientFor(), parent);
|
|
|
|
|
|
|
|
|
|
// Set modal state.
|
|
|
|
|
auto dialog = Test::createXdgDialogV1(childToplevel.get());
|
|
|
|
|
QSignalSpy modalChangedSpy(child, &Window::modalChanged);
|
|
|
|
|
dialog->set_modal();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(modalChangedSpy.wait());
|
|
|
|
|
QVERIFY(child->isModal());
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), child);
|
|
|
|
|
|
|
|
|
|
// Show another window.
|
|
|
|
|
auto otherSurface = Test::createSurface();
|
|
|
|
|
auto otherToplevel = Test::createXdgToplevelSurface(otherSurface.get());
|
|
|
|
|
auto otherWindow = Test::renderAndWaitForShown(otherSurface.get(), {200, 200}, Qt::magenta);
|
|
|
|
|
QVERIFY(otherWindow);
|
|
|
|
|
workspace()->setActiveWindow(otherWindow);
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), otherWindow);
|
|
|
|
|
|
|
|
|
|
// Close the child.
|
|
|
|
|
QSignalSpy childClosedSpy(child, &Window::closed);
|
|
|
|
|
childToplevel.reset();
|
|
|
|
|
childSurface.reset();
|
|
|
|
|
dialog.reset();
|
|
|
|
|
Test::flushWaylandConnection();
|
|
|
|
|
QVERIFY(childClosedSpy.wait());
|
|
|
|
|
QCOMPARE(workspace()->activeWindow(), otherWindow);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-22 18:11:29 +00:00
|
|
|
|
WAYLANDTEST_MAIN(TestXdgShellWindow)
|
|
|
|
|
#include "xdgshellwindow_test.moc"
|