diff options
Diffstat (limited to 'src/Slit.hh')
-rw-r--r-- | src/Slit.hh | 233 |
1 files changed, 138 insertions, 95 deletions
diff --git a/src/Slit.hh b/src/Slit.hh index cce1d97..61a7d33 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,129 +33,169 @@ class Slit; | |||
30 | class Slitmenu; | 33 | class 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 | ||
36 | class Slitmenu : public Basemenu { | 40 | class Slitmenu : public Basemenu { |
37 | private: | 41 | public: |
38 | class Directionmenu : public Basemenu { | 42 | explicit Slitmenu(Slit &theslist); |
39 | private: | 43 | virtual ~Slitmenu(void); |
40 | Slitmenu *slitmenu; | ||
41 | 44 | ||
42 | protected: | 45 | inline Basemenu *getDirectionmenu(void) { return directionmenu; } |
43 | virtual void itemSelected(int, int); | 46 | inline Basemenu *getPlacementmenu(void) { return placementmenu; } |
47 | #ifdef XINERAMA | ||
48 | inline Basemenu *getHeadmenu(void) { return headmenu; } | ||
49 | #endif // XINERAMA | ||
44 | 50 | ||
45 | public: | 51 | void reconfigure(void); |
46 | Directionmenu(Slitmenu *); | ||
47 | }; | ||
48 | 52 | ||
49 | class Placementmenu : public Basemenu { | 53 | private: |
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 | ||
70 | protected: | 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 | ||
75 | public: | 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); | 104 | protected: |
105 | virtual void itemSelected(int button, unsigned int index); | ||
106 | virtual void internal_hide(void); | ||
83 | }; | 107 | }; |
84 | 108 | ||
85 | 109 | ||
86 | class Slit : public TimeoutHandler { | 110 | class Slit : public TimeoutHandler { |
87 | private: | ||
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 | |||
119 | public: | 111 | public: |
120 | Slit(BScreen *); | 112 | explicit Slit(BScreen *); |
121 | virtual ~Slit(); | 113 | virtual ~Slit(); |
122 | 114 | ||
123 | inline const Bool &isOnTop(void) const { return on_top; } | 115 | inline bool isOnTop(void) const { return on_top; } |
124 | inline const Bool &isHidden(void) const { return hidden; } | 116 | inline bool isHidden(void) const { return hidden; } |
125 | inline const Bool &doAutoHide(void) const { return do_auto_hide; } | 117 | inline bool doAutoHide(void) const { return do_auto_hide; } |
126 | 118 | ||
127 | inline Slitmenu *getMenu() { return slitmenu; } | 119 | Slitmenu &getMenu() { return slitmenu; } |
128 | 120 | ||
129 | inline const Window &getWindowID() const { return frame.window; } | 121 | inline const Window &getWindowID() const { return frame.window; } |
130 | 122 | ||
131 | inline const int &getX(void) const | 123 | inline int getX() const { return ((hidden) ? frame.x_hidden : frame.x); } |
132 | { return ((hidden) ? frame.x_hidden : frame.x); } | 124 | inline int getY() const { return ((hidden) ? frame.y_hidden : frame.y); } |
133 | inline const int &getY(void) const | ||
134 | { return ((hidden) ? frame.y_hidden : frame.y); } | ||
135 | 125 | ||
136 | inline const unsigned int &getWidth(void) const { return frame.width; } | 126 | inline unsigned int getWidth(void) const { return frame.width; } |
137 | inline const unsigned int &getHeight(void) const { return frame.height; } | 127 | inline unsigned int getHeight(void) const { return frame.height; } |
138 | 128 | ||
139 | void addClient(Window); | 129 | void addClient(Window); |
140 | void removeClient(SlitClient *, Bool = True); | 130 | void removeClient(Window, bool = true); |
141 | void removeClient(Window, Bool = True); | 131 | void reconfigure(void); |
142 | void reconfigure(void); | 132 | void reposition(void); |
143 | void reposition(void); | 133 | void shutdown(void); |
144 | void shutdown(void); | 134 | void saveClientList(void); |
145 | 135 | ||
146 | void buttonPressEvent(XButtonEvent *); | 136 | void buttonPressEvent(XButtonEvent *); |
147 | void enterNotifyEvent(XCrossingEvent *); | 137 | void enterNotifyEvent(XCrossingEvent *); |
148 | void leaveNotifyEvent(XCrossingEvent *); | 138 | void leaveNotifyEvent(XCrossingEvent *); |
149 | void configureRequestEvent(XConfigureRequestEvent *); | 139 | void configureRequestEvent(XConfigureRequestEvent *); |
150 | 140 | ||
151 | virtual void timeout(void); | 141 | virtual void timeout(void); |
152 | 142 | ||
153 | enum { Vertical = 1, Horizontal }; | 143 | enum { VERTICAL = 1, HORIZONTAL }; |
154 | enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter, | 144 | enum { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER, |
155 | TopRight, CenterRight, BottomRight }; | 145 | TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT }; |
146 | |||
147 | private: | ||
148 | class SlitClient { | ||
149 | public: | ||
150 | SlitClient(BScreen *, Window); // For adding an actual window | ||
151 | SlitClient(const char *); // For adding a placeholder | ||
152 | |||
153 | // Now we pre-initialize a list of slit clients with names for | ||
154 | // comparison with incoming client windows. This allows the slit | ||
155 | // to maintain a sorted order based on a saved window name list. | ||
156 | // Incoming windows not found in the list are appended. Matching | ||
157 | // duplicates are inserted after the last found instance of the | ||
158 | // matching name. | ||
159 | std::string match_name; | ||
160 | |||
161 | Window window, client_window, icon_window; | ||
162 | |||
163 | int x, y; | ||
164 | unsigned int width, height; | ||
165 | |||
166 | void initialize(BScreen * = NULL, Window = None); | ||
167 | }; | ||
168 | |||
169 | void removeClient(SlitClient *, bool, bool); | ||
170 | void loadClientList(void); | ||
171 | |||
172 | Bool on_top, hidden, do_auto_hide; | ||
173 | Display *display; | ||
174 | |||
175 | Fluxbox *fluxbox; | ||
176 | BScreen *screen; | ||
177 | BTimer timer; | ||
178 | |||
179 | typedef std::list<SlitClient *> SlitClients; | ||
180 | |||
181 | SlitClients clientList; | ||
182 | Slitmenu slitmenu; | ||
183 | std::string clientListPath; | ||
184 | |||
185 | struct frame { | ||
186 | Pixmap pixmap; | ||
187 | Window window; | ||
188 | |||
189 | int x, y, x_hidden, y_hidden; | ||
190 | unsigned int width, height; | ||
191 | } frame; | ||
192 | |||
193 | friend class Slitmenu; | ||
194 | friend class Slitmenu::Directionmenu; | ||
195 | friend class Slitmenu::Placementmenu; | ||
196 | #ifdef XINERAMA | ||
197 | friend class Slitmenu::Headmenu; | ||
198 | #endif // XINERAMA | ||
156 | }; | 199 | }; |
157 | 200 | ||
158 | 201 | ||