From de89d349ad189fe87d6e16f8f34160f80ac032a5 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 13 Oct 2025 00:26:39 +0000 Subject: [PATCH] Implement launching maps on Linux --- .../platform/linux/specific_linux.cpp | 55 ++++++++++++++++++- Telegram/ThirdParty/xdg-desktop-portal | 2 +- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index d569503eb4..b8844e380d 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -12,11 +12,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/base_platform_info.h" #include "base/platform/linux/base_linux_dbus_utilities.h" #include "base/platform/linux/base_linux_xdp_utilities.h" +#include "base/platform/linux/base_linux_app_launch_context.h" #include "lang/lang_keys.h" #include "core/launcher.h" #include "core/sandbox.h" #include "core/application.h" #include "core/update_checker.h" +#include "data/data_location.h" #include "window/window_controller.h" #include "webview/platform/linux/webview_linux_webkitgtk.h" @@ -26,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include #include #include @@ -34,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include #include #include @@ -781,7 +785,56 @@ QString ApplicationIconName() { } void LaunchMaps(const Data::LocationPoint &point, Fn fail) { - fail(); + if (auto appInfo = Gio::AppInfo::get_default_for_uri_scheme("geo")) { + if (appInfo.launch_uris( + { + std::format( + "geo:{},{}", + point.latAsString().toStdString(), + point.lonAsString().toStdString()), + }, + base::Platform::AppLaunchContext(), + nullptr)) { + return; + } + } + + XdpOpenURI::OpenURIProxy::new_for_bus( + Gio::BusType::SESSION_, + Gio::DBusProxyFlags::NONE_, + base::Platform::XDP::kService, + base::Platform::XDP::kObjectPath, + [=](GObject::Object, Gio::AsyncResult res) { + auto interface = XdpOpenURI::OpenURI( + XdpOpenURI::OpenURIProxy::new_for_bus_finish(res, nullptr)); + + if (!interface) { + fail(); + return; + } + + interface.call_scheme_supported( + "geo", + GLib::Variant::new_array( + GLib::VariantType::new_("{sv}"), + {}), + [=](GObject::Object, Gio::AsyncResult res) mutable { + const auto result + = interface.call_scheme_supported_finish(res); + + if (!result || !std::get<1>(*result)) { + fail(); + return; + } + + if (!QDesktopServices::openUrl( + u"geo:%1,%2"_q.arg( + point.latAsString(), + point.lonAsString()))) { + fail(); + } + }); + }); } namespace ThirdParty { diff --git a/Telegram/ThirdParty/xdg-desktop-portal b/Telegram/ThirdParty/xdg-desktop-portal index 11c8a96b14..23a76c3921 160000 --- a/Telegram/ThirdParty/xdg-desktop-portal +++ b/Telegram/ThirdParty/xdg-desktop-portal @@ -1 +1 @@ -Subproject commit 11c8a96b147aeae70e3f770313f93b367d53fedd +Subproject commit 23a76c392170dbbd26230f85ef56c3a57e52b857