Reduce portal autostart dialog modality to parent window

This commit is contained in:
Ilya Fedin 2024-07-22 02:12:39 +04:00 committed by John Preston
parent 1ef6f462f6
commit ac78ae823c

View File

@ -18,8 +18,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "core/launcher.h" #include "core/launcher.h"
#include "core/sandbox.h" #include "core/sandbox.h"
#include "core/application.h"
#include "core/core_settings.h" #include "core/core_settings.h"
#include "core/update_checker.h" #include "core/update_checker.h"
#include "window/window_controller.h"
#include "webview/platform/linux/webview_linux_webkitgtk.h" #include "webview/platform/linux/webview_linux_webkitgtk.h"
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
@ -92,10 +94,23 @@ void PortalAutostart(bool enabled, Fn<void(bool)> done) {
uniqueName.erase(0, 1); uniqueName.erase(0, 1);
uniqueName.replace(uniqueName.find('.'), 1, 1, '_'); uniqueName.replace(uniqueName.find('.'), 1, 1, '_');
const auto window = std::make_shared<QWidget>(); const auto parent = []() -> QPointer<QWidget> {
window->setAttribute(Qt::WA_DontShowOnScreen); const auto active = Core::App().activeWindow();
window->setWindowModality(Qt::ApplicationModal); if (!active) {
window->show(); return nullptr;
}
return active->widget().get();
}();
const auto window = std::make_shared<base::unique_qptr<QWidget>>(
std::in_place,
parent);
auto &raw = **window;
raw.setAttribute(Qt::WA_DontShowOnScreen);
raw.setWindowModality(Qt::WindowModal);
raw.show();
XdpRequest::RequestProxy::new_( XdpRequest::RequestProxy::new_(
proxy->get_connection(), proxy->get_connection(),
@ -146,7 +161,6 @@ void PortalAutostart(bool enabled, Fn<void(bool)> done) {
}); });
}); });
std::vector<std::string> commandline; std::vector<std::string> commandline;
commandline.push_back(executable.toStdString()); commandline.push_back(executable.toStdString());
if (Core::Launcher::Instance().customWorkingDir()) { if (Core::Launcher::Instance().customWorkingDir()) {
@ -156,7 +170,9 @@ void PortalAutostart(bool enabled, Fn<void(bool)> done) {
commandline.push_back("-autostart"); commandline.push_back("-autostart");
interface.call_request_background( interface.call_request_background(
base::Platform::XDP::ParentWindowID(), base::Platform::XDP::ParentWindowID(parent
? parent->windowHandle()
: nullptr),
GLib::Variant::new_array({ GLib::Variant::new_array({
GLib::Variant::new_dict_entry( GLib::Variant::new_dict_entry(
GLib::Variant::new_string("handle_token"), GLib::Variant::new_string("handle_token"),