diff options
Diffstat (limited to 'src/FbWinFrame.hh')
-rw-r--r-- | src/FbWinFrame.hh | 103 |
1 files changed, 10 insertions, 93 deletions
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 55d47ed..4a33fec 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh | |||
@@ -33,6 +33,8 @@ | |||
33 | #include "FbTk/Container.hh" | 33 | #include "FbTk/Container.hh" |
34 | #include "FbTk/Shape.hh" | 34 | #include "FbTk/Shape.hh" |
35 | 35 | ||
36 | #include "WindowState.hh" | ||
37 | |||
36 | #include <X11/Xutil.h> | 38 | #include <X11/Xutil.h> |
37 | 39 | ||
38 | #include <vector> | 40 | #include <vector> |
@@ -68,85 +70,6 @@ public: | |||
68 | RIGHTBOTTOM, RIGHT, RIGHTTOP | 70 | RIGHTBOTTOM, RIGHT, RIGHTTOP |
69 | }; | 71 | }; |
70 | 72 | ||
71 | /** | ||
72 | * Types of maximization | ||
73 | */ | ||
74 | enum MaximizeMode { | ||
75 | MAX_NONE = 0, ///< normal state | ||
76 | MAX_HORZ = 1, ///< maximize horizontal | ||
77 | MAX_VERT = 2, ///< maximize vertical | ||
78 | MAX_FULL = 3 ///< maximize full | ||
79 | }; | ||
80 | |||
81 | /** | ||
82 | This enumeration represents individual decoration | ||
83 | attributes, they can be OR-d together to get a mask. | ||
84 | Useful for saving. | ||
85 | */ | ||
86 | enum DecorationMask { | ||
87 | DECORM_TITLEBAR = (1<<0), | ||
88 | DECORM_HANDLE = (1<<1), | ||
89 | DECORM_BORDER = (1<<2), | ||
90 | DECORM_ICONIFY = (1<<3), | ||
91 | DECORM_MAXIMIZE = (1<<4), | ||
92 | DECORM_CLOSE = (1<<5), | ||
93 | DECORM_MENU = (1<<6), | ||
94 | DECORM_STICKY = (1<<7), | ||
95 | DECORM_SHADE = (1<<8), | ||
96 | DECORM_TAB = (1<<9), | ||
97 | DECORM_ENABLED = (1<<10), | ||
98 | DECORM_LAST = (1<<11) // useful for getting "All" | ||
99 | }; | ||
100 | |||
101 | enum Decoration { | ||
102 | DECOR_NONE = 0, | ||
103 | DECOR_NORMAL = DECORM_LAST - 1, | ||
104 | DECOR_TINY = DECORM_TITLEBAR|DECORM_ICONIFY|DECORM_MENU|DECORM_TAB, | ||
105 | DECOR_TOOL = DECORM_TITLEBAR|DECORM_MENU, | ||
106 | DECOR_BORDER = DECORM_BORDER|DECORM_MENU, | ||
107 | DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB | ||
108 | }; | ||
109 | |||
110 | class SizeHints { | ||
111 | public: | ||
112 | SizeHints(): | ||
113 | min_width(1), max_width(0), min_height(1), max_height(0), | ||
114 | width_inc(1), height_inc(1), base_width(0), base_height(0), | ||
115 | min_aspect_x(0), max_aspect_x(1), | ||
116 | min_aspect_y(1), max_aspect_y(0), | ||
117 | win_gravity(0) { } | ||
118 | |||
119 | void reset(const XSizeHints &sizehint); | ||
120 | |||
121 | void apply(unsigned int &w, unsigned int &h, | ||
122 | bool maximizing = false) const; | ||
123 | bool valid(unsigned int width, unsigned int height) const; | ||
124 | void displaySize(unsigned int &i, unsigned int &j, | ||
125 | unsigned int width, unsigned int height) const; | ||
126 | |||
127 | unsigned int min_width, max_width, min_height, max_height, | ||
128 | width_inc, height_inc, base_width, base_height, | ||
129 | min_aspect_x, max_aspect_x, min_aspect_y, max_aspect_y; | ||
130 | int win_gravity; | ||
131 | }; | ||
132 | |||
133 | class State { | ||
134 | public: | ||
135 | State(): | ||
136 | size_hints(), | ||
137 | deco_mask(DECOR_NORMAL), | ||
138 | focused(false), | ||
139 | shaded(false), fullscreen(false), maximized(0), | ||
140 | x(0), y(0), width(1), height(1) { } | ||
141 | |||
142 | SizeHints size_hints; | ||
143 | unsigned int deco_mask; | ||
144 | bool focused, shaded, fullscreen; | ||
145 | int maximized; | ||
146 | int x, y; | ||
147 | unsigned int width, height; | ||
148 | }; | ||
149 | |||
150 | /// create a top level window | 73 | /// create a top level window |
151 | FbWinFrame(BScreen &screen, FocusableTheme<FbWinFrameTheme> &theme, | 74 | FbWinFrame(BScreen &screen, FocusableTheme<FbWinFrameTheme> &theme, |
152 | FbTk::ImageControl &imgctrl, | 75 | FbTk::ImageControl &imgctrl, |
@@ -247,18 +170,9 @@ public: | |||
247 | bool maximizing = false) const; | 170 | bool maximizing = false) const; |
248 | void displaySize(unsigned int width, unsigned int height) const; | 171 | void displaySize(unsigned int width, unsigned int height) const; |
249 | 172 | ||
250 | static int getDecoMaskFromString(const std::string &str); | ||
251 | void setDecorationMask(unsigned int mask) { m_state.deco_mask = mask; } | 173 | void setDecorationMask(unsigned int mask) { m_state.deco_mask = mask; } |
252 | void applyDecorations(); | 174 | void applyDecorations(); |
253 | void applyState(); | 175 | void applyState(); |
254 | void saveGeometry(); | ||
255 | |||
256 | /// determine if the given decoration should be shown in current state | ||
257 | bool useBorder() const; | ||
258 | bool useTabs() const; | ||
259 | bool useTitlebar() const; | ||
260 | bool useHandle() const; | ||
261 | int getShape() const; | ||
262 | 176 | ||
263 | // this function translates its arguments according to win_gravity | 177 | // this function translates its arguments according to win_gravity |
264 | // if win_gravity is negative, it does an inverse translation | 178 | // if win_gravity is negative, it does an inverse translation |
@@ -287,10 +201,10 @@ public: | |||
287 | unsigned int width() const { return m_window.width(); } | 201 | unsigned int width() const { return m_window.width(); } |
288 | unsigned int height() const { return m_window.height(); } | 202 | unsigned int height() const { return m_window.height(); } |
289 | 203 | ||
290 | int normalX() const; | 204 | int normalX() const { return m_state.x; } |
291 | int normalY() const; | 205 | int normalY() const { return m_state.y; } |
292 | unsigned int normalWidth() const; | 206 | unsigned int normalWidth() const { return m_state.width; } |
293 | unsigned int normalHeight() const; | 207 | unsigned int normalHeight() const { return m_state.height; } |
294 | 208 | ||
295 | // extra bits for tabs | 209 | // extra bits for tabs |
296 | int xOffset() const; | 210 | int xOffset() const; |
@@ -368,6 +282,9 @@ private: | |||
368 | bool showHandle(); | 282 | bool showHandle(); |
369 | bool setBorderWidth(bool do_move = true); | 283 | bool setBorderWidth(bool do_move = true); |
370 | 284 | ||
285 | // check which corners should be rounded | ||
286 | int getShape() const; | ||
287 | |||
371 | /** | 288 | /** |
372 | @name apply pixmaps depending on focus | 289 | @name apply pixmaps depending on focus |
373 | */ | 290 | */ |
@@ -463,7 +380,7 @@ private: | |||
463 | TabMode m_tabmode; | 380 | TabMode m_tabmode; |
464 | 381 | ||
465 | unsigned int m_active_orig_client_bw; | 382 | unsigned int m_active_orig_client_bw; |
466 | State m_state; | 383 | WindowState m_state; |
467 | 384 | ||
468 | bool m_need_render; | 385 | bool m_need_render; |
469 | int m_button_size; ///< size for all titlebar buttons | 386 | int m_button_size; ///< size for all titlebar buttons |