mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibGUI: Make Widget ignore paint events that don't intersect it
LibGUI widgets fully contain their child widgets, so there's no pass the paint event on to our children if we get a paint event that doesn't intersect with our rect. While Gfx::Painter was already dutifully clipping out any attempts at painting, this avoids even more pointless work.
This commit is contained in:
parent
13a14b3112
commit
b7e551b164
1 changed files with 7 additions and 0 deletions
|
@ -318,6 +318,13 @@ void Widget::handle_keydown_event(KeyEvent& event)
|
|||
void Widget::handle_paint_event(PaintEvent& event)
|
||||
{
|
||||
VERIFY(is_visible());
|
||||
|
||||
if (!rect().intersects(event.rect())) {
|
||||
// This widget is not inside the paint event rect.
|
||||
// Since widgets fully contain their children, we don't need to recurse further.
|
||||
return;
|
||||
}
|
||||
|
||||
if (fill_with_background_color()) {
|
||||
Painter painter(*this);
|
||||
painter.fill_rect(event.rect(), palette().color(background_role()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue