diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index e05a0701e6..b70228ad28 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -1643,15 +1643,30 @@ Panel::ExternalShellAnchor Panel::externalShellAnchor() const { if (!_webview) { return {}; } - const auto transientParent = _webview->window.winId(); - if (!transientParent) { + auto popupAnchor = _webview->window.popupAnchor(); + auto result = ExternalShellAnchor{ + .outerSize = std::move(popupAnchor.outerSize), + .transientParent = std::move(popupAnchor.transientParent), + }; + switch (result.transientParent.type) { + case Ui::Platform::ForeignParent::Type::X11: + result.anchorGeometry = Ui::Platform::ForeignWindowGeometry( + result.transientParent); + if (result.anchorGeometry) { + result.outerSize = std::nullopt; + } + break; + case Ui::Platform::ForeignParent::Type::None: + case Ui::Platform::ForeignParent::Type::Wayland: + result.anchorGeometry = std::move(popupAnchor.geometry); + break; + } + if (!result.transientParent + && !result.anchorGeometry + && !result.outerSize) { return {}; } - return { - .anchorGeometry = Ui::Platform::ForeignWindowGeometry( - transientParent), - .transientParent = transientParent, - }; + return result; } Webview::PopupResult Panel::showBlockingPopup(Webview::PopupArgs &&args) { @@ -2984,6 +2999,7 @@ void Panel::showBox( const auto anchor = externalShellAnchor(); _externalLayer->setAnchor( anchor.anchorGeometry, + anchor.outerSize, anchor.transientParent); _externalLayer->showBox(std::move(box), options, animated); return; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index edfb2ac94e..ed3f62c11a 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -11,10 +11,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/object_ptr.h" #include "base/weak_ptr.h" #include "base/flags.h" +#include "ui/platform/ui_platform_utility.h" #include "ui/rect_part.h" #include "webview/webview_common.h" #include #include +#include #include #include @@ -206,7 +208,8 @@ private: }; struct ExternalShellAnchor { std::optional anchorGeometry; - void *transientParent = nullptr; + std::optional outerSize; + Platform::ForeignParent transientParent; }; class Button; struct Progress; diff --git a/Telegram/SourceFiles/ui/layers/standalone_layer_stack.cpp b/Telegram/SourceFiles/ui/layers/standalone_layer_stack.cpp index 345ed2968a..0bec21d4a3 100644 --- a/Telegram/SourceFiles/ui/layers/standalone_layer_stack.cpp +++ b/Telegram/SourceFiles/ui/layers/standalone_layer_stack.cpp @@ -163,9 +163,14 @@ void StandaloneLayerStack::hideLayers(anim::type animated) { void StandaloneLayerStack::setAnchor( std::optional geometry, - void *transientParent) { + std::optional outerSize, + Platform::ForeignParent transientParent) { _anchorGeometry = std::move(geometry); - _transientParent = transientParent; + _anchorOuterSize = std::move(outerSize); + _transientParent = std::move(transientParent); + for (const auto &entry : _entries) { + entry.panel->setAnchorData(_anchorGeometry, _transientParent); + } } ShowFactory StandaloneLayerStack::showFactory() { @@ -176,6 +181,9 @@ ShowFactory StandaloneLayerStack::showFactory() { } std::optional StandaloneLayerStack::layerOuterSize() { + if (_anchorOuterSize) { + return _anchorOuterSize; + } if (_anchorGeometry) { return _anchorGeometry->size(); } @@ -205,6 +213,9 @@ void StandaloneLayerStack::closeEntry(SeparatePanel *panel) { entry.panel->hideGetDuration(); _boxClosed.fire({}); if (wasTop && !_entries.empty()) { + _entries.back().panel->setAnchorData( + _anchorGeometry, + _transientParent); _entries.back().panel->showAndActivate(); } } diff --git a/Telegram/SourceFiles/ui/layers/standalone_layer_stack.h b/Telegram/SourceFiles/ui/layers/standalone_layer_stack.h index 31b202433f..2f61b98834 100644 --- a/Telegram/SourceFiles/ui/layers/standalone_layer_stack.h +++ b/Telegram/SourceFiles/ui/layers/standalone_layer_stack.h @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/object_ptr.h" #include "base/unique_qptr.h" #include "base/weak_ptr.h" +#include "ui/platform/ui_platform_utility.h" #include "ui/layers/layer_widget.h" #include @@ -44,7 +45,10 @@ public: LayerOptions options, anim::type animated) override; void hideLayers(anim::type animated) override; - void setAnchor(std::optional geometry, void *transientParent); + void setAnchor( + std::optional geometry, + std::optional outerSize, + Platform::ForeignParent transientParent); ShowFactory showFactory() override; std::optional layerOuterSize() override; bool centerWithinOuter() override { @@ -75,7 +79,8 @@ private: std::vector _entries; std::optional _anchorGeometry; - void *_transientParent = nullptr; + std::optional _anchorOuterSize; + Platform::ForeignParent _transientParent; rpl::event_stream<> _boxAdded; rpl::event_stream<> _boxClosed; diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 8cf2331876..401b08210d 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 8cf2331876d05fbf06301c5313e5568553a06fe2 +Subproject commit 401b08210d44bfafbad11251eab139a80608bcc7