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