diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp --- a/autotests/integration/shell_client_test.cpp +++ b/autotests/integration/shell_client_test.cpp @@ -20,6 +20,7 @@ #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 @@ void TestShellClient::initTestCase() { + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); @@ -174,6 +176,12 @@ 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 @@ 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 @@ 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 --- a/autotests/integration/x11_client_test.cpp +++ b/autotests/integration/x11_client_test.cpp @@ -24,6 +24,7 @@ #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 @@ void X11ClientTest::initTestCase() { + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); @@ -352,6 +354,13 @@ 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 @@ // 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.h b/toplevel.h --- a/toplevel.h +++ b/toplevel.h @@ -31,6 +31,7 @@ // Qt #include #include +#include // xcb #include #include @@ -458,6 +459,14 @@ **/ 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 @@ 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 diff --git a/toplevel.cpp b/toplevel.cpp --- a/toplevel.cpp +++ b/toplevel.cpp @@ -44,6 +44,7 @@ , 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 @@ // 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;