Add an ultimate fallback to WM_CLASS Class for AbstractTasksModel::AppId in XWindowsTasksModel.

Summary:
This makes grouping work for apps we can't find on the system and
can't produce a launcher URL for, such as wine clients. Any better
app will use our superior codepath, the wonky ones like wine then
get left to making sure their WM_CLASS Class makes sense as per the
ICCCM spec.

Of course this doesn't work for XWayland clients on Wayland though.

BUG:368078

Also nixes an obsolete FIXME and adds a small check to avoid
producing launcher URLs that are only the window icon pixmap
query element.

Reviewers: #plasma, davidedmundson, broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D2804
wilder-5.14
Eike Hein 10 years ago
parent 1c0593f8ec
commit 5e30fc609e
  1. 11
      libtaskmanager/taskgroupingproxymodel.cpp
  2. 20
      libtaskmanager/xwindowtasksmodel.cpp

@ -689,7 +689,16 @@ QVariant TaskGroupingProxyModel::data(const QModelIndex &proxyIndex, int role) c
if (isGroup) {
// For group parent items, DisplayRole is mapped to AppName of the first child.
if (role == Qt::DisplayRole) {
return sourceIndex.data(AbstractTasksModel::AppName);
const QString &appName = sourceIndex.data(AbstractTasksModel::AppName).toString();
// Groups are formed by app id or launcher URL; neither requires
// AppName to be available. If it's not, fall back to the app id
/// rather than an empty string.
if (appName.isEmpty()) {
return sourceIndex.data(AbstractTasksModel::AppId);
}
return appName;
} else if (role == AbstractTasksModel::LegacyWinIdList) {
QVariantList winIds;

@ -423,6 +423,21 @@ AppData XWindowTasksModel::Private::appData(WId window)
{
if (!appDataCache.contains(window)) {
const AppData &data = appDataFromUrl(windowUrl(window));
// If we weren't able to derive a launcher URL from the window meta data,
// fall back to WM_CLASS Class string as app id. This helps with apps we
// can't map to an URL due to existing outside the regular system
// environment, e.g. wine clients.
if (data.id.isEmpty() && data.url.isEmpty()) {
AppData dataCopy = data;
dataCopy.id = windowInfo(window)->windowClassClass();
appDataCache.insert(window, dataCopy);
return dataCopy;
}
appDataCache.insert(window, data);
return data;
@ -661,7 +676,10 @@ QUrl XWindowTasksModel::Private::launcherUrl(WId window, bool encodeFallbackIcon
QUrl url = data.url;
// FIXME Hard-coding 64x64 or SizeLarge is not scaling-aware.
// Forego adding the window icon pixmap if the URL is otherwise empty.
if (!url.isValid()) {
return QUrl();
}
const QPixmap pixmap = KWindowSystem::icon(window, KIconLoader::SizeLarge, KIconLoader::SizeLarge, false);
if (pixmap.isNull()) {

Loading…
Cancel
Save