added license GPL
[winnie] / src / wm.h
1 /*
2 winnie - an experimental window system
3
4 Copyright (C) 2013 Eleni Maria Stea
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 Author: Eleni Maria Stea <elene.mst@gmail.com>
20 */
21
22 #ifndef WM_H_
23 #define WM_H_
24
25 #include <list>
26
27 #include "geom.h"
28 #include "pixmap.h"
29
30 class Window;
31
32 bool init_window_manager();
33 void destroy_window_manager(); 
34
35 class WindowManager {
36 private:
37         std::list<Window*> windows;
38
39         std::list<Rect> dirty_rects;
40
41         int bg_color[3];
42         int frame_thickness;
43         int titlebar_thickness;
44         int frame_fcolor[3];
45         int frame_ucolor[3];
46
47         Window *root_win;
48         Window *focused_win;
49         Window *grab_win;
50
51         Pixmap mouse_cursor;
52         Pixmap *background;
53
54         void create_frame(Window *win);
55         void destroy_frame(Window *win);
56
57 public:
58         WindowManager();
59         ~WindowManager();
60
61         void invalidate_region(const Rect &rect);
62         void process_windows();
63
64         void add_window(Window *win);
65         void remove_window(Window *win);
66
67         void set_focused_window(Window *win);
68         const Window *get_focused_window() const;
69         Window *get_focused_window();
70
71         Window *get_window_at_pos(int pointer_x, int pointer_y);
72         Window *get_root_window() const;
73
74         void set_focused_frame_color(int r, int g, int b);
75         void get_focused_frame_color(int *r, int *g, int *b) const;
76
77         void set_unfocused_frame_color(int r, int g, int b);
78         void get_unfocused_frame_color(int *r, int *g, int *b) const;
79
80         void set_background(const Pixmap *pixmap);
81         const Pixmap *get_background() const;
82
83         Window *get_grab_window() const;
84
85         void grab_mouse(Window *win);
86         void release_mouse();
87
88         void raise_window(Window *win);
89         void sink_window(Window *win);
90
91         void maximize_window(Window *win);
92         void unmaximize_window(Window *win);
93 };
94
95 extern WindowManager *wm;
96
97 #endif  // WM_H_