2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-03 16:15:13 +00:00

Implement parent setting for portal and gtk dialogs on Wayland via xdg-foreign-v2

This commit is contained in:
Ilya Fedin
2021-05-10 12:53:34 +04:00
committed by John Preston
parent 7de8d6f9ac
commit 680a9a7ca7
10 changed files with 204 additions and 90 deletions

View File

@@ -102,18 +102,22 @@ PortalAutostart::PortalAutostart(bool start, bool silent) {
const auto parentWindowId = [&]() -> Glib::ustring {
std::stringstream result;
if (const auto activeWindow = Core::App().activeWindow()) {
if (IsX11()) {
result
<< "x11:"
<< std::hex
<< activeWindow
->widget()
.get()
->windowHandle()
->winId();
}
const auto activeWindow = Core::App().activeWindow();
if (!activeWindow) {
return result.str();
}
const auto window = activeWindow->widget()->windowHandle();
if (const auto integration = WaylandIntegration::Instance()) {
if (const auto handle = integration->nativeHandle(window)
; !handle.isEmpty()) {
result << "wayland:" << handle.toStdString();
}
} else if (IsX11()) {
result << "x11:" << std::hex << window->winId();
}
return result.str();
}();