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