]> Dogcows Code - chaz/openbox/blob - src/Slit.hh
had an extra window placement menu
[chaz/openbox] / src / Slit.hh
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Slit.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 __Slit_hh
25 #define __Slit_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29 #include <X11/Xutil.h>
30 }
31
32 #include <list>
33 #include <string>
34
35 #include "Screen.hh"
36 #include "Basemenu.hh"
37
38 // forward declaration
39 class Slit;
40 class Slitmenu;
41
42 class Slitmenu : public Basemenu {
43 private:
44 class Directionmenu : public Basemenu {
45 private:
46 Directionmenu(const Directionmenu&);
47 Directionmenu& operator=(const Directionmenu&);
48 Slit *slit;
49
50 protected:
51 virtual void itemSelected(int button, unsigned int index);
52 virtual void setValues(void);
53
54 public:
55 Directionmenu(Slitmenu *sm);
56 virtual void reconfigure(void);
57 };
58
59 class Placementmenu : public Basemenu {
60 private:
61 Placementmenu(const Placementmenu&);
62 Placementmenu& operator=(const Placementmenu&);
63 Slit *slit;
64
65 protected:
66 virtual void itemSelected(int buton, unsigned int index);
67 virtual void setValues(void);
68
69 public:
70 Placementmenu(Slitmenu *sm);
71 virtual void reconfigure(void);
72 };
73
74 Directionmenu *directionmenu;
75 Placementmenu *placementmenu;
76
77 Slit *slit;
78
79 friend class Directionmenu;
80 friend class Placementmenu;
81 friend class Slit;
82
83 Slitmenu(const Slitmenu&);
84 Slitmenu& operator=(const Slitmenu&);
85
86 protected:
87 virtual void itemSelected(int button, unsigned int index);
88 virtual void internal_hide(void);
89
90 public:
91 Slitmenu(Slit *sl);
92 virtual ~Slitmenu(void);
93
94 inline Basemenu *getDirectionmenu(void) { return directionmenu; }
95 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
96
97 void reconfigure(void);
98 };
99
100
101 class Slit : public TimeoutHandler {
102 public:
103 struct SlitClient {
104 Window window, client_window, icon_window;
105
106 Rect rect;
107 };
108
109 private:
110 typedef std::list<SlitClient*> SlitClientList;
111
112 bool on_top, hidden, do_auto_hide;
113 int direction, placement;
114 std::string slitstr;
115 Display *display;
116
117 Blackbox *blackbox;
118 BScreen *screen;
119 Configuration *config;
120 BTimer *timer;
121 Strut strut;
122
123 SlitClientList clientList;
124 Slitmenu *slitmenu;
125
126 struct SlitFrame {
127 Pixmap pixmap;
128 Window window;
129
130 int x_hidden, y_hidden;
131 Rect rect;
132 } frame;
133
134 void updateStrut(void);
135
136 friend class Slitmenu;
137 friend class Slitmenu::Directionmenu;
138 friend class Slitmenu::Placementmenu;
139
140 Slit(const Slit&);
141 Slit& operator=(const Slit&);
142
143 public:
144 Slit(BScreen *scr);
145 virtual ~Slit(void);
146
147 inline bool isOnTop(void) const { return on_top; }
148 inline bool isHidden(void) const { return hidden; }
149 inline bool doAutoHide(void) const { return do_auto_hide; }
150 inline int getPlacement(void) const { return placement; }
151 inline int getDirection(void) const { return direction; }
152
153 void saveOnTop(bool);
154 void saveAutoHide(bool);
155 void savePlacement(int);
156 void saveDirection(int);
157
158 inline Slitmenu *getMenu(void) { return slitmenu; }
159
160 inline Window getWindowID(void) const { return frame.window; }
161
162 inline int getX(void) const
163 { return ((hidden) ? frame.x_hidden : frame.rect.x()); }
164 inline int getY(void) const
165 { return ((hidden) ? frame.y_hidden : frame.rect.y()); }
166
167 inline unsigned int getWidth(void) const { return frame.rect.width(); }
168 inline unsigned int getExposedWidth(void) const {
169 if (direction == Vertical && do_auto_hide)
170 return screen->getBevelWidth();
171 return frame.rect.width();
172 }
173 inline unsigned int getHeight(void) const { return frame.rect.height(); }
174 inline unsigned int getExposedHeight(void) const {
175 if (direction == Horizontal && do_auto_hide)
176 return screen->getBevelWidth();
177 return frame.rect.height();
178 }
179
180 void addClient(Window w);
181 void removeClient(SlitClient *client, bool remap = True);
182 void removeClient(Window w, bool remap = True);
183 void load_rc(void);
184 void save_rc(void);
185 void reconfigure(void);
186 void updateSlit(void);
187 void reposition(void);
188 void shutdown(void);
189 void toggleAutoHide(void);
190
191 void buttonPressEvent(const XButtonEvent *e);
192 void enterNotifyEvent(const XCrossingEvent * /*unused*/);
193 void leaveNotifyEvent(const XCrossingEvent * /*unused*/);
194 void configureRequestEvent(const XConfigureRequestEvent *e);
195 void unmapNotifyEvent(const XUnmapEvent *e);
196
197 virtual void timeout(void);
198
199 enum { Vertical = 1, Horizontal };
200 enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter,
201 TopRight, CenterRight, BottomRight };
202 };
203
204
205 #endif // __Slit_hh
This page took 0.041851 seconds and 4 git commands to generate.