feat: add GIO_LAUNCHED_DESKTOP_FILE to runtime envs

add hooks for dde-dock

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe
2024-03-06 17:41:26 +08:00
committed by Comix
parent 3b2674023c
commit 1b4fb5551d
10 changed files with 47 additions and 10 deletions

View File

@ -49,12 +49,12 @@ double getScaleFactor() noexcept
return scale;
}
void appendRuntimeScaleFactor(const ApplicationService &app, QVariantMap &runtimeOptions) noexcept
void ApplicationService::appendExtraEnvironments(QVariantMap &runtimeOptions) const noexcept
{
static QStringList scaleEnvs{"DEEPIN_WINE_SCALE=%1;", "GDK_DPI_SCALE=%1;", "QT_SCALE_FACTOR=%1;", "GDK_SCALE=%1;"};
QString oldEnv;
auto factor = app.scaleFactor();
// scale factor
static QStringList scaleEnvs{"DEEPIN_WINE_SCALE=%1;", "GDK_DPI_SCALE=%1;", "QT_SCALE_FACTOR=%1;", "GDK_SCALE=%1;"};
auto factor = scaleFactor();
if (auto it = runtimeOptions.find("env"); it != runtimeOptions.cend()) {
oldEnv = it->value<QString>();
}
@ -63,6 +63,9 @@ void appendRuntimeScaleFactor(const ApplicationService &app, QVariantMap &runtim
oldEnv.append(env.arg(factor));
}
// GIO
oldEnv.append(QString{"GIO_LAUNCHED_DESKTOP_FILE=%1;"}.arg(m_desktopSource.sourcePath()));
runtimeOptions.insert("env", oldEnv);
}
@ -232,8 +235,7 @@ ApplicationService::Launch(const QString &action, const QStringList &fields, con
QString execStr{};
const auto &supportedActions = actions();
auto optionsMap = options;
appendRuntimeScaleFactor(*this, optionsMap);
appendExtraEnvironments(optionsMap);
if (!realExec.isNull()) { // we want to replace exec of this applications.
if (realExec.isEmpty()) {

View File

@ -190,6 +190,7 @@ private:
static bool shouldBeShown(const std::unique_ptr<DesktopEntry> &entry) noexcept;
[[nodiscard]] bool autostartCheck(const QString &filePath) const noexcept;
void setAutostartSource(AutostartSource &&source) noexcept;
void appendExtraEnvironments(QVariantMap &runtimeOptions) const noexcept;
[[nodiscard]] ApplicationManager1Service *parent() { return dynamic_cast<ApplicationManager1Service *>(QObject::parent()); }
[[nodiscard]] const ApplicationManager1Service *parent() const
{