Commit 7b751099 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Emit Workspace::clientAdded() with AbstractClient

Summary:
Currently, if one wants to monitor for new X11 and Wayland clients, they
have to listen for two signals. Workspace::clientAdded() is emitted only
for X11 and Xwayland clients, while WaylandServer::shellClientAdded() is
emitted only for xdg-shell clients. Such design doesn't scale well.

As the first towards emitting Workspace::clientAdded() for new Wayland
clients, this change replaces the X11Client parameter in the clientAdded
signal with AbstractClient.

Test Plan: Tests still pass.

Reviewers: #kwin, cblack

Reviewed By: cblack

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29665
parent 079f9890
......@@ -899,8 +899,10 @@ DebugConsoleModel::DebugConsoleModel(QObject *parent)
m_x11Clients.append(c);
}
connect(workspace(), &Workspace::clientAdded, this,
[this] (X11Client *c) {
add(s_x11ClientId -1, m_x11Clients, c);
[this] (AbstractClient *client) {
if (X11Client *x11Client = qobject_cast<X11Client *>(client)) {
add(s_x11ClientId -1, m_x11Clients, x11Client);
}
}
);
connect(workspace(), &Workspace::clientRemoved, this,
......
......@@ -166,7 +166,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
}
);
connect(ws, &Workspace::clientAdded, this,
[this](X11Client *c) {
[this](AbstractClient *c) {
if (c->readyForPainting())
slotClientShown(c);
else
......@@ -564,8 +564,8 @@ void EffectsHandlerImpl::slotOpacityChanged(Toplevel *t, qreal oldOpacity)
void EffectsHandlerImpl::slotClientShown(KWin::Toplevel *t)
{
Q_ASSERT(qobject_cast<X11Client *>(t));
X11Client *c = static_cast<X11Client *>(t);
Q_ASSERT(qobject_cast<AbstractClient *>(t));
AbstractClient *c = static_cast<AbstractClient *>(t);
disconnect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
setupClientConnections(c);
emit windowAdded(c->effectWindow());
......
......@@ -69,7 +69,7 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent)
connect(QApplication::desktop(), SIGNAL(resized(int)), SIGNAL(screenResized(int)));
if (waylandServer()) {
connect(waylandServer(), &WaylandServer::shellClientAdded, this, &WorkspaceWrapper::clientAdded);
connect(waylandServer(), &WaylandServer::shellClientAdded, this, &WorkspaceWrapper::setupAbstractClientConnections);
connect(waylandServer(), &WaylandServer::shellClientAdded, this, &WorkspaceWrapper::setupClientConnections);
}
foreach (KWin::X11Client *client, ws->clientList()) {
setupClientConnections(client);
......@@ -277,20 +277,19 @@ QString WorkspaceWrapper::supportInformation() const
return Workspace::self()->supportInformation();
}
void WorkspaceWrapper::setupAbstractClientConnections(AbstractClient *client)
void WorkspaceWrapper::setupClientConnections(AbstractClient *client)
{
connect(client, &AbstractClient::clientMinimized, this, &WorkspaceWrapper::clientMinimized);
connect(client, &AbstractClient::clientUnminimized, this, &WorkspaceWrapper::clientUnminimized);
connect(client, qOverload<AbstractClient *, bool, bool>(&AbstractClient::clientMaximizedStateChanged),
this, &WorkspaceWrapper::clientMaximizeSet);
}
void WorkspaceWrapper::setupClientConnections(X11Client *client)
{
setupAbstractClientConnections(client);
X11Client *x11Client = qobject_cast<X11Client *>(client); // TODO: Drop X11-specific signals.
if (!x11Client)
return;
connect(client, &X11Client::clientManaging, this, &WorkspaceWrapper::clientManaging);
connect(client, &X11Client::clientFullScreenSet, this, &WorkspaceWrapper::clientFullScreenSet);
connect(x11Client, &X11Client::clientManaging, this, &WorkspaceWrapper::clientManaging);
connect(x11Client, &X11Client::clientFullScreenSet, this, &WorkspaceWrapper::clientFullScreenSet);
}
void WorkspaceWrapper::showOutline(const QRect &geometry)
......
......@@ -351,8 +351,7 @@ public Q_SLOTS:
void hideOutline();
private Q_SLOTS:
void setupAbstractClientConnections(AbstractClient *client);
void setupClientConnections(X11Client *client);
void setupClientConnections(AbstractClient *client);
};
class QtScriptWorkspaceWrapper : public WorkspaceWrapper
......
......@@ -502,7 +502,7 @@ Q_SIGNALS:
//Signals required for the scripting interface
void desktopPresenceChanged(KWin::AbstractClient*, int);
void currentDesktopChanged(int, KWin::AbstractClient*);
void clientAdded(KWin::X11Client *);
void clientAdded(KWin::AbstractClient *);
void clientRemoved(KWin::AbstractClient*);
void clientActivated(KWin::AbstractClient*);
void clientDemandsAttentionChanged(KWin::AbstractClient*, bool);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment