mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
LibCore+LibGUI: Don't fire timers in non-visible windows by default
LibCore timers now have a TimerShouldFireWhenNotVisible flag which is set to "No" by default. If "No", the timer will not be fired by the event loop if it's within a CObject tree whose nearest GWindow ancestor is currently not visible for timer purposes. (Specificially, this means that the window is either minimized or fully occluded, and so does not want to fire timers just to update the UI.) This is another nice step towards a calm and serene operating system.
This commit is contained in:
parent
f8f2b8b520
commit
411d293961
6 changed files with 42 additions and 9 deletions
|
@ -100,14 +100,14 @@ void CObject::custom_event(CCustomEvent&)
|
|||
{
|
||||
}
|
||||
|
||||
void CObject::start_timer(int ms)
|
||||
void CObject::start_timer(int ms, TimerShouldFireWhenNotVisible fire_when_not_visible)
|
||||
{
|
||||
if (m_timer_id) {
|
||||
dbgprintf("CObject{%p} already has a timer!\n", this);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
m_timer_id = CEventLoop::register_timer(*this, ms, true);
|
||||
m_timer_id = CEventLoop::register_timer(*this, ms, true, fire_when_not_visible);
|
||||
}
|
||||
|
||||
void CObject::stop_timer()
|
||||
|
@ -165,3 +165,10 @@ void CObject::dispatch_event(CEvent& e, CObject* stay_within)
|
|||
target = target->parent();
|
||||
} while (target && target != stay_within && !e.is_accepted());
|
||||
}
|
||||
|
||||
bool CObject::is_visible_for_timer_purposes() const
|
||||
{
|
||||
if (parent())
|
||||
return parent()->is_visible_for_timer_purposes();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue