From 3ad9ac7229ff718532971c10076f51bc3f6e23d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 18 Nov 2018 20:13:55 +0100 Subject: [PATCH] Introduce the concept of an internal window system independent id Summary: For supporting Wayland windows in the kwin_rules_dialog we need a way to pass a window id for Wayland windows to the dialog. This id needs to be sent to the dbus interface to query window information just like the interactive query. For Wayland windows we don't really have a window id and it would require to also pass the windowing system to kwin_rules_dialog and back through the dbus interface. To not complicate things this change introduces a windowing system independent id based on UUID. This could in future also be used internally for areas where it's window id based and used in both windowing systems. Test Plan: Adjusted test cases to verify the uuid is generated and passed to Deleted Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16986 --- autotests/integration/shell_client_test.cpp | 11 +++++++++++ autotests/integration/x11_client_test.cpp | 15 +++++++++++++++ toplevel.cpp | 2 ++ toplevel.h | 10 ++++++++++ 4 files changed, 38 insertions(+) diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp index 6e75cf8ffc..d8a8a75002 100644 --- a/autotests/integration/shell_client_test.cpp +++ b/autotests/integration/shell_client_test.cpp @@ -20,6 +20,7 @@ along with this program. If not, see . #include "kwin_wayland_test.h" #include "cursor.h" #include "effects.h" +#include "deleted.h" #include "platform.h" #include "shell_client.h" #include "screens.h" @@ -95,6 +96,7 @@ private Q_SLOTS: void TestShellClient::initTestCase() { + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); @@ -174,6 +176,12 @@ void TestShellClient::testMapUnmapMap() QVERIFY(client->property("moveable").toBool()); QVERIFY(client->property("moveableAcrossScreens").toBool()); QVERIFY(client->property("resizeable").toBool()); + QCOMPARE(client->internalId().isNull(), false); + const auto uuid = client->internalId(); + QUuid deletedUuid; + QCOMPARE(deletedUuid.isNull(), true); + + connect(client, &ShellClient::windowClosed, this, [&deletedUuid] (Toplevel *, Deleted *d) { deletedUuid = d->internalId(); }); // now unmap QSignalSpy hiddenSpy(client, &ShellClient::windowHidden); @@ -212,6 +220,7 @@ void TestShellClient::testMapUnmapMap() QCOMPARE(hiddenSpy.count(), 2); QCOMPARE(client->readyForPainting(), true); QCOMPARE(client->isHiddenInternal(), true); + QCOMPARE(client->internalId(), uuid); QVERIFY(windowClosedSpy.isEmpty()); QCOMPARE(effectsWindowHiddenSpy.count(), 2); QCOMPARE(effectsWindowHiddenSpy.last().first().value(), client->effectWindow()); @@ -221,6 +230,8 @@ void TestShellClient::testMapUnmapMap() QVERIFY(windowClosedSpy.wait()); QCOMPARE(windowClosedSpy.count(), 1); QCOMPARE(effectsWindowHiddenSpy.count(), 2); + QCOMPARE(deletedUuid.isNull(), false); + QCOMPARE(deletedUuid, uuid); } void TestShellClient::testDesktopPresenceChanged() diff --git a/autotests/integration/x11_client_test.cpp b/autotests/integration/x11_client_test.cpp index 7be40fe7bb..94ba4f62d7 100644 --- a/autotests/integration/x11_client_test.cpp +++ b/autotests/integration/x11_client_test.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . #include "effects.h" #include "effectloader.h" #include "cursor.h" +#include "deleted.h" #include "platform.h" #include "screens.h" #include "shell_client.h" @@ -60,6 +61,7 @@ private Q_SLOTS: void X11ClientTest::initTestCase() { + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); @@ -352,6 +354,13 @@ void X11ClientTest::testX11WindowId() QCOMPARE(client->windowId(), w); QVERIFY(client->isActive()); QCOMPARE(client->window(), w); + QCOMPARE(client->internalId().isNull(), false); + const auto uuid = client->internalId(); + QUuid deletedUuid; + QCOMPARE(deletedUuid.isNull(), true); + + connect(client, &Client::windowClosed, this, [&deletedUuid] (Toplevel *, Deleted *d) { deletedUuid = d->internalId(); }); + NETRootInfo rootInfo(c.data(), NET::WMAllProperties); QCOMPARE(rootInfo.activeWindow(), client->window()); @@ -379,6 +388,12 @@ void X11ClientTest::testX11WindowId() // and destroy the window again xcb_unmap_window(c.data(), w); xcb_flush(c.data()); + QSignalSpy windowClosedSpy(client, &Client::windowClosed); + QVERIFY(windowClosedSpy.isValid()); + QVERIFY(windowClosedSpy.wait()); + + QCOMPARE(deletedUuid.isNull(), false); + QCOMPARE(deletedUuid, uuid); } void X11ClientTest::testCaptionChanges() diff --git a/toplevel.cpp b/toplevel.cpp index ab04f6817f..bff868f6fe 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -44,6 +44,7 @@ Toplevel::Toplevel() , info(NULL) , ready_for_painting(true) , m_isDamaged(false) + , m_internalId(QUuid::createUuid()) , m_client() , damage_handle(None) , is_shape(false) @@ -107,6 +108,7 @@ void Toplevel::detectShape(Window id) // used only by Deleted::copy() void Toplevel::copyToDeleted(Toplevel* c) { + m_internalId = c->internalId(); geom = c->geom; m_visual = c->m_visual; bit_depth = c->bit_depth; diff --git a/toplevel.h b/toplevel.h index ae6f6526b7..a5805cb846 100644 --- a/toplevel.h +++ b/toplevel.h @@ -31,6 +31,7 @@ along with this program. If not, see . // Qt #include #include +#include // xcb #include #include @@ -458,6 +459,14 @@ public: **/ virtual bool isPopupWindow() const; + /** + * A UUID to uniquely identify this Toplevel independent of windowing system. + **/ + QUuid internalId() const + { + return m_internalId; + } + Q_SIGNALS: void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); void damaged(KWin::Toplevel* toplevel, const QRect& damage); @@ -577,6 +586,7 @@ protected: private: // when adding new data members, check also copyToDeleted() + QUuid m_internalId; Xcb::Window m_client; xcb_damage_damage_t damage_handle; QRegion damage_region; // damage is really damaged window (XDamage) and texture needs