mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:58:12 +00:00
Stop recomposing the window hierarchy after every dang widget paint.
This commit is contained in:
parent
f3ec96a1b9
commit
cfd76ade73
8 changed files with 34 additions and 41 deletions
|
@ -19,16 +19,18 @@ Widget::~Widget()
|
|||
{
|
||||
}
|
||||
|
||||
void Widget::setWindowRelativeRect(const Rect& rect)
|
||||
void Widget::setWindowRelativeRect(const Rect& rect, bool should_update)
|
||||
{
|
||||
// FIXME: Make some kind of event loop driven ResizeEvent?
|
||||
m_relativeRect = rect;
|
||||
update();
|
||||
if (should_update)
|
||||
update();
|
||||
}
|
||||
|
||||
void Widget::repaint(const Rect& rect)
|
||||
{
|
||||
event(*make<PaintEvent>(rect));
|
||||
if (auto* w = window())
|
||||
w->repaint(rect);
|
||||
}
|
||||
|
||||
void Widget::event(Event& event)
|
||||
|
@ -109,10 +111,13 @@ void Widget::mouseMoveEvent(MouseEvent&)
|
|||
|
||||
void Widget::update()
|
||||
{
|
||||
auto* w = window();
|
||||
if (!w)
|
||||
return;
|
||||
if (m_hasPendingPaintEvent)
|
||||
return;
|
||||
m_hasPendingPaintEvent = true;
|
||||
EventLoop::main().postEvent(this, make<PaintEvent>(rect()));
|
||||
EventLoop::main().postEvent(w, make<PaintEvent>(rect()));
|
||||
}
|
||||
|
||||
Widget::HitTestResult Widget::hitTest(int x, int y)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue