git.iko.soy/typeable/nixpkgs
on master help sign in
kwin: unwrap executable name for resource name

Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>

commit60679c15e31924923b5d36810ed1d45debcca80d authorYaroslav Bolyukin <iam@lach.pw> dateSat 25 Sep 2021, 19:53 (5 years ago) parent39b5332
1 file changed+74−17
pkgs/desktops/plasma-5/kwin/0001-NixOS-Unwrap-executable-name-for-.desktop-search.patch+74−17
pkgs/desktops/plasma-5/kwin/0001-NixOS-Unwrap-executable-name-for-.desktop-search.patch+74−17
@@ -8,22 +8,32 @@ Because it's completely bypassing argv0! This looks at the executable
88file in-use according to the kernel!
99
1010Wrappers cannot affect the `/proc/.../exe` symlink!
11+
12+Co-authored-by: Yaroslav Bolyukin <iam@lach.pw>
1113---
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
1419
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++{
2737+ // NixOS fixes many packaging issues through "wrapper" scripts that manipulates the environment or does
2838+ // miscellaneous trickeries and mischievous things to make the programs work.
2939+ // In turn, programs often employs different mischievous schemes and trickeries to do *other things.
@@ -47,11 +57,58 @@ index 8a70c1fad..6674f553b 100644
4757+ // Approximately equivalent to s;/\.;/;
4858+ executablePath.remove(executablePath.lastIndexOf("/")+1, 1);
4959+ }
50−+ // !! End NixOS fix
5160+
61++ return executablePath;
62++}
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);
5287 // needed to be able to use the logging category in a header static function
5388 static QLoggingCategory KWIN_UTILS ("KWIN_UTILS", QtWarningMsg);
5489 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);
55113--
56−2.28.0
57−
114+2.32.0