Set parent window ID for portal autostart dialog

This commit is contained in:
Ilya Fedin 2020-11-08 10:47:51 +04:00 committed by John Preston
parent acaf8e4931
commit 3a45957ceb

View file

@ -20,6 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "core/crash_reports.h" #include "core/crash_reports.h"
#include "core/update_checker.h" #include "core/update_checker.h"
#include "window/window_controller.h"
#include "core/application.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtWidgets/QDesktopWidget> #include <QtWidgets/QDesktopWidget>
@ -108,8 +110,19 @@ void PortalAutostart(bool autostart, bool silent = false) {
qsl("org.freedesktop.portal.Background"), qsl("org.freedesktop.portal.Background"),
qsl("RequestBackground")); qsl("RequestBackground"));
const auto parentWindowId = [&] {
if (const auto activeWindow = Core::App().activeWindow()) {
if (!IsWayland()) {
return qsl("x11:%1").arg(QString::number(
activeWindow->widget().get()->windowHandle()->winId(),
16));
}
}
return QString();
}();
message.setArguments({ message.setArguments({
QString(), parentWindowId,
options options
}); });