X-Git-Url: https://eleni.mutantstargoat.com/git/?a=blobdiff_plain;f=src%2Fwindow.cc;h=fb46b381da7e53eee2b2eac5a7a0d1d9d101bb2e;hb=59cd3a77c4517e387f4c2e21e8b62a9017370116;hp=b5635ed856cda6afe04c1c2f9c8e05be74866d5c;hpb=981f0eab2195d34f7c186a2e3e891810e14ce5b4;p=winnie diff --git a/src/window.cc b/src/window.cc index b5635ed..fb46b38 100644 --- a/src/window.cc +++ b/src/window.cc @@ -1,4 +1,5 @@ #include +#include //TODO #include #include "gfx.h" @@ -86,30 +87,35 @@ const char *Window::get_title() const void Window::invalidate() { dirty = true; - Rect abs_rect = get_absolute_rect(); + Rect abs_rect = get_absolute_rect(); wm->invalidate_region(abs_rect); } -void Window::draw(const Rect &dirty_region) +void Window::draw(Rect *dirty_region) { - //TODO - //titlebar, frame - - Rect intersect = rect_intersection(rect, dirty_region); + Rect abs_rect = get_absolute_rect(); + Rect intersect = rect_intersection(abs_rect, *dirty_region); if(intersect.width && intersect.height) { + Rect prev_clip = get_clipping_rect(); + set_clipping_rect(abs_rect); + if(callbacks.display) { callbacks.display(this); } dirty = false; - draw_children(rect); + draw_children(abs_rect); + + *dirty_region = rect_union(*dirty_region, abs_rect); + set_clipping_rect(prev_clip); } } void Window::draw_children(const Rect &dirty_region) { + Rect drect = dirty_region; for(size_t i=0; idraw(dirty_region); + children[i]->draw(&drect); } } @@ -145,6 +151,11 @@ bool Window::get_focusable() const return focusable; } +bool Window::get_dirty() const +{ + return dirty; +} + void Window::set_display_callback(DisplayFuncType func) { callbacks.display = func;