Merge pull request #139459 from CertainLach/kwin-unwrap-executable-name

kwin: unwrap executable name for resource name

authored by

Thomas Tuegel and committed by
GitHub
1ed5ee87 fd97e464

+74 -17
+74 -17
pkgs/desktops/plasma-5/kwin/0001-NixOS-Unwrap-executable-name-for-.desktop-search.patch
··· 8 8 file in-use according to the kernel! 9 9 10 10 Wrappers cannot affect the `/proc/.../exe` symlink! 11 + 12 + Co-authored-by: Yaroslav Bolyukin <iam@lach.pw> 11 13 --- 12 - src/service_utils.h | 28 +++++++++++++++++++++++++++- 13 - 1 file changed, 27 insertions(+), 1 deletion(-) 14 + src/nixos_utils.h | 41 +++++++++++++++++++++++++++++++++++++++++ 15 + src/service_utils.h | 4 +++- 16 + src/waylandclient.cpp | 5 ++++- 17 + 3 files changed, 48 insertions(+), 2 deletions(-) 18 + create mode 100644 src/nixos_utils.h 14 19 15 - diff --git a/src/service_utils.h b/src/service_utils.h 16 - index 8a70c1fad..6674f553b 100644 17 - --- a/src/service_utils.h 18 - +++ b/src/service_utils.h 19 - @@ -26,8 +26,34 @@ namespace KWin 20 - const static QString s_waylandInterfaceName = QStringLiteral("X-KDE-Wayland-Interfaces"); 21 - const static QString s_dbusRestrictedInterfaceName = QStringLiteral("X-KDE-DBUS-Restricted-Interfaces"); 22 - 23 - -static QStringList fetchProcessServiceField(const QString &executablePath, const QString &fieldName) 24 - +static QStringList fetchProcessServiceField(const QString &in_executablePath, const QString &fieldName) 25 - { 26 - + // !! Start NixOS fix 20 + diff --git a/src/nixos_utils.h b/src/nixos_utils.h 21 + new file mode 100644 22 + index 0000000..726065d 23 + --- /dev/null 24 + +++ b/src/nixos_utils.h 25 + @@ -0,0 +1,41 @@ 26 + +#ifndef NIXOS_UTILS_H 27 + +#define NIXOS_UTILS_H 28 + + 29 + +// kwin 30 + +#include <kwinglobals.h> 31 + + 32 + +namespace KWin 33 + +{ 34 + + 35 + +static QString unwrapExecutablePath(const QString &in_executablePath) 36 + +{ 27 37 + // NixOS fixes many packaging issues through "wrapper" scripts that manipulates the environment or does 28 38 + // miscellaneous trickeries and mischievous things to make the programs work. 29 39 + // In turn, programs often employs different mischievous schemes and trickeries to do *other things. ··· 47 57 + // Approximately equivalent to s;/\.;/; 48 58 + executablePath.remove(executablePath.lastIndexOf("/")+1, 1); 49 59 + } 50 - + // !! End NixOS fix 60 + + 61 + + return executablePath; 62 + +} 51 63 + 64 + +}// namespace 65 + + 66 + +#endif // SERVICE_UTILS_H 67 + diff --git a/src/service_utils.h b/src/service_utils.h 68 + index 8a70c1f..475b15d 100644 69 + --- a/src/service_utils.h 70 + +++ b/src/service_utils.h 71 + @@ -19,6 +19,7 @@ 72 + #include <QLoggingCategory> 73 + //KF 74 + #include <KApplicationTrader> 75 + +#include "nixos_utils.h" 76 + 77 + namespace KWin 78 + { 79 + @@ -26,8 +27,9 @@ namespace KWin 80 + const static QString s_waylandInterfaceName = QStringLiteral("X-KDE-Wayland-Interfaces"); 81 + const static QString s_dbusRestrictedInterfaceName = QStringLiteral("X-KDE-DBUS-Restricted-Interfaces"); 82 + 83 + -static QStringList fetchProcessServiceField(const QString &executablePath, const QString &fieldName) 84 + +static QStringList fetchProcessServiceField(const QString &in_executablePath, const QString &fieldName) 85 + { 86 + + const QString executablePath = unwrapExecutablePath(in_executablePath); 52 87 // needed to be able to use the logging category in a header static function 53 88 static QLoggingCategory KWIN_UTILS ("KWIN_UTILS", QtWarningMsg); 54 89 const auto servicesFound = KApplicationTrader::query([&executablePath] (const KService::Ptr &service) { 90 + diff --git a/src/waylandclient.cpp b/src/waylandclient.cpp 91 + index fd2c0c1..ae8cf96 100644 92 + --- a/src/waylandclient.cpp 93 + +++ b/src/waylandclient.cpp 94 + @@ -10,6 +10,7 @@ 95 + #include "screens.h" 96 + #include "wayland_server.h" 97 + #include "workspace.h" 98 + +#include "nixos_utils.h" 99 + 100 + #include <KWaylandServer/display.h> 101 + #include <KWaylandServer/clientbuffer.h> 102 + @@ -173,7 +174,9 @@ void WaylandClient::updateIcon() 103 + 104 + void WaylandClient::updateResourceName() 105 + { 106 + - const QFileInfo fileInfo(surface()->client()->executablePath()); 107 + + const QString in_path = surface()->client()->executablePath(); 108 + + const QString path = unwrapExecutablePath(in_path); 109 + + const QFileInfo fileInfo(path); 110 + if (fileInfo.exists()) { 111 + const QByteArray executableFileName = fileInfo.fileName().toUtf8(); 112 + setResourceClass(executableFileName, executableFileName); 55 113 -- 56 - 2.28.0 57 - 114 + 2.32.0