mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-25 09:04:53 +00:00
WindowServer: Fix flickering
Rather than blitting and rendering each window every time, only render what actually changed. And while doing so, only render the portions that are visible on the screen. This avoids flickering because flipping framebuffers isn't always perfectly in sync with the code, so it's possible that the flip happens slightly delayed and we can briefly see the next iteration having partially completed. Also, avoid touching the mouse cursor unless it is in an area that needs updating. This reduces flickering unless it is over an area that is updated often. And because we no longer render the entire screen, we'll save the contents below the cursor so that we can hide it before touching that area. Fixes #2981
This commit is contained in:
@@ -65,7 +65,7 @@ void Button::on_mouse_event(const MouseEvent& event)
|
||||
if (event.type() == Event::MouseDown && event.button() == MouseButton::Left) {
|
||||
m_pressed = true;
|
||||
wm.set_cursor_tracking_button(this);
|
||||
wm.invalidate(screen_rect());
|
||||
m_frame.invalidate(m_relative_rect);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void Button::on_mouse_event(const MouseEvent& event)
|
||||
// However, we don't know that rect yet. We can make an educated
|
||||
// guess which also looks okay even when wrong:
|
||||
m_hovered = false;
|
||||
wm.invalidate(screen_rect());
|
||||
m_frame.invalidate(m_relative_rect);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ void Button::on_mouse_event(const MouseEvent& event)
|
||||
m_hovered = rect().contains(event.position());
|
||||
wm.set_hovered_button(m_hovered ? this : nullptr);
|
||||
if (old_hovered != m_hovered)
|
||||
wm.invalidate(screen_rect());
|
||||
m_frame.invalidate(m_relative_rect);
|
||||
}
|
||||
|
||||
if (event.type() == Event::MouseMove && event.buttons() & (unsigned)MouseButton::Left) {
|
||||
@@ -104,7 +104,7 @@ void Button::on_mouse_event(const MouseEvent& event)
|
||||
bool old_pressed = m_pressed;
|
||||
m_pressed = m_hovered;
|
||||
if (old_pressed != m_pressed)
|
||||
wm.invalidate(screen_rect());
|
||||
m_frame.invalidate(m_relative_rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user