diff --git a/Telegram/Resources/iv_html/page.css b/Telegram/Resources/iv_html/page.css
index 85a6124cc..0e0b3322a 100644
--- a/Telegram/Resources/iv_html/page.css
+++ b/Telegram/Resources/iv_html/page.css
@@ -88,6 +88,12 @@ html.custom_scroll ::-webkit-scrollbar-thumb:hover {
opacity: 1;
}
}
+#menu_page_blocker {
+ z-index: 999;
+ position: fixed;
+ width: 100%;
+ height: 100%;
+}
#top_shadow {
z-index: 999;
position: fixed;
diff --git a/Telegram/Resources/iv_html/page.js b/Telegram/Resources/iv_html/page.js
index efac9fa65..ac75d6d93 100644
--- a/Telegram/Resources/iv_html/page.js
+++ b/Telegram/Resources/iv_html/page.js
@@ -8,6 +8,11 @@ var IV = {
var target = e.target;
var context = '';
while (target) {
+ if (target.id == 'menu_page_blocker') {
+ IV.notify({ event: 'menu_page_blocker_click' });
+ IV.menuShown(false);
+ return;
+ }
if (target.tagName == 'AUDIO' || target.tagName == 'VIDEO') {
return;
}
@@ -599,6 +604,20 @@ var IV = {
back: function () {
window.history.back();
},
+ menuShown: function (shown) {
+ var already = document.getElementById('menu_page_blocker');
+ if (already && shown) {
+ return;
+ } else if (already) {
+ document.body.removeChild(already);
+ return;
+ } else if (!shown) {
+ return;
+ }
+ var blocker = document.createElement('div');
+ blocker.id = 'menu_page_blocker';
+ document.body.appendChild(blocker);
+ },
videos: {},
videosPlaying: {},
diff --git a/Telegram/SourceFiles/iv/iv_controller.cpp b/Telegram/SourceFiles/iv/iv_controller.cpp
index 67c423636..e24124ecd 100644
--- a/Telegram/SourceFiles/iv/iv_controller.cpp
+++ b/Telegram/SourceFiles/iv/iv_controller.cpp
@@ -429,6 +429,10 @@ void Controller::createWebview(const QString &dataPath) {
const auto url = object.value("url").toString();
const auto context = object.value("context").toString();
processLink(url, context);
+ } else if (event == "menu_page_blocker_click") {
+ if (_menu) {
+ _menu->hideMenu();
+ }
} else if (event == u"ready"_q) {
_ready = true;
auto script = QByteArray();
@@ -443,6 +447,9 @@ void Controller::createWebview(const QString &dataPath) {
if (base::take(_reloadInitialWhenReady)) {
script += reloadScript(0);
}
+ if (_menu) {
+ script += "IV.menuShown(true);";
+ }
if (!script.isEmpty()) {
_webview->eval(script);
}
@@ -648,7 +655,7 @@ bool Controller::active() const {
}
void Controller::showJoinedTooltip() {
- if (_webview) {
+ if (_webview && _ready) {
_webview->eval("IV.showTooltip('"
+ EscapeForScriptString(
tr::lng_action_you_joined(tr::now).toUtf8())
@@ -679,6 +686,9 @@ void Controller::showMenu() {
_menu = base::make_unique_q(
_window.get(),
st::popupMenuWithIcons);
+ if (_webview && _ready) {
+ _webview->eval("IV.menuShown(true);");
+ }
_menu->setDestroyedCallback(crl::guard(_window.get(), [
this,
weakButton = Ui::MakeWeak(_menuToggle.data()),
@@ -686,6 +696,13 @@ void Controller::showMenu() {
if (_menu == menu && weakButton) {
weakButton->setForceRippled(false);
}
+ if (const auto widget = _webview ? _webview->widget() : nullptr) {
+ InvokeQueued(widget, crl::guard(_window.get(), [=] {
+ if (_webview && _ready) {
+ _webview->eval("IV.menuShown(false);");
+ }
+ }));
+ }
}));
_menuToggle->setForceRippled(true);