aboutsummaryrefslogtreecommitdiff
path: root/src/Slit.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Slit.hh')
-rw-r--r--src/Slit.hh263
1 files changed, 159 insertions, 104 deletions
diff --git a/src/Slit.hh b/src/Slit.hh
index cce1d97..b5135d8 100644
--- a/src/Slit.hh
+++ b/src/Slit.hh
@@ -1,3 +1,6 @@
1// Slit.hh for Fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
1// Slit.hh for Blackbox - an X11 Window manager 4// Slit.hh for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 6//
@@ -18,9 +21,9 @@
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
21 24
22#ifndef _SLIT_HH_ 25#ifndef SLIT_HH
23#define _SLIT_HH_ 26#define SLIT_HH
24 27
25#include <X11/Xlib.h> 28#include <X11/Xlib.h>
26#include <X11/Xutil.h> 29#include <X11/Xutil.h>
@@ -30,130 +33,182 @@ class Slit;
30class Slitmenu; 33class Slitmenu;
31 34
32#include "Basemenu.hh" 35#include "Basemenu.hh"
33#include "LinkedList.hh"
34 36
37#include <list>
38#include <string>
35 39
36class Slitmenu : public Basemenu { 40class Slitmenu : public Basemenu {
37private: 41public:
38 class Directionmenu : public Basemenu { 42 explicit Slitmenu(Slit &theslist);
39 private: 43 virtual ~Slitmenu();
40 Slitmenu *slitmenu;
41 44
42 protected: 45 inline Basemenu *getDirectionmenu() { return directionmenu; }
43 virtual void itemSelected(int, int); 46 inline Basemenu *getPlacementmenu() { return placementmenu; }
47#ifdef XINERAMA
48 inline Basemenu *getHeadmenu() { return headmenu; }
49#endif // XINERAMA
44 50
45 public: 51 void reconfigure();
46 Directionmenu(Slitmenu *);
47 };
48 52
49 class Placementmenu : public Basemenu { 53private:
50 private: 54 class Directionmenu : public Basemenu {
51 Slitmenu *slitmenu; 55 private:
56 Slitmenu *slitmenu;
52 57
53 protected: 58 protected:
54 virtual void itemSelected(int, int); 59 virtual void itemSelected(int button, unsigned int index);
55 60
56 public: 61 public:
57 Placementmenu(Slitmenu *); 62 Directionmenu(Slitmenu *);
58 }; 63 };
59 64
60 Directionmenu *directionmenu; 65 class Placementmenu : public Basemenu {
61 Placementmenu *placementmenu; 66 private:
67 Slitmenu *slitmenu;
62 68
63 Slit *slit; 69 protected:
70 virtual void itemSelected(int button, unsigned int index);
64 71
65 friend class Directionmenu; 72 public:
66 friend class Placementmenu; 73 Placementmenu(Slitmenu *);
67 friend class Slit; 74 };
68 75
76#ifdef XINERAMA
77 class Headmenu : public Basemenu {
78 public:
79 Headmenu(Slitmenu *);
80 private:
81 Slitmenu *slitmenu;
69 82
70protected: 83 protected:
71 virtual void itemSelected(int, int); 84 virtual void itemSelected(int button, unsigned int index);
72 virtual void internal_hide(void);
73 85
86 };
87#endif // XINERAMA
74 88
75public: 89 Directionmenu *directionmenu;
76 Slitmenu(Slit *); 90 Placementmenu *placementmenu;
77 virtual ~Slitmenu(void); 91#ifdef XINERAMA
92 Headmenu *headmenu;
93#endif // XINERAMA
94 Slit &slit;
95
96 friend class Directionmenu;
97 friend class Placementmenu;
98#ifdef XINERAMA
99 friend class Headmenu;
100#endif // XINERAMA
101 friend class Slit;
78 102
79 inline Basemenu *getDirectionmenu(void) { return directionmenu; }
80 inline Basemenu *getPlacementmenu(void) { return placementmenu; }
81 103
82 void reconfigure(void); 104protected:
105 virtual void itemSelected(int button, unsigned int index);
106 virtual void internal_hide();
83}; 107};
84 108
85 109
86class Slit : public TimeoutHandler { 110class Slit : public TimeoutHandler {
87private:
88 class SlitClient {
89 public:
90 Window window, client_window, icon_window;
91
92 int x, y;
93 unsigned int width, height;
94 };
95
96 Bool on_top, hidden, do_auto_hide;
97 Display *display;
98
99 Fluxbox *fluxbox;
100 BScreen *screen;
101 BTimer *timer;
102
103 LinkedList<SlitClient> *clientList;
104 Slitmenu *slitmenu;
105
106 struct frame {
107 Pixmap pixmap;
108 Window window;
109
110 int x, y, x_hidden, y_hidden;
111 unsigned int width, height;
112 } frame;
113
114 friend class Slitmenu;
115 friend class Slitmenu::Directionmenu;
116 friend class Slitmenu::Placementmenu;
117
118
119public: 111public:
120 Slit(BScreen *); 112 explicit Slit(BScreen *screen);
121 virtual ~Slit(); 113 virtual ~Slit();
122 114
123 inline const Bool &isOnTop(void) const { return on_top; } 115 inline bool isOnTop() const { return on_top; }
124 inline const Bool &isHidden(void) const { return hidden; } 116 inline bool isHidden() const { return hidden; }
125 inline const Bool &doAutoHide(void) const { return do_auto_hide; } 117 inline bool doAutoHide() const { return do_auto_hide; }
126 118
127 inline Slitmenu *getMenu() { return slitmenu; } 119 Slitmenu &menu() { return slitmenu; }
128 120
129 inline const Window &getWindowID() const { return frame.window; } 121 inline const Window &getWindowID() const { return frame.window; }
122
123 inline int x() const { return ((hidden) ? frame.x_hidden : frame.x); }
124 inline int y() const { return ((hidden) ? frame.y_hidden : frame.y); }
125
126 inline unsigned int width() const { return frame.width; }
127 inline unsigned int height() const { return frame.height; }
128
129 void addClient(Window clientwin);
130 void removeClient(Window clientwin, bool = true);
131 void reconfigure();
132 void reposition();
133 void shutdown();
134 void saveClientList();
135
136 /**
137 @name eventhandlers
138 */
139 //@{
140 void buttonPressEvent(XButtonEvent *bp);
141 void enterNotifyEvent(XCrossingEvent *en);
142 void leaveNotifyEvent(XCrossingEvent *ln);
143 void configureRequestEvent(XConfigureRequestEvent *cr);
144 //@}
145
146 virtual void timeout();
147
148 /**
149 Client alignment
150 */
151 enum { VERTICAL = 1, HORIZONTAL };
152 /**
153 Screen placement
154 */
155 enum { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER,
156 TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT };
130 157
131 inline const int &getX(void) const 158private:
132 { return ((hidden) ? frame.x_hidden : frame.x); } 159 class SlitClient {
133 inline const int &getY(void) const 160 public:
134 { return ((hidden) ? frame.y_hidden : frame.y); } 161 SlitClient(BScreen *screen, Window client_window); // For adding an actual window
135 162 SlitClient(const char *name); // For adding a placeholder
136 inline const unsigned int &getWidth(void) const { return frame.width; } 163
137 inline const unsigned int &getHeight(void) const { return frame.height; } 164 // Now we pre-initialize a list of slit clients with names for
138 165 // comparison with incoming client windows. This allows the slit
139 void addClient(Window); 166 // to maintain a sorted order based on a saved window name list.
140 void removeClient(SlitClient *, Bool = True); 167 // Incoming windows not found in the list are appended. Matching
141 void removeClient(Window, Bool = True); 168 // duplicates are inserted after the last found instance of the
142 void reconfigure(void); 169 // matching name.
143 void reposition(void); 170 std::string match_name;
144 void shutdown(void); 171
145 172 Window window, client_window, icon_window;
146 void buttonPressEvent(XButtonEvent *); 173
147 void enterNotifyEvent(XCrossingEvent *); 174 int x, y;
148 void leaveNotifyEvent(XCrossingEvent *); 175 unsigned int width, height;
149 void configureRequestEvent(XConfigureRequestEvent *); 176
150 177 void initialize(BScreen *screen = 0, Window client_window= None);
151 virtual void timeout(void); 178 };
152 179
153 enum { Vertical = 1, Horizontal }; 180 void removeClient(SlitClient *client, bool remap, bool destroy);
154 enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter, 181 void loadClientList();
155 TopRight, CenterRight, BottomRight }; 182
183 bool on_top, hidden, do_auto_hide;
184
185 Display *display; ///< display connection
186
187 Fluxbox *fluxbox; ///< obsolete
188 BScreen *screen;
189 BTimer timer;
190
191 typedef std::list<SlitClient *> SlitClients;
192
193 SlitClients clientList;
194 Slitmenu slitmenu;
195 std::string clientListPath;
196
197 struct frame {
198 Pixmap pixmap;
199 Window window;
200
201 int x, y, x_hidden, y_hidden;
202 unsigned int width, height;
203 } frame;
204
205 friend class Slitmenu;
206 friend class Slitmenu::Directionmenu;
207 friend class Slitmenu::Placementmenu;
208 #ifdef XINERAMA
209 friend class Slitmenu::Headmenu;
210 #endif // XINERAMA
156}; 211};
157 212
158 213
159#endif // __Slit_hh 214#endif // SLIT_HH