]> icculus.org git repositories - mikachu/openbox.git/blob - src/blackbox.hh
compiles now. uses xft2
[mikachu/openbox.git] / src / blackbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // blackbox.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #ifndef   __blackbox_hh
25 #define   __blackbox_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29
30 #ifdef    HAVE_STDIO_H
31 # include <stdio.h>
32 #endif // HAVE_STDIO_H
33
34 #ifdef    TIME_WITH_SYS_TIME
35 #  include <sys/time.h>
36 #  include <time.h>
37 #else // !TIME_WITH_SYS_TIME
38 #  ifdef    HAVE_SYS_TIME_H
39 #    include <sys/time.h>
40 #  else // !HAVE_SYS_TIME_H
41 #    include <time.h>
42 #  endif // HAVE_SYS_TIME_H
43 #endif // TIME_WITH_SYS_TIME
44 }
45
46 #include <list>
47 #include <map>
48 #include <string>
49
50 #include "basedisplay.hh"
51 #include "configuration.hh"
52 #include "timer.hh"
53 #include "xatom.hh"
54
55 #define AttribShaded      (1l << 0)
56 #define AttribMaxHoriz    (1l << 1)
57 #define AttribMaxVert     (1l << 2)
58 #define AttribOmnipresent (1l << 3)
59 #define AttribWorkspace   (1l << 4)
60 #define AttribStack       (1l << 5)
61 #define AttribDecoration  (1l << 6)
62
63 #define StackTop          (0)
64 #define StackNormal       (1)
65 #define StackBottom       (2)
66
67 #define DecorNone         (0)
68 #define DecorNormal       (1)
69 #define DecorTiny         (2)
70 #define DecorTool         (3)
71
72 struct BlackboxHints {
73   unsigned long flags, attrib, workspace, stack, decoration;
74 };
75
76 struct BlackboxAttributes {
77   unsigned long flags, attrib, workspace, stack, decoration;
78   int premax_x, premax_y;
79   unsigned int premax_w, premax_h;
80 };
81
82 #define PropBlackboxHintsElements      (5)
83 #define PropBlackboxAttributesElements (9)
84
85
86 //forward declaration
87 class BScreen;
88 class Blackbox;
89 class BlackboxWindow;
90 class BWindowGroup;
91
92 class Blackbox : public BaseDisplay, public TimeoutHandler {
93 private:
94   struct BCursor {
95     Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
96   };
97   BCursor cursor;
98
99   struct BResource {
100     Time double_click_interval;
101
102     std::string style_file;
103     int colors_per_channel;
104     timeval auto_raise_delay;
105     unsigned long cache_life, cache_max;
106     std::string titlebar_layout;
107     unsigned int mod_mask;  // modifier mask used for window-mouse interaction
108
109
110 #ifdef    XINERAMA
111     bool xinerama_placement, xinerama_maximize, xinerama_snap;
112 #endif // XINERAMA
113   } resource;
114
115   typedef std::map<Window, BlackboxWindow*> WindowLookup;
116   typedef WindowLookup::value_type WindowLookupPair;
117   WindowLookup windowSearchList;
118
119   typedef std::map<Window, BScreen*> WindowScreenLookup;
120   typedef WindowScreenLookup::value_type WindowScreenLookupPair;
121   WindowScreenLookup systraySearchList;
122
123   typedef std::map<Window, BWindowGroup*> GroupLookup;
124   typedef GroupLookup::value_type GroupLookupPair;
125   GroupLookup groupSearchList;
126
127   typedef std::list<BScreen*> ScreenList;
128   ScreenList screenList;
129
130   BScreen *active_screen;
131   BlackboxWindow *focused_window, *changing_window;
132   BTimer *timer;
133   Configuration config;
134   XAtom *xatom;
135
136   bool no_focus, reconfigure_wait;
137   Time last_time;
138   char **argv;
139   std::string rc_file;
140
141   Blackbox(const Blackbox&);
142   Blackbox& operator=(const Blackbox&);
143
144   void load_rc(void);
145   void save_rc(void);
146   void real_reconfigure(void);
147
148   virtual void process_event(XEvent *);
149
150
151 public:
152   Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0);
153   virtual ~Blackbox(void);
154
155   BWindowGroup *searchGroup(Window window);
156   BScreen *searchSystrayWindow(Window window);
157   BlackboxWindow *searchWindow(Window window);
158   BScreen *searchScreen(Window window);
159
160 #ifdef    XINERAMA
161   inline bool doXineramaPlacement(void) const
162     { return resource.xinerama_placement; }
163   inline bool doXineramaMaximizing(void) const
164     { return resource.xinerama_maximize; }
165   inline bool doXineramaSnapping(void) const
166     { return resource.xinerama_snap; }
167
168   void saveXineramaPlacement(bool x);
169   void saveXineramaMaximizing(bool x);
170   void saveXineramaSnapping(bool x);
171 #endif // XINERAMA
172   
173   void saveSystrayWindowSearch(Window window, BScreen *screen);
174   void saveWindowSearch(Window window, BlackboxWindow *data);
175   void saveGroupSearch(Window window, BWindowGroup *data);
176   void removeSystrayWindowSearch(Window window);
177   void removeWindowSearch(Window window);
178   void removeGroupSearch(Window window);
179
180   inline XAtom *getXAtom(void) { return xatom; }
181
182   inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
183   inline BlackboxWindow *getChangingWindow(void) { return changing_window; }
184
185   inline Configuration *getConfig() { return &config; }
186   inline const Time &getDoubleClickInterval(void) const
187   { return resource.double_click_interval; }
188   inline const Time &getLastTime(void) const { return last_time; }
189
190   inline const char *getStyleFilename(void) const
191     { return resource.style_file.c_str(); }
192
193   inline int getColorsPerChannel(void) const
194     { return resource.colors_per_channel; }
195
196   inline std::string getTitlebarLayout(void) const
197     { return resource.titlebar_layout; }
198
199   inline const timeval &getAutoRaiseDelay(void) const
200     { return resource.auto_raise_delay; }
201
202   inline unsigned long getCacheLife(void) const
203     { return resource.cache_life; }
204   inline unsigned long getCacheMax(void) const
205     { return resource.cache_max; }
206
207   inline void setNoFocus(bool f) { no_focus = f; }
208
209   inline Cursor getSessionCursor(void) const
210     { return cursor.session; }
211   inline Cursor getMoveCursor(void) const
212     { return cursor.move; }
213   inline Cursor getLowerLeftAngleCursor(void) const
214     { return cursor.ll_angle; }
215   inline Cursor getLowerRightAngleCursor(void) const
216     { return cursor.lr_angle; }
217   inline Cursor getUpperLeftAngleCursor(void) const
218     { return cursor.ul_angle; }
219   inline Cursor getUpperRightAngleCursor(void) const
220     { return cursor.ur_angle; }
221   
222   inline unsigned int getMouseModMask(void) const
223     { return resource.mod_mask; }
224
225   void setFocusedWindow(BlackboxWindow *win);
226   void setChangingWindow(BlackboxWindow *win);
227   void shutdown(void);
228   void saveStyleFilename(const std::string& filename);
229   void restart(const char *prog = 0);
230   void reconfigure(void);
231
232   bool validateWindow(Window window);
233
234   virtual bool handleSignal(int sig);
235
236   virtual void timeout(void);
237
238   enum { B_AmericanDate = 1, B_EuropeanDate };
239 };
240
241
242 #endif // __blackbox_hh