X-Git-Url: http://git.mutantstargoat.com?p=winnie;a=blobdiff_plain;f=src%2Fwindow.cc;h=04f72cd9e4ebd83010660db32c2ba0daec6c407b;hp=59302d4ec309f9e683413a7e5fc62f57092a7b4c;hb=e2626c41c841dbbfb64ddf6341b4e23089036299;hpb=be0a7f10421181033894629afbba677986bb9f44 diff --git a/src/window.cc b/src/window.cc index 59302d4..04f72cd 100644 --- a/src/window.cc +++ b/src/window.cc @@ -1,4 +1,26 @@ +/* +winnie - an experimental window system + +Copyright (C) 2013 Eleni Maria Stea + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +Author: Eleni Maria Stea +*/ + #include +#include //TODO #include #include "gfx.h" @@ -15,6 +37,7 @@ Window::Window() dirty = true; managed = true; focusable = true; + state = STATE_NORMAL; } Window::~Window() @@ -90,24 +113,31 @@ void Window::invalidate() wm->invalidate_region(abs_rect); } -void Window::draw(const Rect &dirty_region) +void Window::draw(Rect *dirty_region) { Rect abs_rect = get_absolute_rect(); - Rect intersect = rect_intersection(abs_rect, dirty_region); + 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(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); } } @@ -229,3 +259,13 @@ Window *Window::get_parent() { return parent; } + +void Window::set_state(State state) +{ + this->state = state; +} + +Window::State Window::get_state() const +{ + return state; +}