Commit 90393d7d authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Send an icon only if there is one

Currently, plasma window model test fails because the null icon is
received after executing the main body of the test.

    FAIL!  : PlasmaWindowModelTest::testVirtualDesktops() '!dataChangedSpy.wait(100)' returned FALSE. ()
       Loc: [/data/projects/src/kwayland-server/autotests/client/test_plasma_window_model.cpp(583)]

We can fix the test by waiting for the iconChanged signal to be emitted,
but we will need to wait in all tests too. Furthermore, it doesn't make a
lot of sense to wait for an icon that was never set.

This change makes the compositor send an icon only if there is one.

It's a behavioral change, but it shouldn't regress anything because kwin
always sets icons via the plasma window management protocol even for apps
that have no valid app id.

It also makes the api of the PlasmaWindowInterface class more intuitive.
parent eda53c7f
Pipeline #54571 passed with stage
in 7 minutes and 14 seconds
......@@ -566,24 +566,10 @@ void TestWindowManagement::testIcon()
{
using namespace KWayland::Client;
// initially, the server should send us an icon
// initially, there shouldn't be any icon
QSignalSpy iconChangedSpy(m_window, &PlasmaWindow::iconChanged);
QVERIFY(iconChangedSpy.isValid());
QVERIFY(iconChangedSpy.wait());
QCOMPARE(iconChangedSpy.count(), 1);
if (!QIcon::hasThemeIcon(QStringLiteral("wayland"))) {
QEXPECT_FAIL("", "no icon", Continue);
}
QCOMPARE(m_window->icon().name(), QStringLiteral("wayland"));
// first goes from themed name to empty
m_windowInterface->setIcon(QIcon());
QVERIFY(iconChangedSpy.wait());
QCOMPARE(iconChangedSpy.count(), 2);
if (!QIcon::hasThemeIcon(QStringLiteral("wayland"))) {
QEXPECT_FAIL("", "no icon", Continue);
}
QCOMPARE(m_window->icon().name(), QStringLiteral("wayland"));
QVERIFY(m_window->icon().isNull());
// create an icon with a pixmap
QImage p(32, 32, QImage::Format_ARGB32_Premultiplied);
......@@ -591,17 +577,17 @@ void TestWindowManagement::testIcon()
const QIcon dummyIcon(QPixmap::fromImage(p));
m_windowInterface->setIcon(dummyIcon);
QVERIFY(iconChangedSpy.wait());
QCOMPARE(iconChangedSpy.count(), 3);
QCOMPARE(iconChangedSpy.count(), 1);
QCOMPARE(m_window->icon().pixmap(32, 32), dummyIcon.pixmap(32, 32));
// let's set a themed icon
m_windowInterface->setIcon(QIcon::fromTheme(QStringLiteral("xorg")));
m_windowInterface->setIcon(QIcon::fromTheme(QStringLiteral("wayland")));
QVERIFY(iconChangedSpy.wait());
QCOMPARE(iconChangedSpy.count(), 4);
if (!QIcon::hasThemeIcon(QStringLiteral("xorg"))) {
QEXPECT_FAIL("", "no icon", Continue);
QCOMPARE(iconChangedSpy.count(), 2);
if (!QIcon::hasThemeIcon(QStringLiteral("wayland"))) {
QEXPECT_FAIL("", "no wayland icon", Continue);
}
QCOMPARE(m_window->icon().name(), QStringLiteral("xorg"));
QCOMPARE(m_window->icon().name(), QStringLiteral("wayland"));
}
void TestWindowManagement::testPid()
......
......@@ -328,7 +328,7 @@ void PlasmaWindowInterfacePrivate::org_kde_plasma_window_bind_resource(Resource
send_state_changed(resource->handle, m_state);
if (!m_themedIconName.isEmpty()) {
send_themed_icon_name_changed(resource->handle, m_themedIconName);
} else {
} else if (!m_icon.isNull()) {
if (resource->version() >= ORG_KDE_PLASMA_WINDOW_ICON_CHANGED_SINCE_VERSION) {
send_icon_changed(resource->handle);
}
......
Supports Markdown
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