2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Destroy layers not delayed.

This commit is contained in:
John Preston
2018-11-23 15:05:06 +04:00
parent 2fc5b69465
commit 23dc9ef494
6 changed files with 49 additions and 60 deletions

View File

@@ -278,32 +278,43 @@ void MainWindow::showMainMenu() {
}
void MainWindow::ensureLayerCreated() {
if (!_layer) {
_layer.create(bodyWidget());
_layer->hideFinishEvents(
) | rpl::start_with_next([=, pointer = _layer.data()] {
layerHidden(pointer);
}, _layer->lifetime());
if (controller()) {
controller()->enableGifPauseReason(Window::GifPauseReason::Layer);
}
if (_layer) {
return;
}
_layer = base::make_unique_q<Window::LayerStackWidget>(
bodyWidget());
_layer->hideFinishEvents(
) | rpl::start_with_next([=] {
destroyLayer();
}, _layer->lifetime());
if (controller()) {
controller()->enableGifPauseReason(Window::GifPauseReason::Layer);
}
}
void MainWindow::destroyLayerDelayed() {
if (_layer) {
_layer.destroyDelayed();
if (controller()) {
controller()->disableGifPauseReason(Window::GifPauseReason::Layer);
}
void MainWindow::destroyLayer() {
if (!_layer) {
return;
}
const auto resetFocus = Ui::InFocusChain(_layer);
if (resetFocus) setFocus();
_layer = nullptr;
if (controller()) {
controller()->disableGifPauseReason(Window::GifPauseReason::Layer);
}
if (resetFocus) setInnerFocus();
InvokeQueued(this, [=] {
checkHistoryActivation();
});
}
void MainWindow::ui_hideSettingsAndLayer(anim::type animated) {
if (_layer) {
_layer->hideAll(animated);
if (animated == anim::type::instant) {
destroyLayerDelayed();
destroyLayer();
}
}
}
@@ -331,7 +342,7 @@ void MainWindow::ui_showBox(
if ((animated == anim::type::instant)
&& _layer
&& !_layer->layerShown()) {
destroyLayerDelayed();
destroyLayer();
}
}
Messenger::Instance().hideMediaView();
@@ -618,19 +629,6 @@ void MainWindow::noIntro(Intro::Widget *was) {
}
}
void MainWindow::layerHidden(not_null<Window::LayerStackWidget*> layer) {
if (_layer != layer) {
return;
}
auto resetFocus = Ui::InFocusChain(layer);
if (resetFocus) setFocus();
destroyLayerDelayed();
if (resetFocus) setInnerFocus();
InvokeQueued(this, [this] {
checkHistoryActivation();
});
}
bool MainWindow::takeThirdSectionFromLayer() {
return _layer ? _layer->takeToThirdSection() : false;
}