]> Dogcows Code - chaz/openbox/blob - src/blackbox.hh
move Rect and PointerAssassin into the toolkit
[chaz/openbox] / src / blackbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __blackbox_hh
3 #define __blackbox_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7
8 #ifdef HAVE_STDIO_H
9 # include <stdio.h>
10 #endif // HAVE_STDIO_H
11
12 #ifdef TIME_WITH_SYS_TIME
13 # include <sys/time.h>
14 # include <time.h>
15 #else // !TIME_WITH_SYS_TIME
16 # ifdef HAVE_SYS_TIME_H
17 # include <sys/time.h>
18 # else // !HAVE_SYS_TIME_H
19 # include <time.h>
20 # endif // HAVE_SYS_TIME_H
21 #endif // TIME_WITH_SYS_TIME
22 }
23
24 #include <list>
25 #include <map>
26 #include <string>
27
28 #include "basedisplay.hh"
29 #include "configuration.hh"
30 #include "timer.hh"
31 #include "xatom.hh"
32
33 #define AttribShaded (1l << 0)
34 #define AttribMaxHoriz (1l << 1)
35 #define AttribMaxVert (1l << 2)
36 #define AttribOmnipresent (1l << 3)
37 #define AttribWorkspace (1l << 4)
38 #define AttribStack (1l << 5)
39 #define AttribDecoration (1l << 6)
40
41 #define StackTop (0)
42 #define StackNormal (1)
43 #define StackBottom (2)
44
45 #define DecorNone (0)
46 #define DecorNormal (1)
47 #define DecorTiny (2)
48 #define DecorTool (3)
49
50 struct BlackboxHints {
51 unsigned long flags, attrib, workspace, stack, decoration;
52 };
53
54 struct BlackboxAttributes {
55 unsigned long flags, attrib, workspace, stack, decoration;
56 int premax_x, premax_y;
57 unsigned int premax_w, premax_h;
58 };
59
60 #define PropBlackboxHintsElements (5)
61 #define PropBlackboxAttributesElements (9)
62
63
64 //forward declaration
65 class BScreen;
66 class Blackbox;
67 class BlackboxWindow;
68 class BWindowGroup;
69
70 class Blackbox : public BaseDisplay, public TimeoutHandler {
71 private:
72 struct BCursor {
73 Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
74 };
75 BCursor cursor;
76
77 struct BResource {
78 Time double_click_interval;
79
80 std::string style_file;
81 int colors_per_channel;
82 timeval auto_raise_delay;
83 unsigned long cache_life, cache_max;
84 std::string titlebar_layout;
85 unsigned int mod_mask; // modifier mask used for window-mouse interaction
86
87
88 #ifdef XINERAMA
89 bool xinerama_placement, xinerama_maximize, xinerama_snap;
90 #endif // XINERAMA
91 } resource;
92
93 typedef std::map<Window, BlackboxWindow*> WindowLookup;
94 typedef WindowLookup::value_type WindowLookupPair;
95 WindowLookup windowSearchList;
96
97 typedef std::map<Window, BScreen*> WindowScreenLookup;
98 typedef WindowScreenLookup::value_type WindowScreenLookupPair;
99 WindowScreenLookup systraySearchList;
100
101 typedef std::map<Window, BWindowGroup*> GroupLookup;
102 typedef GroupLookup::value_type GroupLookupPair;
103 GroupLookup groupSearchList;
104
105 typedef std::list<BScreen*> ScreenList;
106 ScreenList screenList;
107
108 BScreen *active_screen;
109 BlackboxWindow *focused_window, *changing_window;
110 BTimer *timer;
111 Configuration config;
112 XAtom *xatom;
113
114 bool no_focus, reconfigure_wait;
115 Time last_time;
116 char **argv;
117 std::string rc_file;
118
119 Blackbox(const Blackbox&);
120 Blackbox& operator=(const Blackbox&);
121
122 void load_rc(void);
123 void save_rc(void);
124 void real_reconfigure(void);
125
126 virtual void process_event(XEvent *);
127
128
129 public:
130 Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0);
131 virtual ~Blackbox(void);
132
133 BWindowGroup *searchGroup(Window window);
134 BScreen *searchSystrayWindow(Window window);
135 BlackboxWindow *searchWindow(Window window);
136 BScreen *searchScreen(Window window);
137
138 #ifdef XINERAMA
139 inline bool doXineramaPlacement(void) const
140 { return resource.xinerama_placement; }
141 inline bool doXineramaMaximizing(void) const
142 { return resource.xinerama_maximize; }
143 inline bool doXineramaSnapping(void) const
144 { return resource.xinerama_snap; }
145
146 void saveXineramaPlacement(bool x);
147 void saveXineramaMaximizing(bool x);
148 void saveXineramaSnapping(bool x);
149 #endif // XINERAMA
150
151 void saveSystrayWindowSearch(Window window, BScreen *screen);
152 void saveWindowSearch(Window window, BlackboxWindow *data);
153 void saveGroupSearch(Window window, BWindowGroup *data);
154 void removeSystrayWindowSearch(Window window);
155 void removeWindowSearch(Window window);
156 void removeGroupSearch(Window window);
157
158 inline XAtom *getXAtom(void) { return xatom; }
159
160 inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
161 inline BlackboxWindow *getChangingWindow(void) { return changing_window; }
162
163 inline Configuration *getConfig() { return &config; }
164 inline const Time &getDoubleClickInterval(void) const
165 { return resource.double_click_interval; }
166 inline const Time &getLastTime(void) const { return last_time; }
167
168 inline const char *getStyleFilename(void) const
169 { return resource.style_file.c_str(); }
170
171 inline int getColorsPerChannel(void) const
172 { return resource.colors_per_channel; }
173
174 inline std::string getTitlebarLayout(void) const
175 { return resource.titlebar_layout; }
176
177 inline const timeval &getAutoRaiseDelay(void) const
178 { return resource.auto_raise_delay; }
179
180 inline unsigned long getCacheLife(void) const
181 { return resource.cache_life; }
182 inline unsigned long getCacheMax(void) const
183 { return resource.cache_max; }
184
185 inline void setNoFocus(bool f) { no_focus = f; }
186
187 inline Cursor getSessionCursor(void) const
188 { return cursor.session; }
189 inline Cursor getMoveCursor(void) const
190 { return cursor.move; }
191 inline Cursor getLowerLeftAngleCursor(void) const
192 { return cursor.ll_angle; }
193 inline Cursor getLowerRightAngleCursor(void) const
194 { return cursor.lr_angle; }
195 inline Cursor getUpperLeftAngleCursor(void) const
196 { return cursor.ul_angle; }
197 inline Cursor getUpperRightAngleCursor(void) const
198 { return cursor.ur_angle; }
199
200 inline unsigned int getMouseModMask(void) const
201 { return resource.mod_mask; }
202
203 void setFocusedWindow(BlackboxWindow *win);
204 void setChangingWindow(BlackboxWindow *win);
205 void shutdown(void);
206 void saveStyleFilename(const std::string& filename);
207 void restart(const char *prog = 0);
208 void reconfigure(void);
209
210 bool validateWindow(Window window);
211
212 virtual bool handleSignal(int sig);
213
214 virtual void timeout(void);
215
216 enum { B_AmericanDate = 1, B_EuropeanDate };
217 };
218
219
220 #endif // __blackbox_hh
This page took 0.041149 seconds and 4 git commands to generate.