summaryrefslogtreecommitdiff
path: root/WindowServer/WSMessageLoop.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-17 01:30:23 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-17 01:30:55 +0100
commitd3dcb4222772462dd8193ce154efd1c1e4d82e95 (patch)
tree96271aad00094f3d10de320a46f46cb065d28eca /WindowServer/WSMessageLoop.cpp
parent1c6dfc3282d219f20a7de1e266a8052b9e4c94b6 (diff)
downloadserenity-d3dcb4222772462dd8193ce154efd1c1e4d82e95.zip
WindowServer: Don't nap in the message loop if there's a queued message.
This fixes a bug where clicking on a button would sometimes take a while before showing up visually.
Diffstat (limited to 'WindowServer/WSMessageLoop.cpp')
-rw-r--r--WindowServer/WSMessageLoop.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/WindowServer/WSMessageLoop.cpp b/WindowServer/WSMessageLoop.cpp
index 1d8f8a92e3..88fe0d5a95 100644
--- a/WindowServer/WSMessageLoop.cpp
+++ b/WindowServer/WSMessageLoop.cpp
@@ -131,20 +131,22 @@ void WSMessageLoop::wait_for_message()
});
struct timeval timeout = { 0, 0 };
- bool had_any_timer = false;
- for (auto& it : m_timers) {
- auto& timer = *it.value;
- if (!had_any_timer) {
- timeout = timer.next_fire_time;
- had_any_timer = true;
- continue;
+ if (m_queued_messages.is_empty()) {
+ bool had_any_timer = false;
+ for (auto& it : m_timers) {
+ auto& timer = *it.value;
+ if (!had_any_timer) {
+ timeout = timer.next_fire_time;
+ had_any_timer = true;
+ continue;
+ }
+ if (timer.next_fire_time.tv_sec > timeout.tv_sec || (timer.next_fire_time.tv_sec == timeout.tv_sec && timer.next_fire_time.tv_usec > timeout.tv_usec))
+ timeout = timer.next_fire_time;
}
- if (timer.next_fire_time.tv_sec > timeout.tv_sec || (timer.next_fire_time.tv_sec == timeout.tv_sec && timer.next_fire_time.tv_usec > timeout.tv_usec))
- timeout = timer.next_fire_time;
}
- int rc = select(max_fd + 1, &rfds, nullptr, nullptr, m_timers.is_empty() && m_queued_messages.is_empty() ? nullptr : &timeout);
+ int rc = select(max_fd + 1, &rfds, nullptr, nullptr, m_queued_messages.is_empty() ? nullptr : &timeout);
if (rc < 0) {
ASSERT_NOT_REACHED();
}