mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
Refactor GUI rendering model to be two-phased.
Instead of clients painting whenever they feel like it, we now ask that they paint in response to a paint message. After finishing painting, clients notify the WindowServer about the rect(s) they painted into and then flush eventually happens, etc. This stuff leaves us with a lot of badly named things. Need to fix that.
This commit is contained in:
parent
3a401d5249
commit
7cf3c7461c
16 changed files with 117 additions and 40 deletions
|
@ -134,7 +134,7 @@ void GEventLoop::wait_for_event()
|
|||
}
|
||||
switch (event.type) {
|
||||
case GUI_Event::Type::Paint:
|
||||
dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height); break;
|
||||
dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height);
|
||||
handle_paint_event(event, *window);
|
||||
break;
|
||||
case GUI_Event::Type::MouseDown:
|
||||
|
|
|
@ -106,7 +106,7 @@ void GWidget::update()
|
|||
if (m_has_pending_paint_event)
|
||||
return;
|
||||
m_has_pending_paint_event = true;
|
||||
GEventLoop::main().post_event(w, make<GPaintEvent>(relative_rect()));
|
||||
w->update(relative_rect());
|
||||
}
|
||||
|
||||
GWidget::HitTestResult GWidget::hit_test(int x, int y)
|
||||
|
|
|
@ -49,11 +49,18 @@ GWindow::~GWindow()
|
|||
void GWindow::set_title(String&& title)
|
||||
{
|
||||
dbgprintf("GWindow::set_title \"%s\"\n", title.characters());
|
||||
GUI_WindowParameters params;
|
||||
int rc = gui_set_window_title(m_window_id, title.characters(), title.length());
|
||||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
String GWindow::title() const
|
||||
{
|
||||
char buffer[256];
|
||||
int rc = gui_get_window_title(m_window_id, buffer, sizeof(buffer));
|
||||
ASSERT(rc >= 0);
|
||||
return String(buffer, rc);
|
||||
}
|
||||
|
||||
void GWindow::set_rect(const Rect& a_rect)
|
||||
{
|
||||
dbgprintf("GWindow::set_rect! %d,%d %dx%d\n", a_rect.x(), a_rect.y(), a_rect.width(), a_rect.height());
|
||||
|
@ -85,7 +92,7 @@ void GWindow::event(GEvent& event)
|
|||
rect = m_main_widget->rect();
|
||||
m_main_widget->event(*make<GPaintEvent>(rect));
|
||||
GUI_Rect gui_rect = rect;
|
||||
int rc = gui_invalidate_window(m_window_id, &gui_rect);
|
||||
int rc = gui_notify_paint_finished(m_window_id, &gui_rect);
|
||||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
|
@ -105,9 +112,11 @@ void GWindow::show()
|
|||
{
|
||||
}
|
||||
|
||||
void GWindow::update()
|
||||
void GWindow::update(const Rect& a_rect)
|
||||
{
|
||||
GEventLoop::main().post_event(this, make<GPaintEvent>());
|
||||
GUI_Rect rect = a_rect;
|
||||
int rc = gui_invalidate_window(m_window_id, a_rect.is_null() ? nullptr : &rect);
|
||||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void GWindow::set_main_widget(GWidget* widget)
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
|
||||
int window_id() const { return m_window_id; }
|
||||
|
||||
String title() const;
|
||||
void set_title(String&&);
|
||||
|
||||
int x() const { return rect().x(); }
|
||||
|
@ -40,7 +41,7 @@ public:
|
|||
|
||||
void show();
|
||||
|
||||
void update();
|
||||
void update(const Rect& = Rect());
|
||||
|
||||
private:
|
||||
RetainPtr<GraphicsBitmap> m_backing;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue