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