+/*
+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 <http://www.gnu.org/licenses/>.
+
+Author: Eleni Maria Stea <elene.mst@gmail.com>
+*/
+
#include <algorithm>
#include <limits.h>
#include <stdexcept>
grab_win = 0;
focused_win = 0;
+ background = 0;
bg_color[0] = 210;
bg_color[1] = 106;
wait_vsync();
- fill_rect(uni, bg_color[0], bg_color[1], bg_color[2]);
+ if(!background) {
+ fill_rect(uni, bg_color[0], bg_color[1], bg_color[2]);
+ }
+ else {
+ blit(background->pixels, Rect(0, 0, background->width, background->height),
+ get_framebuffer(), get_screen_size(), 0, 0);
+ }
root_win->draw_children(uni);
get_framebuffer(), get_screen_size(), mouse_x, mouse_y,
0, 0, 0);
- Rect mouse_rect = {mouse_x, mouse_y, mouse_cursor.get_width(), mouse_cursor.get_height()};
+ Rect mouse_rect(mouse_x, mouse_y, mouse_cursor.get_width(), mouse_cursor.get_height());
invalidate_region(mouse_rect);
- gfx_update();
+ gfx_update(uni);
}
void WindowManager::add_window(Window *win)
*b = frame_ucolor[2];
}
+void WindowManager::set_background(const Pixmap *pixmap)
+{
+ if(background) {
+ delete background;
+ }
+
+ if(pixmap) {
+ background = new Pixmap(*pixmap);
+ }
+ else {
+ background = 0;
+ }
+}
+
+const Pixmap *WindowManager::get_background() const
+{
+ return background;
+}
+
Window *WindowManager::get_grab_window() const
{
return grab_win;
rect.height -= frame_thickness * 2 + titlebar_thickness;
}
else {
- rect.x = 0;
- rect.y = 0;
- win->move(rect.x, rect.y);
+ win->move(0, 0);
}
win->resize(rect.width, rect.height);
static long last_click = 0;
if(bn == 0) {
- if(pressed) {
+ if(pressed) {
+ wm->grab_mouse(win);
+ wm->raise_window(win);
+ prev_x = x;
+ prev_y = y;
+ }
+ else {
long time = winnie_get_time();
if((time - last_click) < DCLICK_INTERVAL) {
Window *child = win->get_children()[0];
Window::State state = child->get_state();
if(state == Window::STATE_MAXIMIZED) {
- child->set_state(Window::STATE_NORMAL);
wm->unmaximize_window(child);
}
else if(state == Window::STATE_NORMAL) {
wm->maximize_window(child);
}
}
-
- wm->grab_mouse(win);
- wm->raise_window(win);
- prev_x = x;
- prev_y = y;
-
last_click = time;
- }
- else {
+
wm->release_mouse();
}
}
prev_x = x - dx;
prev_y = y - dy;
- Rect rect = win->get_rect();
- win->move(rect.x + dx, rect.y + dy);
+ if(win->get_children()[0]->get_state() != Window::STATE_MAXIMIZED) {
+ Rect rect = win->get_rect();
+ win->move(rect.x + dx, rect.y + dy);
+ }
}
}