Stop animations when window is hidden (API + UWP)

This commit is contained in:
Paul Rouget 2020-02-19 14:09:50 +01:00
parent 5597ccf57d
commit 6ddde1a3e1
11 changed files with 77 additions and 0 deletions

View file

@ -71,6 +71,10 @@ void BrowserPage::BindServoEvents() {
? Visibility::Collapsed
: Visibility::Visible);
});
Window::Current().VisibilityChanged(
[=](const auto &, const VisibilityChangedEventArgs &args) {
servoControl().ChangeVisibility(args.Visible());
});
}
void BrowserPage::OnURLFocused(Windows::Foundation::IInspectable const &) {

View file

@ -56,6 +56,7 @@ public:
void Reload() { capi::reload(); }
void Stop() { capi::stop(); }
bool LoadUri(hstring uri) { return capi::load_uri(*hstring2char(uri)); }
void ChangeVisibility(bool visible) { capi::change_visibility(visible); }
bool IsUriValid(hstring uri) {
return capi::is_uri_valid(*hstring2char(uri));
}

View file

@ -247,6 +247,9 @@ void ServoControl::GoForward() {
void ServoControl::Reload() {
RunOnGLThread([=] { mServo->Reload(); });
}
void ServoControl::ChangeVisibility(bool visible) {
RunOnGLThread([=] { mServo->ChangeVisibility(visible); });
}
void ServoControl::Stop() {
RunOnGLThread([=] { mServo->Stop(); });
}

View file

@ -13,6 +13,7 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
void GoForward();
void Reload();
void Stop();
void ChangeVisibility(bool);
void Shutdown();
hstring LoadURIOrSearch(hstring);
void SendMediaSessionAction(int32_t);

View file

@ -14,6 +14,7 @@ namespace ServoApp {
void SetTransientMode(Boolean transient);
void SetArgs(String args);
void Shutdown();
void ChangeVisibility(Boolean visible);
void SendMediaSessionAction(UInt32 action);
event EventDelegate OnLoadStarted;
event EventDelegate OnLoadEnded;