diff --git a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp
index dc7f2f695..47316905d 100644
--- a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp
@@ -58,18 +58,17 @@ int Launcher::exec() {
return GtkIntegration::Exec(
GtkIntegration::Type::Base,
QString::fromStdString(*(i + 1)),
- std::stoi(*(i + 2)));
- } else if (*i == "-webviewhelper" && std::distance(i, e) > 3) {
+ QString::fromStdString(*(i + 2)));
+ } else if (*i == "-webviewhelper" && std::distance(i, e) > 2) {
return GtkIntegration::Exec(
GtkIntegration::Type::Webview,
QString::fromStdString(*(i + 1)),
- std::stoi(*(i + 2)),
- std::stoi(*(i + 3)));
+ QString::fromStdString(*(i + 2)));
} else if (*i == "-gtkintegration" && std::distance(i, e) > 2) {
return GtkIntegration::Exec(
GtkIntegration::Type::TDesktop,
QString::fromStdString(*(i + 1)),
- std::stoi(*(i + 2)));
+ QString::fromStdString(*(i + 2)));
}
}
diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
index 74456143f..3faec9248 100644
--- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
+++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.cpp
@@ -16,11 +16,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/linux/base_linux_glibmm_helper.h"
#include "base/platform/linux/base_linux_dbus_utilities.h"
#include "base/platform/base_platform_info.h"
+#include "webview/platform/linux/webview_linux_webkit2gtk.h"
#include "platform/linux/linux_gtk_integration_p.h"
#include "platform/linux/linux_gdk_helper.h"
#include "platform/linux/linux_gtk_open_with_dialog.h"
#include "platform/linux/linux_wayland_integration.h"
-#include "webview/webview_interface.h"
#include "window/window_controller.h"
#include "core/application.h"
@@ -42,6 +42,8 @@ using BaseGtkIntegration = base::Platform::GtkIntegration;
namespace {
constexpr auto kService = "org.telegram.desktop.GtkIntegration-%1"_cs;
+constexpr auto kBaseService = "org.telegram.desktop.BaseGtkIntegration-%1"_cs;
+constexpr auto kWebviewService = "org.telegram.desktop.GtkIntegration.WebviewHelper-%1-%2"_cs;
constexpr auto kObjectPath = "/org/telegram/desktop/GtkIntegration"_cs;
constexpr auto kInterface = "org.telegram.desktop.GtkIntegration"_cs;
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs;
@@ -66,6 +68,8 @@ constexpr auto kIntrospectionXML = R"INTROSPECTION(
)INTROSPECTION"_cs;
+Glib::ustring ServiceName;
+
bool GetImageFromClipboardSupported() {
return (gtk_clipboard_get != nullptr)
&& (gtk_clipboard_wait_for_contents != nullptr)
@@ -93,8 +97,7 @@ public:
return Glib::RefPtr();
}
}())
- , interfaceVTable(sigc::mem_fun(this, &Private::handleMethodCall))
- , serviceName(kService.utf16().arg(getpid()).toStdString()) {
+ , interfaceVTable(sigc::mem_fun(this, &Private::handleMethodCall)) {
}
void handleMethodCall(
@@ -109,7 +112,6 @@ public:
const Glib::RefPtr dbusConnection;
const Gio::DBus::InterfaceVTable interfaceVTable;
Glib::RefPtr introspectionData;
- Glib::ustring serviceName;
Glib::ustring parentDBusName;
bool remoting = true;
uint registerId = 0;
@@ -303,7 +305,7 @@ void GtkIntegration::load(const QString &allowedBackends) {
base::Platform::MakeGlibVariant(std::tuple{
Glib::ustring(allowedBackends.toStdString()),
}),
- _private->serviceName);
+ ServiceName);
} catch (...) {
}
@@ -344,9 +346,8 @@ void GtkIntegration::load(const QString &allowedBackends) {
Loaded = true;
}
-int GtkIntegration::exec(const QString &parentDBusName, int ppid) {
+int GtkIntegration::exec(const QString &parentDBusName) {
_private->remoting = false;
- _private->serviceName = kService.utf16().arg(ppid).toStdString();
_private->parentDBusName = parentDBusName.toStdString();
_private->introspectionData = Gio::DBus::NodeInfo::create_for_xml(
@@ -357,7 +358,7 @@ int GtkIntegration::exec(const QString &parentDBusName, int ppid) {
_private->introspectionData->lookup_interface(),
_private->interfaceVTable);
- const auto app = Gio::Application::create(_private->serviceName);
+ const auto app = Gio::Application::create(ServiceName);
app->hold();
_private->parentServiceWatcherId = base::Platform::DBus::RegisterServiceWatcher(
_private->dbusConnection,
@@ -406,7 +407,7 @@ bool GtkIntegration::showOpenWithDialog(const QString &filepath) const {
Glib::ustring(parent.toStdString()),
Glib::ustring(filepath.toStdString()),
}),
- _private->serviceName);
+ ServiceName);
const auto context = Glib::MainContext::create();
const auto loop = Glib::MainLoop::create(context);
@@ -434,7 +435,7 @@ bool GtkIntegration::showOpenWithDialog(const QString &filepath) const {
} catch (...) {
}
},
- _private->serviceName,
+ ServiceName,
std::string(kInterface),
"OpenWithDialogResponse",
std::string(kObjectPath));
@@ -505,7 +506,7 @@ QImage GtkIntegration::getImageFromClipboard() const {
{},
{},
outFdList,
- _private->serviceName);
+ ServiceName);
const auto streamSize = base::Platform::GlibVariantCast(
reply.get_child(1));
@@ -609,25 +610,22 @@ QString GtkIntegration::AllowedBackends() {
int GtkIntegration::Exec(
Type type,
const QString &parentDBusName,
- int ppid,
- uint instanceNumber) {
+ const QString &serviceName) {
Glib::init();
Gio::init();
if (type == Type::Base) {
+ BaseGtkIntegration::SetServiceName(serviceName);
if (const auto integration = BaseGtkIntegration::Instance()) {
- return integration->exec(parentDBusName, ppid);
+ return integration->exec(parentDBusName);
}
} else if (type == Type::Webview) {
- if (const auto instance = Webview::CreateInstance({})) {
- return instance->exec(
- parentDBusName.toStdString(),
- ppid,
- instanceNumber);
- }
+ Webview::WebKit2Gtk::SetServiceName(serviceName.toStdString());
+ return Webview::WebKit2Gtk::Exec(parentDBusName.toStdString());
} else if (type == Type::TDesktop) {
+ ServiceName = serviceName.toStdString();
if (const auto integration = Instance()) {
- return integration->exec(parentDBusName, ppid);
+ return integration->exec(parentDBusName);
}
}
@@ -635,10 +633,27 @@ int GtkIntegration::Exec(
}
void GtkIntegration::Start(Type type) {
- if (type != Type::Base && type != Type::TDesktop) {
+ if (type != Type::Base
+ && type != Type::Webview
+ && type != Type::TDesktop) {
return;
}
+ const auto d = QFile::encodeName(QDir(cWorkingDir()).absolutePath());
+ char h[33] = { 0 };
+ hashMd5Hex(d.constData(), d.size(), h);
+
+ if (type == Type::Base) {
+ BaseGtkIntegration::SetServiceName(kBaseService.utf16().arg(h));
+ } else if (type == Type::Webview) {
+ Webview::WebKit2Gtk::SetServiceName(
+ kWebviewService.utf16().arg(h).arg("%1").toStdString());
+
+ return;
+ } else {
+ ServiceName = kService.utf16().arg(h).toStdString();
+ }
+
const auto dbusName = [] {
try {
static const auto connection = Gio::DBus::Connection::get_sync(
@@ -659,7 +674,9 @@ void GtkIntegration::Start(Type type) {
? qsl("-basegtkintegration")
: qsl("-gtkintegration"),
dbusName,
- QString::number(getpid()),
+ (type == Type::Base)
+ ? kBaseService.utf16().arg(h)
+ : kService.utf16().arg(h),
});
}
@@ -672,18 +689,11 @@ void GtkIntegration::Autorestart(Type type) {
static const auto connection = Gio::DBus::Connection::get_sync(
Gio::DBus::BusType::BUS_TYPE_SESSION);
- const auto baseServiceName = [] {
- if (const auto integration = BaseGtkIntegration::Instance()) {
- return integration->serviceName();
- }
- return QString();
- }();
-
base::Platform::DBus::RegisterServiceWatcher(
connection,
(type == Type::Base)
- ? baseServiceName.toStdString()
- : kService.utf16().arg(getpid()).toStdString(),
+ ? Glib::ustring(BaseGtkIntegration::ServiceName().toStdString())
+ : ServiceName,
[=](
const Glib::ustring &service,
const Glib::ustring &oldOwner,
diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h
index df24fd2c0..ebff11d5c 100644
--- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h
+++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration.h
@@ -21,7 +21,7 @@ public:
static GtkIntegration *Instance();
void load(const QString &allowedBackends);
- int exec(const QString &parentDBusName, int ppid);
+ int exec(const QString &parentDBusName);
[[nodiscard]] bool showOpenWithDialog(const QString &filepath) const;
@@ -32,8 +32,7 @@ public:
static int Exec(
Type type,
const QString &parentDBusName,
- int ppid,
- uint instanceNumber = 0);
+ const QString &serviceName);
static void Start(Type type);
diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp b/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp
index 2cd7c2a03..0c7f61d2b 100644
--- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp
+++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration_dummy.cpp
@@ -25,7 +25,7 @@ GtkIntegration *GtkIntegration::Instance() {
void GtkIntegration::load(const QString &allowedBackends) {
}
-int GtkIntegration::exec(const QString &parentDBusName, int ppid) {
+int GtkIntegration::exec(const QString &parentDBusName) {
return 1;
}
@@ -44,8 +44,7 @@ QString GtkIntegration::AllowedBackends() {
int GtkIntegration:Exec(
Type type,
const QString &parentDBusName,
- int ppid,
- uint instanceNumber) {
+ const QString &serviceName) {
return 1;
}
diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
index 1707e53f3..7cea2a999 100644
--- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
@@ -746,6 +746,7 @@ void start() {
Glib::set_application_name(std::string(AppName));
GtkIntegration::Start(GtkIntegration::Type::Base);
+ GtkIntegration::Start(GtkIntegration::Type::Webview);
GtkIntegration::Start(GtkIntegration::Type::TDesktop);
#ifdef DESKTOP_APP_USE_PACKAGED_RLOTTIE
diff --git a/Telegram/lib_base b/Telegram/lib_base
index f493a8174..b721f4d13 160000
--- a/Telegram/lib_base
+++ b/Telegram/lib_base
@@ -1 +1 @@
-Subproject commit f493a8174f993119de8d9a5170dc89641bfafbef
+Subproject commit b721f4d1302c5119d59ab35ddfd5abb90fab42ed
diff --git a/Telegram/lib_webview b/Telegram/lib_webview
index 794aba38b..1a3206777 160000
--- a/Telegram/lib_webview
+++ b/Telegram/lib_webview
@@ -1 +1 @@
-Subproject commit 794aba38bac729471afbcc3aca62400bafd55b4c
+Subproject commit 1a3206777c0bca6d9fb5b643131e6d2b028a336f