mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 23:15:59 +00:00
Remove unneeded TrayIconFileTemplate function
Use /.flatpak-info instead of deprecated /run/user/$UID/flatpak-info Improve indentation in UseXDGDesktopPortal and IsAppIndicator Remove unneeded NeedTrayIconFile and rename IsAppIndicator to IsIndicatorApplication Include only needed part of QtDBus in main_window_linux.cpp Remove usage of QDBusInterface from SandboxAutostart and IsSNIAvailable Don't check dbus activatable services in IsIndicatorApplication Move XEmbed menu initialization to initTrayMenuHook, tray availability check to initHook Don't create unneeded file for tooltip icon, since indicator-application doesn't support tooltips Passthrough counter from updateIconCounters Suppress log errors for LastUserInputTime on GNOME Set applcation name and icon name for pulseaudio
This commit is contained in:
@@ -30,7 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QtDBus/QDBusError>
|
||||
#endif
|
||||
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
@@ -61,23 +61,29 @@ void SandboxAutostart(bool autostart, bool silent = false) {
|
||||
});
|
||||
options["dbus-activatable"] = false;
|
||||
|
||||
const auto requestBackgroundReply = QDBusInterface(
|
||||
auto message = QDBusMessage::createMethodCall(
|
||||
qsl("org.freedesktop.portal.Desktop"),
|
||||
qsl("/org/freedesktop/portal/desktop"),
|
||||
qsl("org.freedesktop.portal.Background")
|
||||
).call(qsl("RequestBackground"), QString(), options);
|
||||
qsl("org.freedesktop.portal.Background"),
|
||||
qsl("RequestBackground"));
|
||||
|
||||
if (!silent) {
|
||||
if (requestBackgroundReply.type() == QDBusMessage::ErrorMessage) {
|
||||
LOG(("Flatpak autostart error: %1")
|
||||
.arg(requestBackgroundReply.errorMessage()));
|
||||
} else if (requestBackgroundReply.type()
|
||||
!= QDBusMessage::ReplyMessage) {
|
||||
LOG(("Flatpak autostart error: invalid reply"));
|
||||
message.setArguments({
|
||||
QString(),
|
||||
options
|
||||
});
|
||||
|
||||
if (silent) {
|
||||
QDBusConnection::sessionBus().send(message);
|
||||
} else {
|
||||
const QDBusReply<void> reply = QDBusConnection::sessionBus().call(
|
||||
message);
|
||||
|
||||
if (!reply.isValid()) {
|
||||
LOG(("Flatpak autostart error: %1").arg(reply.error().message()));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
bool RunShellCommand(const QByteArray &command) {
|
||||
auto result = system(command.constData());
|
||||
@@ -168,7 +174,7 @@ bool GenerateDesktopFile(
|
||||
QRegularExpression::MultilineOption),
|
||||
qsl("Exec=\\1")
|
||||
+ (args.isEmpty() ? QString() : ' ' + args));
|
||||
#else
|
||||
#else // DESKTOP_APP_USE_PACKAGED
|
||||
fileText = fileText.replace(
|
||||
QRegularExpression(
|
||||
qsl("^TryExec=.*$"),
|
||||
@@ -184,7 +190,7 @@ bool GenerateDesktopFile(
|
||||
+ EscapeShell(QFile::encodeName(cExeDir() + cExeName()))
|
||||
.replace('\\', qsl("\\\\"))
|
||||
+ (args.isEmpty() ? QString() : ' ' + args));
|
||||
#endif
|
||||
#endif // !DESKTOP_APP_USE_PACKAGED
|
||||
target.write(fileText.toUtf8());
|
||||
target.close();
|
||||
|
||||
@@ -209,9 +215,7 @@ void SetApplicationIcon(const QIcon &icon) {
|
||||
}
|
||||
|
||||
bool InSandbox() {
|
||||
static const auto Sandbox = QFileInfo::exists(
|
||||
QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)
|
||||
+ qsl("/flatpak-info"));
|
||||
static const auto Sandbox = QFileInfo::exists(qsl("/.flatpak-info"));
|
||||
return Sandbox;
|
||||
}
|
||||
|
||||
@@ -228,12 +232,18 @@ bool IsXDGDesktopPortalPresent() {
|
||||
"org.freedesktop.portal.Desktop",
|
||||
"/org/freedesktop/portal/desktop").isValid();
|
||||
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
return XDGDesktopPortalPresent;
|
||||
}
|
||||
|
||||
bool UseXDGDesktopPortal() {
|
||||
static const auto UsePortal = qEnvironmentVariableIsSet("TDESKTOP_USE_PORTAL")
|
||||
&& IsXDGDesktopPortalPresent();
|
||||
static const auto UsePortal = [&] {
|
||||
const auto envVar = qEnvironmentVariableIsSet("TDESKTOP_USE_PORTAL");
|
||||
const auto portalPresent = IsXDGDesktopPortalPresent();
|
||||
|
||||
return envVar && portalPresent;
|
||||
}();
|
||||
|
||||
return UsePortal;
|
||||
}
|
||||
|
||||
@@ -360,7 +370,8 @@ std::optional<crl::time> LastUserInputTime() {
|
||||
|
||||
if (reply.isValid()) {
|
||||
return (crl::now() - static_cast<crl::time>(reply.value()));
|
||||
} else if (reply.error().type() != QDBusError::ServiceUnknown) {
|
||||
} else if (reply.error().type() != QDBusError::ServiceUnknown
|
||||
&& reply.error().type() != QDBusError::NotSupported) {
|
||||
LOG(("Unable to get last user input time: %1: %2")
|
||||
.arg(reply.error().name())
|
||||
.arg(reply.error().message()));
|
||||
@@ -488,6 +499,9 @@ void start() {
|
||||
LOG(("Launcher filename: %1").arg(GetLauncherFilename()));
|
||||
FallbackFontConfig();
|
||||
|
||||
qputenv("PULSE_PROP_application.name", AppName.utf8());
|
||||
qputenv("PULSE_PROP_application.icon_name", GetIconName().toLatin1());
|
||||
|
||||
#ifdef TDESKTOP_FORCE_GTK_FILE_DIALOG
|
||||
LOG(("Checking for XDG Desktop Portal..."));
|
||||
// this can give us a chance to use a proper file dialog for current session
|
||||
@@ -622,7 +636,7 @@ void psAutoStart(bool start, bool silent) {
|
||||
if (InSandbox()) {
|
||||
#ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION
|
||||
SandboxAutostart(start, silent);
|
||||
#endif
|
||||
#endif // !DESKTOP_APP_USE_PACKAGED
|
||||
} else {
|
||||
const auto autostart = [&] {
|
||||
if (InSnap()) {
|
||||
|
Reference in New Issue
Block a user