[wayland] Provide icon from ShellSurface's windowClass
We can use the window class to locate a desktop file and from this we can load a themed icon.
This commit is contained in:
parent
2192bd69e0
commit
31e599a63d
2 changed files with 14 additions and 0 deletions
|
@ -33,6 +33,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <KWayland/Server/plasmashell_interface.h>
|
||||
#include <KWayland/Server/qtsurfaceextension_interface.h>
|
||||
|
||||
#include <KDesktopFile>
|
||||
|
||||
#include <QWindow>
|
||||
|
||||
using namespace KWayland::Server;
|
||||
|
@ -83,6 +85,8 @@ ShellClient::ShellClient(ShellSurfaceInterface *surface)
|
|||
maximize(maximized ? MaximizeFull : MaximizeRestore);
|
||||
}
|
||||
);
|
||||
connect(surface, &ShellSurfaceInterface::windowClassChanged, this, &ShellClient::updateIcon);
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
ShellClient::~ShellClient() = default;
|
||||
|
@ -627,4 +631,13 @@ bool ShellClient::hasStrut() const
|
|||
return m_plasmaShellSurface->panelBehavior() != PlasmaShellSurfaceInterface::PanelBehavior::WindowsGoBelow;
|
||||
}
|
||||
|
||||
void ShellClient::updateIcon()
|
||||
{
|
||||
if (m_shellSurface->windowClass().isEmpty()) {
|
||||
setIcon(QIcon());
|
||||
}
|
||||
KDesktopFile df(QStringLiteral("%0.desktop").arg(QString::fromUtf8(m_shellSurface->windowClass())));
|
||||
setIcon(QIcon::fromTheme(df.readIcon()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ private:
|
|||
void createWindowId();
|
||||
void findInternalWindow();
|
||||
void updateInternalWindowGeometry();
|
||||
void updateIcon();
|
||||
static void deleteClient(ShellClient *c);
|
||||
|
||||
KWayland::Server::ShellSurfaceInterface *m_shellSurface;
|
||||
|
|
Loading…
Reference in a new issue