Set icon to wayland if desktop file is not found

Summary:
For X windows KWin uses the generic X icon if no icon is found. Thus
KWin should use the generic Wayland icon if no icon is found for a
Wayland client.

With this change applications with incorrect desktop file name at least
get a generic icon instead of no icon.

Test Plan: Started Qt assistant on Wayland and it had icon.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3023
This commit is contained in:
Martin Gräßlin 2016-10-11 16:32:47 +02:00
parent 9eede1c66b
commit 8201def97f

View file

@ -1155,18 +1155,20 @@ bool ShellClient::hasStrut() const
void ShellClient::updateIcon() void ShellClient::updateIcon()
{ {
const QString waylandIconName = QStringLiteral("wayland");
QString desktopFile; QString desktopFile;
if (m_shellSurface) { if (m_shellSurface) {
desktopFile = QString::fromUtf8(m_shellSurface->windowClass()); desktopFile = QString::fromUtf8(m_shellSurface->windowClass());
} }
if (desktopFile.isEmpty()) { if (desktopFile.isEmpty()) {
setIcon(QIcon()); setIcon(QIcon::fromTheme(waylandIconName));
} }
if (!desktopFile.endsWith(QLatin1String(".desktop"))) { if (!desktopFile.endsWith(QLatin1String(".desktop"))) {
desktopFile.append(QLatin1String(".desktop")); desktopFile.append(QLatin1String(".desktop"));
} }
KDesktopFile df(desktopFile); KDesktopFile df(desktopFile);
setIcon(QIcon::fromTheme(df.readIcon())); const QString iconName = df.readIcon();
setIcon(QIcon::fromTheme(iconName.isEmpty() ? waylandIconName : iconName));
} }
bool ShellClient::isTransient() const bool ShellClient::isTransient() const