Merge signal connections for AbstractClient in Workspace
Summary: Have one dedicated method which performs the connection for both Client and ShellClient. This fixes the desktopPresenceChanged signal not being passed to the effects. Note that not all signals are merged. Most signals setup for Client don't make sense for ShellClient as ShellClient cannot block composite or unredirect. Test Plan: Test case added for ShellClient to ensure that the signal is correctly invoked on the ShellClient, Workspace and EffectsHandler. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2059
This commit is contained in:
parent
f9725a6849
commit
445335ba5f
4 changed files with 47 additions and 5 deletions
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
#include "kwin_wayland_test.h"
|
||||
#include "cursor.h"
|
||||
#include "effects.h"
|
||||
#include "platform.h"
|
||||
#include "shell_client.h"
|
||||
#include "screens.h"
|
||||
|
@ -46,6 +47,7 @@ private Q_SLOTS:
|
|||
void cleanup();
|
||||
|
||||
void testMapUnmapMap();
|
||||
void testDesktopPresenceChanged();
|
||||
};
|
||||
|
||||
void TestShellClient::initTestCase()
|
||||
|
@ -131,5 +133,41 @@ void TestShellClient::testMapUnmapMap()
|
|||
QCOMPARE(windowClosedSpy.count(), 1);
|
||||
}
|
||||
|
||||
void TestShellClient::testDesktopPresenceChanged()
|
||||
{
|
||||
// this test verifies that the desktop presence changed signals are properly emitted
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(c);
|
||||
QCOMPARE(c->desktop(), 1);
|
||||
effects->setNumberOfDesktops(4);
|
||||
QSignalSpy desktopPresenceChangedClientSpy(c, &ShellClient::desktopPresenceChanged);
|
||||
QVERIFY(desktopPresenceChangedClientSpy.isValid());
|
||||
QSignalSpy desktopPresenceChangedWorkspaceSpy(workspace(), &Workspace::desktopPresenceChanged);
|
||||
QVERIFY(desktopPresenceChangedWorkspaceSpy.isValid());
|
||||
QSignalSpy desktopPresenceChangedEffectsSpy(effects, &EffectsHandler::desktopPresenceChanged);
|
||||
QVERIFY(desktopPresenceChangedEffectsSpy.isValid());
|
||||
|
||||
// let's change the desktop
|
||||
workspace()->sendClientToDesktop(c, 2, false);
|
||||
QCOMPARE(c->desktop(), 2);
|
||||
QCOMPARE(desktopPresenceChangedClientSpy.count(), 1);
|
||||
QCOMPARE(desktopPresenceChangedWorkspaceSpy.count(), 1);
|
||||
// effects is delayed by one cycle
|
||||
QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 0);
|
||||
QVERIFY(desktopPresenceChangedEffectsSpy.wait());
|
||||
QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1);
|
||||
|
||||
// verify the arguments
|
||||
QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value<AbstractClient*>(), c);
|
||||
QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1);
|
||||
QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value<AbstractClient*>(), c);
|
||||
QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1);
|
||||
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value<EffectWindow*>(), c->effectWindow());
|
||||
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1);
|
||||
QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2);
|
||||
}
|
||||
|
||||
WAYLANDTEST_MAIN(TestShellClient)
|
||||
#include "shell_client_test.moc"
|
||||
|
|
|
@ -162,9 +162,6 @@ bool WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags)
|
|||
ScreenLocker::KSldApp::self()->lockScreenShown();
|
||||
}
|
||||
auto client = new ShellClient(surface);
|
||||
if (auto c = Compositor::self()) {
|
||||
connect(client, &Toplevel::needsRepaint, c, &Compositor::scheduleRepaint);
|
||||
}
|
||||
if (client->isInternal()) {
|
||||
m_internalClients << client;
|
||||
} else {
|
||||
|
|
|
@ -368,6 +368,7 @@ void Workspace::init()
|
|||
if (auto w = waylandServer()) {
|
||||
connect(w, &WaylandServer::shellClientAdded, this,
|
||||
[this] (ShellClient *c) {
|
||||
setupClientConnections(c);
|
||||
c->updateDecoration(false);
|
||||
updateClientLayer(c);
|
||||
if (!c->isInternal()) {
|
||||
|
@ -483,18 +484,23 @@ Workspace::~Workspace()
|
|||
_self = 0;
|
||||
}
|
||||
|
||||
void Workspace::setupClientConnections(AbstractClient *c)
|
||||
{
|
||||
connect(c, &Toplevel::needsRepaint, m_compositor, &Compositor::scheduleRepaint);
|
||||
connect(c, &AbstractClient::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged);
|
||||
}
|
||||
|
||||
Client* Workspace::createClient(xcb_window_t w, bool is_mapped)
|
||||
{
|
||||
StackingUpdatesBlocker blocker(this);
|
||||
Client* c = new Client();
|
||||
connect(c, SIGNAL(needsRepaint()), m_compositor, SLOT(scheduleRepaint()));
|
||||
setupClientConnections(c);
|
||||
connect(c, &Client::activeChanged, m_compositor, static_cast<void (Compositor::*)()>(&Compositor::checkUnredirect));
|
||||
connect(c, SIGNAL(fullScreenChanged()), m_compositor, SLOT(checkUnredirect()));
|
||||
connect(c, SIGNAL(geometryChanged()), m_compositor, SLOT(checkUnredirect()));
|
||||
connect(c, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), m_compositor, SLOT(checkUnredirect()));
|
||||
connect(c, SIGNAL(blockingCompositingChanged(KWin::Client*)), m_compositor, SLOT(updateCompositeBlocking(KWin::Client*)));
|
||||
connect(c, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), ScreenEdges::self(), SIGNAL(checkBlocking()));
|
||||
connect(c, &Client::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged);
|
||||
if (!c->manage(w, is_mapped)) {
|
||||
Client::deleteClient(c);
|
||||
return NULL;
|
||||
|
|
|
@ -512,6 +512,7 @@ private:
|
|||
|
||||
/// This is the right way to create a new client
|
||||
Client* createClient(xcb_window_t w, bool is_mapped);
|
||||
void setupClientConnections(AbstractClient *client);
|
||||
void addClient(Client* c);
|
||||
Unmanaged* createUnmanaged(xcb_window_t w);
|
||||
void addUnmanaged(Unmanaged* c);
|
||||
|
|
Loading…
Reference in a new issue