46f4857d391186c042f0aa31e711c0aaa8fe1398
[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 #include "winnie.h"
30
31 class Window;
32
33 bool init_window_manager();
34 void destroy_window_manager(); 
35
36 class WindowManager {
37 private:
38         std::list<Window*> windows;
39
40         std::list<Rect> dirty_rects;
41
42         int bg_color[3];
43         int frame_thickness;
44         int titlebar_thickness;
45         int frame_fcolor[3];
46         int frame_ucolor[3];
47
48         Window *root_win;
49         Window *focused_win;
50         Window *grab_win;
51
52         Pixmap mouse_cursor;
53         Pixmap *background;
54
55         void create_frame(Window *win);
56         void destroy_frame(Window *win);
57
58 public:
59         WindowManager();
60         ~WindowManager();
61
62         void invalidate_region(const Rect &rect);
63         void process_windows();
64
65         void add_window(Window *win);
66         void remove_window(Window *win);
67
68         void set_focused_window(Window *win);
69         const Window *get_focused_window() const;
70         Window *get_focused_window();
71
72         Window *get_window_at_pos(int pointer_x, int pointer_y);
73         Window *get_root_window() const;
74
75         void set_focused_frame_color(int r, int g, int b);
76         void get_focused_frame_color(int *r, int *g, int *b) const;
77
78         void set_unfocused_frame_color(int r, int g, int b);
79         void get_unfocused_frame_color(int *r, int *g, int *b) const;
80
81         void set_background(const Pixmap *pixmap);
82         const Pixmap *get_background() const;
83
84         Window *get_grab_window() const;
85
86         void grab_mouse(Window *win);
87         void release_mouse();
88
89         void raise_window(Window *win);
90         void sink_window(Window *win);
91
92         void maximize_window(Window *win);
93         void unmaximize_window(Window *win);
94 };
95
96 extern WindowManager *wm;
97
98 #endif  // WM_H_