Skip to content

Commit

Permalink
Delay UpdatePowerSaveBlocker to show in media viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Jun 22, 2024
1 parent 006d6fe commit eea50ed
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ OverlayWidget::OverlayWidget()
_window->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
}
_widget->setMouseTracking(true);
_window->createWinId();

_window->screenValue(
) | rpl::skip(1) | rpl::start_with_next([=](not_null<QScreen*> screen) {
Expand Down Expand Up @@ -3823,12 +3822,17 @@ void OverlayWidget::updatePowerSaveBlocker(
&& _document->isVideoFile()
&& !IsPausedOrPausing(state.state)
&& !IsStoppedOrStopping(state.state);
base::UpdatePowerSaveBlocker(
_streamed->powerSaveBlocker,
block,
base::PowerSaveBlockType::PreventDisplaySleep,
[] { return u"Video playback is active"_q; },
[=] { return window(); });

_window->shownValue() | rpl::filter([=](bool shown) {
return shown;
}) | rpl::take(1) | rpl::start_with_next([=] {
base::UpdatePowerSaveBlocker(
_streamed->powerSaveBlocker,
block,
base::PowerSaveBlockType::PreventDisplaySleep,
[] { return u"Video playback is active"_q; },
[=] { return window(); });
}, lifetime());
}

QImage OverlayWidget::transformedShownContent() const {
Expand Down

0 comments on commit eea50ed

Please sign in to comment.