summaryrefslogtreecommitdiff
path: root/Servers/WindowServer/Compositor.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-22 21:13:23 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-22 21:13:23 +0100
commit424a3f5ac3c659d57d38aba36f4062c8ecbc4044 (patch)
treec9b64b14cde9dd11d7b159beff12a89e2e470d2e /Servers/WindowServer/Compositor.cpp
parentbb70d0692b4aab9ec4cf24cc35abb35e2f8ef2a2 (diff)
downloadserenity-424a3f5ac3c659d57d38aba36f4062c8ecbc4044.zip
WindowServer+LibGUI: Add a way to get notified at display refresh rate
This patch adds GUI::DisplayLink, a mechanism for registering callbacks that will fire at the display refresh rate. Note that we don't actually know the screen refresh rate, but this is instead completely driven by WindowServer's compositing timer. For all current intents and purposes it does the job well enough. :^)
Diffstat (limited to 'Servers/WindowServer/Compositor.cpp')
-rw-r--r--Servers/WindowServer/Compositor.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Servers/WindowServer/Compositor.cpp b/Servers/WindowServer/Compositor.cpp
index a821855a16..e5cf24182b 100644
--- a/Servers/WindowServer/Compositor.cpp
+++ b/Servers/WindowServer/Compositor.cpp
@@ -25,6 +25,7 @@
*/
#include "Compositor.h"
+#include "ClientConnection.h"
#include "Event.h"
#include "EventLoop.h"
#include "Screen.h"
@@ -69,6 +70,7 @@ Compositor::Compositor()
init_bitmaps();
m_compose_timer->on_timeout = [&]() {
+ notify_display_links();
#if defined(COMPOSITOR_DEBUG)
dbgprintf("Compositor: delayed frame callback: %d rects\n", m_dirty_rects.size());
#endif
@@ -466,4 +468,11 @@ void Compositor::draw_cursor()
m_last_cursor_rect = cursor_rect;
}
+void Compositor::notify_display_links()
+{
+ ClientConnection::for_each_client([](auto& client) {
+ client.notify_display_link({});
+ });
+}
+
}