Emit clientAdded for wayland clients

Emit the clientAdded() signal also for Wayland clients in order to unify
the API of the Workspace class for different client types.
This commit is contained in:
Vlad Zahorodnii 2020-07-22 21:35:41 +03:00 committed by Vlad Zahorodnii
parent b4e271c664
commit a17a86999b
17 changed files with 83 additions and 107 deletions

View file

@ -120,7 +120,7 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient_data()
void TestDbusInterface::testGetWindowInfoXdgShellClient() void TestDbusInterface::testGetWindowInfoXdgShellClient()
{ {
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
QScopedPointer<Surface> surface(Test::createSurface()); QScopedPointer<Surface> surface(Test::createSurface());

View file

@ -260,7 +260,7 @@ void TestIdleInhibition::testDontInhibitWhenUnmapped()
QVERIFY(inhibitor->isValid()); QVERIFY(inhibitor->isValid());
// Map the client. // Map the client.
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Test::render(surface.data(), QSize(100, 50), Qt::blue); Test::render(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(clientAddedSpy.isEmpty()); QVERIFY(clientAddedSpy.isEmpty());

View file

@ -122,7 +122,7 @@ void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
QVERIFY(leftSpy.isValid()); QVERIFY(leftSpy.isValid());
// now create the two windows and make them overlap // now create the two windows and make them overlap
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface1 = Test::createSurface(Test::waylandCompositor()); Surface *surface1 = Test::createSurface(Test::waylandCompositor());
QVERIFY(surface1); QVERIFY(surface1);

View file

@ -226,7 +226,7 @@ void LockScreenTest::testStackingOrder()
{ {
// This test verifies that the lockscreen greeter is placed above other windows. // This test verifies that the lockscreen greeter is placed above other windows.
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
LOCK LOCK

View file

@ -273,7 +273,7 @@ void PlasmaWindowTest::testLockScreenNoPlasmaWindow()
QVERIFY(plasmaWindowCreatedSpy.isValid()); QVERIFY(plasmaWindowCreatedSpy.isValid());
// this time we use a QSignalSpy on XdgShellClient as it'a a little bit more complex setup // this time we use a QSignalSpy on XdgShellClient as it'a a little bit more complex setup
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
// lock // lock
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);

View file

@ -209,7 +209,7 @@ void PointerInputTest::testWarpingUpdatesFocus()
QVERIFY(leftSpy.isValid()); QVERIFY(leftSpy.isValid());
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -257,7 +257,7 @@ void PointerInputTest::testWarpingGeneratesPointerMotion()
QVERIFY(movedSpy.isValid()); QVERIFY(movedSpy.isValid());
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -297,7 +297,7 @@ void PointerInputTest::testWarpingDuringFilter()
Cursors::self()->mouse()->setPos(10, 10); Cursors::self()->mouse()->setPos(10, 10);
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -340,7 +340,7 @@ void PointerInputTest::testUpdateFocusAfterScreenChange()
QVERIFY(enteredSpy.isValid()); QVERIFY(enteredSpy.isValid());
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -436,7 +436,7 @@ void PointerInputTest::testModifierClickUnrestrictedMove()
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -503,7 +503,7 @@ void PointerInputTest::testModifierClickUnrestrictedMoveGlobalShortcutsDisabled(
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -576,7 +576,7 @@ void PointerInputTest::testModifierScrollOpacity()
workspace()->slotReconfigure(); workspace()->slotReconfigure();
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -635,7 +635,7 @@ void PointerInputTest::testModifierScrollOpacityGlobalShortcutsDisabled()
workspace()->slotReconfigure(); workspace()->slotReconfigure();
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -685,7 +685,7 @@ void PointerInputTest::testScrollAction()
group.sync(); group.sync();
workspace()->slotReconfigure(); workspace()->slotReconfigure();
// create two windows // create two windows
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface1 = Test::createSurface(m_compositor); Surface *surface1 = Test::createSurface(m_compositor);
QVERIFY(surface1); QVERIFY(surface1);
@ -745,7 +745,7 @@ void PointerInputTest::testFocusFollowsMouse()
QCOMPARE(options->delayFocusInterval(), 200); QCOMPARE(options->delayFocusInterval(), 200);
// create two windows // create two windows
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface1 = Test::createSurface(m_compositor); Surface *surface1 = Test::createSurface(m_compositor);
QVERIFY(surface1); QVERIFY(surface1);
@ -831,7 +831,7 @@ void PointerInputTest::testMouseActionInactiveWindow()
workspace()->slotReconfigure(); workspace()->slotReconfigure();
// create two windows // create two windows
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface1 = Test::createSurface(m_compositor); Surface *surface1 = Test::createSurface(m_compositor);
QVERIFY(surface1); QVERIFY(surface1);
@ -921,7 +921,7 @@ void PointerInputTest::testMouseActionActiveWindow()
QCOMPARE(options->isClickRaise(), clickRaise); QCOMPARE(options->isClickRaise(), clickRaise);
// create two windows // create two windows
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface1 = Test::createSurface(m_compositor); Surface *surface1 = Test::createSurface(m_compositor);
QVERIFY(surface1); QVERIFY(surface1);
@ -1003,7 +1003,7 @@ void PointerInputTest::testCursorImage()
QVERIFY(!fallbackCursor.isNull()); QVERIFY(!fallbackCursor.isNull());
// create a window // create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -1104,7 +1104,7 @@ void PointerInputTest::testEffectOverrideCursorImage()
QVERIFY(!fallback.isNull()); QVERIFY(!fallback.isNull());
// now let's create a window // now let's create a window
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -1180,7 +1180,7 @@ void PointerInputTest::testPopup()
Cursors::self()->mouse()->setPos(800, 800); Cursors::self()->mouse()->setPos(800, 800);
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -1261,7 +1261,7 @@ void PointerInputTest::testDecoCancelsPopup()
QVERIFY(motionSpy.isValid()); QVERIFY(motionSpy.isValid());
Cursors::self()->mouse()->setPos(800, 800); Cursors::self()->mouse()->setPos(800, 800);
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);
@ -1338,7 +1338,7 @@ void PointerInputTest::testWindowUnderCursorWhileButtonPressed()
QVERIFY(leftSpy.isValid()); QVERIFY(leftSpy.isValid());
Cursors::self()->mouse()->setPos(800, 800); Cursors::self()->mouse()->setPos(800, 800);
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
Surface *surface = Test::createSurface(m_compositor); Surface *surface = Test::createSurface(m_compositor);
QVERIFY(surface); QVERIFY(surface);

View file

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "abstract_client.h" #include "abstract_client.h"
#include "screenlockerwatcher.h" #include "screenlockerwatcher.h"
#include "wayland_server.h" #include "wayland_server.h"
#include "workspace.h"
#include <KWayland/Client/compositor.h> #include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h> #include <KWayland/Client/connection_thread.h>
@ -64,7 +65,7 @@ namespace Test
static struct { static struct {
ConnectionThread *connection = nullptr; ConnectionThread *connection = nullptr;
EventQueue *queue = nullptr; EventQueue *queue = nullptr;
Compositor *compositor = nullptr; KWayland::Client::Compositor *compositor = nullptr;
SubCompositor *subCompositor = nullptr; SubCompositor *subCompositor = nullptr;
ServerSideDecorationManager *decoration = nullptr; ServerSideDecorationManager *decoration = nullptr;
ShadowManager *shadowManager = nullptr; ShadowManager *shadowManager = nullptr;
@ -283,7 +284,7 @@ ConnectionThread *waylandConnection()
return s_waylandConnection.connection; return s_waylandConnection.connection;
} }
Compositor *waylandCompositor() KWayland::Client::Compositor *waylandCompositor()
{ {
return s_waylandConnection.compositor; return s_waylandConnection.compositor;
} }
@ -401,7 +402,7 @@ void render(Surface *surface, const QImage &img)
AbstractClient *waitForWaylandWindowShown(int timeout) AbstractClient *waitForWaylandWindowShown(int timeout)
{ {
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
if (!clientAddedSpy.isValid()) { if (!clientAddedSpy.isValid()) {
return nullptr; return nullptr;
} }
@ -413,7 +414,7 @@ AbstractClient *waitForWaylandWindowShown(int timeout)
AbstractClient *renderAndWaitForShown(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format, int timeout) AbstractClient *renderAndWaitForShown(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format, int timeout)
{ {
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
if (!clientAddedSpy.isValid()) { if (!clientAddedSpy.isValid()) {
return nullptr; return nullptr;
} }

View file

@ -171,7 +171,7 @@ void TestXdgShellClient::testMapUnmap()
QScopedPointer<XdgShellSurface> shellSurface( QScopedPointer<XdgShellSurface> shellSurface(
Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly));
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested);
@ -878,8 +878,8 @@ void TestXdgShellClient::testUnresponsiveWindow()
// for this an external binary is launched // for this an external binary is launched
const QString kill = QFINDTESTDATA(QStringLiteral("kill")); const QString kill = QFINDTESTDATA(QStringLiteral("kill"));
QVERIFY(!kill.isEmpty()); QVERIFY(!kill.isEmpty());
QSignalSpy shellClientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(shellClientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
QScopedPointer<QProcess> process(new QProcess); QScopedPointer<QProcess> process(new QProcess);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
@ -907,12 +907,12 @@ void TestXdgShellClient::testUnresponsiveWindow()
QVERIFY(processStartedSpy.wait()); QVERIFY(processStartedSpy.wait());
AbstractClient *killClient = nullptr; AbstractClient *killClient = nullptr;
if (shellClientAddedSpy.isEmpty()) { if (clientAddedSpy.isEmpty()) {
QVERIFY(shellClientAddedSpy.wait()); QVERIFY(clientAddedSpy.wait());
} }
::kill(process->processId(), SIGUSR1); // send a signal to freeze the process ::kill(process->processId(), SIGUSR1); // send a signal to freeze the process
killClient = shellClientAddedSpy.first().first().value<AbstractClient*>(); killClient = clientAddedSpy.first().first().value<AbstractClient*>();
QVERIFY(killClient); QVERIFY(killClient);
QSignalSpy unresponsiveSpy(killClient, &AbstractClient::unresponsiveChanged); QSignalSpy unresponsiveSpy(killClient, &AbstractClient::unresponsiveChanged);
QSignalSpy killedSpy(process.data(), static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished)); QSignalSpy killedSpy(process.data(), static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished));

View file

@ -112,8 +112,6 @@ void XwaylandSelectionsTest::testSync()
QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded); QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid()); QVERIFY(clientAddedSpy.isValid());
QSignalSpy shellClientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(shellClientAddedSpy.isValid());
QSignalSpy clipboardChangedSpy(Xwl::DataBridge::self()->dataDeviceIface(), &KWaylandServer::DataDeviceInterface::selectionChanged); QSignalSpy clipboardChangedSpy(Xwl::DataBridge::self()->dataDeviceIface(), &KWaylandServer::DataDeviceInterface::selectionChanged);
QVERIFY(clipboardChangedSpy.isValid()); QVERIFY(clipboardChangedSpy.isValid());
@ -131,13 +129,8 @@ void XwaylandSelectionsTest::testSync()
QVERIFY(m_copyProcess->waitForStarted()); QVERIFY(m_copyProcess->waitForStarted());
AbstractClient *copyClient = nullptr; AbstractClient *copyClient = nullptr;
if (copyPlatform == QLatin1String("xcb")) { QVERIFY(clientAddedSpy.wait());
QVERIFY(clientAddedSpy.wait()); copyClient = clientAddedSpy.first().first().value<AbstractClient *>();
copyClient = clientAddedSpy.first().first().value<AbstractClient*>();
} else {
QVERIFY(shellClientAddedSpy.wait());
copyClient = shellClientAddedSpy.first().first().value<AbstractClient*>();
}
QVERIFY(copyClient); QVERIFY(copyClient);
if (workspace()->activeClient() != copyClient) { if (workspace()->activeClient() != copyClient) {
workspace()->activateClient(copyClient); workspace()->activateClient(copyClient);
@ -166,15 +159,9 @@ void XwaylandSelectionsTest::testSync()
QVERIFY(m_pasteProcess->waitForStarted()); QVERIFY(m_pasteProcess->waitForStarted());
AbstractClient *pasteClient = nullptr; AbstractClient *pasteClient = nullptr;
if (pastePlatform == QLatin1String("xcb")) { QVERIFY(clientAddedSpy.wait());
QVERIFY(clientAddedSpy.wait()); pasteClient = clientAddedSpy.last().first().value<AbstractClient *>();
pasteClient = clientAddedSpy.last().first().value<AbstractClient*>();
} else {
QVERIFY(shellClientAddedSpy.wait());
pasteClient = shellClientAddedSpy.last().first().value<AbstractClient*>();
}
QCOMPARE(clientAddedSpy.count(), 1); QCOMPARE(clientAddedSpy.count(), 1);
QCOMPARE(shellClientAddedSpy.count(), 1);
QVERIFY(pasteClient); QVERIFY(pasteClient);
if (workspace()->activeClient() != pasteClient) { if (workspace()->activeClient() != pasteClient) {

View file

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "main.h" #include "main.h"
#include "scene.h" #include "scene.h"
#include "unmanaged.h" #include "unmanaged.h"
#include "waylandclient.h"
#include "wayland_server.h" #include "wayland_server.h"
#include "workspace.h" #include "workspace.h"
#include "keyboard_input.h" #include "keyboard_input.h"
@ -876,40 +877,15 @@ DebugConsoleModel::DebugConsoleModel(QObject *parent)
if (waylandServer()) { if (waylandServer()) {
const auto clients = waylandServer()->clients(); const auto clients = waylandServer()->clients();
for (auto c : clients) { for (auto c : clients) {
m_waylandClients.append(c); handleClientAdded(c);
} }
// TODO: that only includes windows getting shown, not those which are only created
connect(waylandServer(), &WaylandServer::shellClientAdded, this,
[this] (AbstractClient *c) {
add(s_waylandClientId -1, m_waylandClients, c);
}
);
connect(waylandServer(), &WaylandServer::shellClientRemoved, this,
[this] (AbstractClient *c) {
remove(s_waylandClientId -1, m_waylandClients, c);
}
);
} }
const auto x11Clients = workspace()->clientList(); const auto x11Clients = workspace()->clientList();
for (auto c : x11Clients) { for (auto c : x11Clients) {
m_x11Clients.append(c); handleClientAdded(c);
} }
connect(workspace(), &Workspace::clientAdded, this, connect(workspace(), &Workspace::clientAdded, this, &DebugConsoleModel::handleClientAdded);
[this] (AbstractClient *client) { connect(workspace(), &Workspace::clientRemoved, this, &DebugConsoleModel::handleClientRemoved);
if (X11Client *x11Client = qobject_cast<X11Client *>(client)) {
add(s_x11ClientId -1, m_x11Clients, x11Client);
}
}
);
connect(workspace(), &Workspace::clientRemoved, this,
[this] (AbstractClient *ac) {
X11Client *c = qobject_cast<X11Client *>(ac);
if (!c) {
return;
}
remove(s_x11ClientId -1, m_x11Clients, c);
}
);
const auto unmangeds = workspace()->unmanagedList(); const auto unmangeds = workspace()->unmanagedList();
for (auto u : unmangeds) { for (auto u : unmangeds) {
@ -940,6 +916,36 @@ DebugConsoleModel::DebugConsoleModel(QObject *parent)
); );
} }
void DebugConsoleModel::handleClientAdded(AbstractClient *client)
{
X11Client *x11Client = qobject_cast<X11Client *>(client);
if (x11Client) {
add(s_x11ClientId - 1, m_x11Clients, x11Client);
return;
}
WaylandClient *waylandClient = qobject_cast<WaylandClient *>(client);
if (waylandClient) {
add(s_waylandClientId - 1, m_waylandClients, waylandClient);
return;
}
}
void DebugConsoleModel::handleClientRemoved(AbstractClient *client)
{
X11Client *x11Client = qobject_cast<X11Client *>(client);
if (x11Client) {
remove(s_x11ClientId - 1, m_x11Clients, x11Client);
return;
}
WaylandClient *waylandClient = qobject_cast<WaylandClient *>(client);
if (waylandClient) {
remove(s_waylandClientId - 1, m_waylandClients, waylandClient);
return;
}
}
DebugConsoleModel::~DebugConsoleModel() = default; DebugConsoleModel::~DebugConsoleModel() = default;
int DebugConsoleModel::columnCount(const QModelIndex &parent) const int DebugConsoleModel::columnCount(const QModelIndex &parent) const
@ -1241,7 +1247,7 @@ static T *clientForIndex(const QModelIndex &index, const QVector<T*> &clients, i
return clients.at(row); return clients.at(row);
} }
AbstractClient *DebugConsoleModel::waylandClient(const QModelIndex &index) const WaylandClient *DebugConsoleModel::waylandClient(const QModelIndex &index) const
{ {
return clientForIndex(index, m_waylandClients, s_waylandClientId); return clientForIndex(index, m_waylandClients, s_waylandClientId);
} }
@ -1285,14 +1291,6 @@ SurfaceTreeModel::SurfaceTreeModel(QObject *parent)
} }
connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset); connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset);
} }
if (waylandServer()) {
connect(waylandServer(), &WaylandServer::shellClientAdded, this,
[this, reset] (AbstractClient *c) {
connect(c->surface(), &SurfaceInterface::subSurfaceTreeChanged, this, reset);
reset();
}
);
}
connect(workspace(), &Workspace::clientAdded, this, connect(workspace(), &Workspace::clientAdded, this,
[this, reset] (AbstractClient *c) { [this, reset] (AbstractClient *c) {
if (c->surface()) { if (c->surface()) {

View file

@ -44,6 +44,7 @@ class X11Client;
class InternalClient; class InternalClient;
class Unmanaged; class Unmanaged;
class DebugConsoleFilter; class DebugConsoleFilter;
class WaylandClient;
class KWIN_EXPORT DebugConsoleModel : public QAbstractItemModel class KWIN_EXPORT DebugConsoleModel : public QAbstractItemModel
{ {
@ -59,6 +60,10 @@ public:
int rowCount(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override;
QModelIndex parent(const QModelIndex &child) const override; QModelIndex parent(const QModelIndex &child) const override;
private Q_SLOTS:
void handleClientAdded(AbstractClient *client);
void handleClientRemoved(AbstractClient *client);
private: private:
template <class T> template <class T>
QModelIndex indexForClient(int row, int column, const QVector<T*> &clients, int id) const; QModelIndex indexForClient(int row, int column, const QVector<T*> &clients, int id) const;
@ -73,13 +78,13 @@ private:
void add(int parentRow, QVector<T*> &clients, T *client); void add(int parentRow, QVector<T*> &clients, T *client);
template <class T> template <class T>
void remove(int parentRow, QVector<T*> &clients, T *client); void remove(int parentRow, QVector<T*> &clients, T *client);
AbstractClient *waylandClient(const QModelIndex &index) const; WaylandClient *waylandClient(const QModelIndex &index) const;
InternalClient *internalClient(const QModelIndex &index) const; InternalClient *internalClient(const QModelIndex &index) const;
X11Client *x11Client(const QModelIndex &index) const; X11Client *x11Client(const QModelIndex &index) const;
Unmanaged *unmanaged(const QModelIndex &index) const; Unmanaged *unmanaged(const QModelIndex &index) const;
int topLevelRowCount() const; int topLevelRowCount() const;
QVector<AbstractClient *> m_waylandClients; QVector<WaylandClient *> m_waylandClients;
QVector<InternalClient*> m_internalClients; QVector<InternalClient*> m_internalClients;
QVector<X11Client *> m_x11Clients; QVector<X11Client *> m_x11Clients;
QVector<Unmanaged*> m_unmanageds; QVector<Unmanaged*> m_unmanageds;

View file

@ -258,12 +258,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
setupClientConnections(client); setupClientConnections(client);
} }
if (auto w = waylandServer()) { if (auto w = waylandServer()) {
connect(w, &WaylandServer::shellClientAdded, this, [this](AbstractClient *c) {
if (c->readyForPainting())
slotClientShown(c);
else
connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
});
const auto clients = waylandServer()->clients(); const auto clients = waylandServer()->clients();
for (AbstractClient *c : clients) { for (AbstractClient *c : clients) {
if (c->readyForPainting()) { if (c->readyForPainting()) {

View file

@ -163,7 +163,6 @@ void PointerInputRedirection::init()
const auto clients = workspace()->allClientList(); const auto clients = workspace()->allClientList();
std::for_each(clients.begin(), clients.end(), setupMoveResizeConnection); std::for_each(clients.begin(), clients.end(), setupMoveResizeConnection);
connect(workspace(), &Workspace::clientAdded, this, setupMoveResizeConnection); connect(workspace(), &Workspace::clientAdded, this, setupMoveResizeConnection);
connect(waylandServer(), &WaylandServer::shellClientAdded, this, setupMoveResizeConnection);
// warp the cursor to center of screen // warp the cursor to center of screen
warp(screens()->geometry().center()); warp(screens()->geometry().center());
@ -964,7 +963,6 @@ CursorImage::CursorImage(PointerInputRedirection *parent)
const auto clients = workspace()->allClientList(); const auto clients = workspace()->allClientList();
std::for_each(clients.begin(), clients.end(), setupMoveResizeConnection); std::for_each(clients.begin(), clients.end(), setupMoveResizeConnection);
connect(workspace(), &Workspace::clientAdded, this, setupMoveResizeConnection); connect(workspace(), &Workspace::clientAdded, this, setupMoveResizeConnection);
connect(waylandServer(), &WaylandServer::shellClientAdded, this, setupMoveResizeConnection);
loadThemeCursor(Qt::ArrowCursor, &m_fallbackCursor); loadThemeCursor(Qt::ArrowCursor, &m_fallbackCursor);
m_surfaceRenderedTimer.start(); m_surfaceRenderedTimer.start();

View file

@ -21,7 +21,7 @@
#include "popup_input_filter.h" #include "popup_input_filter.h"
#include "abstract_client.h" #include "abstract_client.h"
#include "deleted.h" #include "deleted.h"
#include "wayland_server.h" #include "workspace.h"
#include <QMouseEvent> #include <QMouseEvent>
@ -31,7 +31,7 @@ namespace KWin
PopupInputFilter::PopupInputFilter() PopupInputFilter::PopupInputFilter()
: QObject() : QObject()
{ {
connect(waylandServer(), &WaylandServer::shellClientAdded, this, &PopupInputFilter::handleClientAdded); connect(workspace(), &Workspace::clientAdded, this, &PopupInputFilter::handleClientAdded);
} }
void PopupInputFilter::handleClientAdded(Toplevel *client) void PopupInputFilter::handleClientAdded(Toplevel *client)

View file

@ -47,9 +47,6 @@ ClientLevel::ClientLevel(ClientModel *model, AbstractLevel *parent)
connect(Workspace::self(), &Workspace::clientAdded, this, &ClientLevel::clientAdded); connect(Workspace::self(), &Workspace::clientAdded, this, &ClientLevel::clientAdded);
connect(Workspace::self(), &Workspace::clientRemoved, this, &ClientLevel::clientRemoved); connect(Workspace::self(), &Workspace::clientRemoved, this, &ClientLevel::clientRemoved);
connect(model, SIGNAL(exclusionsChanged()), SLOT(reInit())); connect(model, SIGNAL(exclusionsChanged()), SLOT(reInit()));
if (waylandServer()) {
connect(waylandServer(), &WaylandServer::shellClientAdded, this, &ClientLevel::clientAdded);
}
} }
ClientLevel::~ClientLevel() ClientLevel::~ClientLevel()

View file

@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "../x11client.h" #include "../x11client.h"
#include "../outline.h" #include "../outline.h"
#include "../screens.h" #include "../screens.h"
#include "../xdgshellclient.h"
#include "../virtualdesktops.h" #include "../virtualdesktops.h"
#include "../wayland_server.h" #include "../wayland_server.h"
#include "../workspace.h" #include "../workspace.h"
@ -67,10 +66,6 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent)
} }
); );
connect(QApplication::desktop(), SIGNAL(resized(int)), SIGNAL(screenResized(int))); connect(QApplication::desktop(), SIGNAL(resized(int)), SIGNAL(screenResized(int)));
if (waylandServer()) {
connect(waylandServer(), &WaylandServer::shellClientAdded, this, &WorkspaceWrapper::clientAdded);
connect(waylandServer(), &WaylandServer::shellClientAdded, this, &WorkspaceWrapper::setupClientConnections);
}
foreach (KWin::X11Client *client, ws->clientList()) { foreach (KWin::X11Client *client, ws->clientList()) {
setupClientConnections(client); setupClientConnections(client);
} }

View file

@ -752,6 +752,7 @@ void Workspace::addShellClient(AbstractClient *client)
updateStackingOrder(true); updateStackingOrder(true);
updateClientArea(); updateClientArea();
}); });
emit clientAdded(client);
} }
void Workspace::removeShellClient(AbstractClient *client) void Workspace::removeShellClient(AbstractClient *client)