FreeBSD Bugzilla – Attachment 255745 Details for
Bug 280638
x11-wm/plasma6-kwin linuxism breaks spectacle screenshots
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
the patch that ChatGPT produced for me
patch-src_utils_serviceutils.h (text/plain), 5.11 KB, created by
Oleg
on 2024-12-09 17:27:44 UTC
(
hide
)
Description:
the patch that ChatGPT produced for me
Filename:
MIME Type:
Creator:
Oleg
Created:
2024-12-09 17:27:44 UTC
Size:
5.11 KB
patch
obsolete
>--- src/utils/serviceutils.h.orig 2024-12-09 10:34:45.220830000 -0500 >+++ src/utils/serviceutils.h 2024-12-09 11:05:29.452034000 -0500 >@@ -1,14 +1,17 @@ > /* >- KWin - the KDE window manager >- This file is part of the KDE project. >+ KWin - the KDE window manager >+ This file is part of the KDE project. > >- SPDX-FileCopyrightText: 2020 Méven Car <meven.car@enioka.com> >+ SPDX-FileCopyrightText: 2020 Méven Car <meven.car@enioka.com> > >- SPDX-License-Identifier: GPL-2.0-or-later >-*/ >+ SPDX-License-Identifier: GPL-2.0-or-later >+ */ > > #pragma once >- >+#if defined(__FreeBSD__) >+#include <limits.h> >+#include <sys/sysctl.h> >+#endif > // cmake stuff > #include "config-kwin.h" > // kwin >@@ -23,51 +26,67 @@ > namespace KWin > { > >-const static QString s_waylandInterfaceName = QStringLiteral("X-KDE-Wayland-Interfaces"); >-const static QString s_dbusRestrictedInterfaceName = QStringLiteral("X-KDE-DBUS-Restricted-Interfaces"); >+ const static QString s_waylandInterfaceName = QStringLiteral("X-KDE-Wayland-Interfaces"); >+ const static QString s_dbusRestrictedInterfaceName = QStringLiteral("X-KDE-DBUS-Restricted-Interfaces"); > >-static QStringList fetchProcessServiceField(const QString &executablePath, const QString &fieldName) >-{ >- // needed to be able to use the logging category in a header static function >- static QLoggingCategory KWIN_UTILS("KWIN_UTILS", QtWarningMsg); >- const auto servicesFound = KApplicationTrader::query([&executablePath](const KService::Ptr &service) { >- const auto splitCommandList = QProcess::splitCommand(service->exec()); >- if (splitCommandList.isEmpty()) { >- return false; >- } >- return QFileInfo(splitCommandList.first()).canonicalFilePath() == executablePath; >- }); >+ static QStringList fetchProcessServiceField(const QString &executablePath, const QString &fieldName) >+ { >+ // needed to be able to use the logging category in a header static function >+ static QLoggingCategory KWIN_UTILS("KWIN_UTILS", QtWarningMsg); >+ const auto servicesFound = KApplicationTrader::query([&executablePath](const KService::Ptr &service) { >+ const auto splitCommandList = QProcess::splitCommand(service->exec()); >+ if (splitCommandList.isEmpty()) { >+ return false; >+ } >+ return QFileInfo(splitCommandList.first()).canonicalFilePath() == executablePath; >+ }); > >- if (servicesFound.isEmpty()) { >- qCDebug(KWIN_UTILS) << "Could not find the desktop file for" << executablePath; >- return {}; >- } >+ if (servicesFound.isEmpty()) { >+ qCDebug(KWIN_UTILS) << "Could not find the desktop file for" << executablePath; >+ return {}; >+ } > >- const auto fieldValues = servicesFound.first()->property<QStringList>(fieldName); >- if (KWIN_UTILS().isDebugEnabled()) { >- qCDebug(KWIN_UTILS) << "Interfaces found for" << executablePath << fieldName << ":" << fieldValues; >- } >- return fieldValues; >-} >+ const auto fieldValues = servicesFound.first()->property<QStringList>(fieldName); >+ if (KWIN_UTILS().isDebugEnabled()) { >+ qCDebug(KWIN_UTILS) << "Interfaces found for" << executablePath << fieldName << ":" << fieldValues; >+ } >+ return fieldValues; >+ } > >-static inline QStringList fetchRequestedInterfacesForDesktopId(const QString &desktopId) >-{ >- const auto service = KService::serviceByDesktopName(desktopId); >- if (!service) { >- return {}; >- } >- return service->property<QStringList>(s_waylandInterfaceName); >-} >+ static inline QStringList fetchRequestedInterfacesForDesktopId(const QString &desktopId) >+ { >+ const auto service = KService::serviceByDesktopName(desktopId); >+ if (!service) { >+ return {}; >+ } >+ return service->property<QStringList>(s_waylandInterfaceName); >+ } > >-static inline QStringList fetchRequestedInterfaces(const QString &executablePath) >-{ >- return fetchProcessServiceField(executablePath, s_waylandInterfaceName); >-} >+ static inline QStringList fetchRequestedInterfaces(const QString &executablePath) >+ { >+ return fetchProcessServiceField(executablePath, s_waylandInterfaceName); >+ } > >-static inline QStringList fetchRestrictedDBusInterfacesFromPid(const uint pid) >-{ >- const auto executablePath = QFileInfo(QStringLiteral("/proc/%1/exe").arg(pid)).symLinkTarget(); >- return fetchProcessServiceField(executablePath, s_dbusRestrictedInterfaceName); >-} >+ static inline QStringList fetchRestrictedDBusInterfacesFromPid(const uint pid) >+ { >+#ifdef __FreeBSD__ >+ static int pathname[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; >+ pathname[3] = pid; >+ size_t path_size = PATH_MAX; >+ char *executablePath = (char*)malloc(path_size); >+ if (executablePath != nullptr) { >+ if (sysctl(pathname, sizeof(pathname) / sizeof(pathname[0]), executablePath, &path_size, NULL, 0) == 0) { >+ QString path = QString::fromLocal8Bit(executablePath); >+ free(executablePath); >+ return fetchProcessServiceField(path, s_dbusRestrictedInterfaceName); >+ } >+ free(executablePath); >+ } >+ return QStringList(); >+#else >+ const auto executablePath = QFileInfo(QStringLiteral("/proc/%1/exe").arg(pid)).symLinkTarget(); >+ return fetchProcessServiceField(executablePath, s_dbusRestrictedInterfaceName); >+#endif >+ } > > } // namespace
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 280638
:
252525
| 255745