Get .desktop file name for launcher URL and activities string from KWindowInfo.
ClosedPublic

Authored by hein on Nov 4 2016, 12:49 PM.

Details

Summary

The former depends on https://git.reviewboard.kde.org/r/129327/

The latter is a thematically related cleanup I did along the way.
The strange original code was probably to handle the NULL_UUID, but
TaskFilterProxyModel (where this data role becomes relevant)
developed the ability to do this since.

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
hein updated this revision to Diff 7901.Nov 4 2016, 12:49 PM
hein retitled this revision from to Get .desktop file name for launcher URL and activities string from KWindowInfo..
hein updated this object.
hein edited the test plan for this revision. (Show Details)
hein added reviewers: Plasma, graesslin.
hein added a subscriber: plasma-devel.
Restricted Application added a project: Plasma. · View Herald TranscriptNov 4 2016, 12:49 PM
graesslin added inline comments.Nov 7 2016, 6:39 AM
libtaskmanager/xwindowtasksmodel.cpp
490–499

In KWin we also ensure that the desktopFile ends with .desktop prior to passing to KDesktopFile:

QString desktopFile = QString::fromUtf8(m_desktopFileName);
if (!desktopFile.endsWith(QLatin1String(".desktop"))) {
    desktopFile.append(QLatin1String(".desktop"));
}

The desktoFileName is without the .desktop suffix.

hein marked an inline comment as done.Nov 7 2016, 8:39 AM
hein added inline comments.
libtaskmanager/xwindowtasksmodel.cpp
490–499

In KWin we also ensure that the desktopFile ends with .desktop prior to passing to KDesktopFile

This shouldn't be necessary. "Passing to KDesktopFile" in this code's case is calling KDesktopFile::isDesktopFile, which is documented to do the following:

"The check is performed looking at the file extension (the file is not opened). Currently, the only valid extension is ".desktop". "

I.e. checking for the extension isn't necessary, that's what isDesktopFile() is doing. Basically, we try to find a KService first, and if that fails we check if it's a .desktop file and whether it exists, then use it.

graesslin added inline comments.Nov 7 2016, 8:41 AM
libtaskmanager/xwindowtasksmodel.cpp
490–499

exactly. So if you get a name which does not have the .desktop file extension it won't be used.

hein marked an inline comment as done.Nov 7 2016, 9:15 AM
hein added inline comments.
libtaskmanager/xwindowtasksmodel.cpp
490–499

But that seems sensible. The only time the app should set the prop to something that doesn't end with .desktop, it would be a "system menu id" related to a .desktop file that KService can locate. If KService can't find anything, I expect (and check for) the prop value to be an absolute path to a .desktop file outside of system location and include the extension. If that's not the case, something is fishy - the app is likely not well-behaved and it seems smarter to use the general heuristic than trying to fix up a broken path value.

Also quoting KWS:

"If the application's desktop file name is not at a standard location it should be the full path to the desktop file name (e.g. "/opt/kde/share/org.kde.foo.desktop")."

What value do you see in being lenient and fixing up a broken absolute path?

graesslin added inline comments.Nov 7 2016, 10:09 AM
libtaskmanager/xwindowtasksmodel.cpp
490–499

In KWin we had needed to add the .desktop - this is just passing on experience. Do with this experience what you want. For my part I don't trust our application developers to pass in a correct ID. This is a very easy way to fix it from our side.

hein marked an inline comment as done.Nov 7 2016, 10:15 AM
hein added inline comments.
libtaskmanager/xwindowtasksmodel.cpp
490–499

I'll grudgingly add it, although something about modifying absolute paths feels really unsettling to me.

This revision was automatically updated to reflect the committed changes.
hein marked an inline comment as done.