diff options
Diffstat (limited to 'src/WindowState.hh')
-rw-r--r-- | src/WindowState.hh | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/WindowState.hh b/src/WindowState.hh new file mode 100644 index 0000000..fa17eb6 --- /dev/null +++ b/src/WindowState.hh | |||
@@ -0,0 +1,118 @@ | |||
1 | // WindowState.hh | ||
2 | // Copyright (c) 2008 Fluxbox Team (fluxgen at fluxbox dot org) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // 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 | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | #ifndef WINDOWSTATE_HH | ||
23 | #define WINDOWSTATE_HH | ||
24 | |||
25 | #include <X11/Xutil.h> | ||
26 | |||
27 | #include <string> | ||
28 | |||
29 | class SizeHints { | ||
30 | public: | ||
31 | SizeHints(): | ||
32 | min_width(1), max_width(0), min_height(1), max_height(0), | ||
33 | width_inc(1), height_inc(1), base_width(0), base_height(0), | ||
34 | min_aspect_x(0), max_aspect_x(1), | ||
35 | min_aspect_y(1), max_aspect_y(0), | ||
36 | win_gravity(0) { } | ||
37 | |||
38 | void reset(const XSizeHints &sizehint); | ||
39 | |||
40 | void apply(unsigned int &w, unsigned int &h, | ||
41 | bool maximizing = false) const; | ||
42 | bool valid(unsigned int width, unsigned int height) const; | ||
43 | void displaySize(unsigned int &i, unsigned int &j, | ||
44 | unsigned int width, unsigned int height) const; | ||
45 | |||
46 | unsigned int min_width, max_width, min_height, max_height, | ||
47 | width_inc, height_inc, base_width, base_height, | ||
48 | min_aspect_x, max_aspect_x, min_aspect_y, max_aspect_y; | ||
49 | int win_gravity; | ||
50 | }; | ||
51 | |||
52 | class WindowState { | ||
53 | public: | ||
54 | |||
55 | /** | ||
56 | * Types of maximization | ||
57 | */ | ||
58 | enum MaximizeMode { | ||
59 | MAX_NONE = 0, ///< normal state | ||
60 | MAX_HORZ = 1, ///< maximize horizontal | ||
61 | MAX_VERT = 2, ///< maximize vertical | ||
62 | MAX_FULL = 3 ///< maximize full | ||
63 | }; | ||
64 | |||
65 | /** | ||
66 | This enumeration represents individual decoration | ||
67 | attributes, they can be OR-d together to get a mask. | ||
68 | Useful for saving. | ||
69 | */ | ||
70 | enum DecorationMask { | ||
71 | DECORM_TITLEBAR = (1<<0), | ||
72 | DECORM_HANDLE = (1<<1), | ||
73 | DECORM_BORDER = (1<<2), | ||
74 | DECORM_ICONIFY = (1<<3), | ||
75 | DECORM_MAXIMIZE = (1<<4), | ||
76 | DECORM_CLOSE = (1<<5), | ||
77 | DECORM_MENU = (1<<6), | ||
78 | DECORM_STICKY = (1<<7), | ||
79 | DECORM_SHADE = (1<<8), | ||
80 | DECORM_TAB = (1<<9), | ||
81 | DECORM_ENABLED = (1<<10), | ||
82 | DECORM_LAST = (1<<11) // useful for getting "All" | ||
83 | }; | ||
84 | |||
85 | enum Decoration { | ||
86 | DECOR_NONE = 0, | ||
87 | DECOR_NORMAL = DECORM_LAST - 1, | ||
88 | DECOR_TINY = DECORM_TITLEBAR|DECORM_ICONIFY|DECORM_MENU|DECORM_TAB, | ||
89 | DECOR_TOOL = DECORM_TITLEBAR|DECORM_MENU, | ||
90 | DECOR_BORDER = DECORM_BORDER|DECORM_MENU, | ||
91 | DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB | ||
92 | }; | ||
93 | |||
94 | WindowState(): | ||
95 | size_hints(), | ||
96 | deco_mask(DECOR_NORMAL), | ||
97 | focused(false), | ||
98 | shaded(false), fullscreen(false), maximized(0), | ||
99 | x(0), y(0), width(1), height(1) { } | ||
100 | |||
101 | void saveGeometry(int x, int y, unsigned int width, unsigned int height); | ||
102 | |||
103 | bool useBorder() const; | ||
104 | bool useHandle() const; | ||
105 | bool useTabs() const; | ||
106 | bool useTitlebar() const; | ||
107 | |||
108 | static int getDecoMaskFromString(const std::string &str); | ||
109 | |||
110 | SizeHints size_hints; | ||
111 | unsigned int deco_mask; | ||
112 | bool focused, shaded, fullscreen; | ||
113 | int maximized; | ||
114 | int x, y; | ||
115 | unsigned int width, height; | ||
116 | }; | ||
117 | |||
118 | #endif // WINDOWSTATE_HH | ||