mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Stop animations when window is hidden (API + UWP)
This commit is contained in:
parent
5597ccf57d
commit
6ddde1a3e1
11 changed files with 77 additions and 0 deletions
|
@ -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 &) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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(); });
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue