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