summaryrefslogtreecommitdiff
path: root/Libraries/LibCore/CEventLoop.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-29 15:58:07 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-29 16:03:36 +0100
commit411d2939615dd3e72866666013a4d93b2ad0caf4 (patch)
tree1f4c7487929912b2569c6ee2791dc8a77a16a4a6 /Libraries/LibCore/CEventLoop.h
parentf8f2b8b520d7fdcd145bbbb3c6e8c4c7b28687c8 (diff)
downloadserenity-411d2939615dd3e72866666013a4d93b2ad0caf4.zip
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.
Diffstat (limited to 'Libraries/LibCore/CEventLoop.h')
-rw-r--r--Libraries/LibCore/CEventLoop.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/Libraries/LibCore/CEventLoop.h b/Libraries/LibCore/CEventLoop.h
index 5166b79093..af942bef19 100644
--- a/Libraries/LibCore/CEventLoop.h
+++ b/Libraries/LibCore/CEventLoop.h
@@ -38,7 +38,7 @@ public:
bool was_exit_requested() const { return m_exit_requested; }
- static int register_timer(CObject&, int milliseconds, bool should_reload);
+ static int register_timer(CObject&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible);
static bool unregister_timer(int timer_id);
static void register_notifier(Badge<CNotifier>, CNotifier&);
@@ -77,6 +77,7 @@ private:
int interval { 0 };
timeval fire_time { 0, 0 };
bool should_reload { false };
+ TimerShouldFireWhenNotVisible fire_when_not_visible { TimerShouldFireWhenNotVisible::No };
WeakPtr<CObject> owner;
void reload(const timeval& now);