From ac78ae823c0e7865d69b6cbe133648978f0232fd Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 22 Jul 2024 02:12:39 +0400 Subject: [PATCH] Reduce portal autostart dialog modality to parent window --- .../platform/linux/specific_linux.cpp | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 6d8a8ec54..32437fb77 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -18,8 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/localstorage.h" #include "core/launcher.h" #include "core/sandbox.h" +#include "core/application.h" #include "core/core_settings.h" #include "core/update_checker.h" +#include "window/window_controller.h" #include "webview/platform/linux/webview_linux_webkitgtk.h" #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION @@ -92,10 +94,23 @@ void PortalAutostart(bool enabled, Fn done) { uniqueName.erase(0, 1); uniqueName.replace(uniqueName.find('.'), 1, 1, '_'); - const auto window = std::make_shared(); - window->setAttribute(Qt::WA_DontShowOnScreen); - window->setWindowModality(Qt::ApplicationModal); - window->show(); + const auto parent = []() -> QPointer { + const auto active = Core::App().activeWindow(); + if (!active) { + return nullptr; + } + + return active->widget().get(); + }(); + + const auto window = std::make_shared>( + std::in_place, + parent); + + auto &raw = **window; + raw.setAttribute(Qt::WA_DontShowOnScreen); + raw.setWindowModality(Qt::WindowModal); + raw.show(); XdpRequest::RequestProxy::new_( proxy->get_connection(), @@ -146,7 +161,6 @@ void PortalAutostart(bool enabled, Fn done) { }); }); - std::vector commandline; commandline.push_back(executable.toStdString()); if (Core::Launcher::Instance().customWorkingDir()) { @@ -156,7 +170,9 @@ void PortalAutostart(bool enabled, Fn done) { commandline.push_back("-autostart"); interface.call_request_background( - base::Platform::XDP::ParentWindowID(), + base::Platform::XDP::ParentWindowID(parent + ? parent->windowHandle() + : nullptr), GLib::Variant::new_array({ GLib::Variant::new_dict_entry( GLib::Variant::new_string("handle_token"),