diff options
Diffstat (limited to 'src/WinClient.hh')
-rw-r--r-- | src/WinClient.hh | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/src/WinClient.hh b/src/WinClient.hh new file mode 100644 index 0000000..a3fa8d9 --- /dev/null +++ b/src/WinClient.hh | |||
@@ -0,0 +1,203 @@ | |||
1 | // WinClient.hh for Fluxbox - an X11 Window manager | ||
2 | // Copyright (c) 2003 Henrik Kinnunen (fluxgen(at)users.sourceforge.net) | ||
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 | // $Id: WinClient.hh,v 1.16 2003/12/17 01:20:49 fluxgen Exp $ | ||
23 | |||
24 | #ifndef WINCLIENT_HH | ||
25 | #define WINCLIENT_HH | ||
26 | |||
27 | #include "Window.hh" | ||
28 | #include "Subject.hh" | ||
29 | #include "FbWindow.hh" | ||
30 | |||
31 | #include <X11/Xutil.h> | ||
32 | #include <string> | ||
33 | |||
34 | class BScreen; | ||
35 | class Strut; | ||
36 | |||
37 | /// Holds client window info | ||
38 | class WinClient:public FbTk::FbWindow { | ||
39 | public: | ||
40 | typedef std::list<WinClient *> TransientList; | ||
41 | // this structure only contains 3 elements... the Motif 2.0 structure contains | ||
42 | // 5... we only need the first 3... so that is all we will define | ||
43 | typedef struct MwmHints { | ||
44 | unsigned long flags; // Motif wm flags | ||
45 | unsigned long functions; // Motif wm functions | ||
46 | unsigned long decorations; // Motif wm decorations | ||
47 | } MwmHints; | ||
48 | |||
49 | WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin = 0); | ||
50 | |||
51 | ~WinClient(); | ||
52 | |||
53 | void updateRect(int x, int y, unsigned int width, unsigned int height); | ||
54 | |||
55 | bool sendFocus(); // returns whether we sent a message or not | ||
56 | // i.e. whether we assume the focus will get taken | ||
57 | void sendClose(bool forceful = false); | ||
58 | // not aware of anything that makes this false at present | ||
59 | inline bool isClosable() const { return true; } | ||
60 | void reparent(Window win, int x, int y); | ||
61 | |||
62 | void addModal(); // some transient of ours (or us) is modal | ||
63 | void removeModal(); // some transient (or us) is no longer modal | ||
64 | |||
65 | /// updates from wm class hints | ||
66 | void updateWMClassHint(); | ||
67 | void updateWMProtocols(); | ||
68 | |||
69 | |||
70 | void updateTitle(); | ||
71 | void updateIconTitle(); | ||
72 | /// updates transient window information | ||
73 | void updateTransientInfo(); | ||
74 | |||
75 | void updateBlackboxHints(); | ||
76 | void updateMWMHints(); | ||
77 | void updateWMHints(); | ||
78 | void updateWMNormalHints(); | ||
79 | |||
80 | void setStrut(Strut *strut); | ||
81 | void clearStrut(); | ||
82 | |||
83 | bool focus(); // calls Window->setCurrentClient to give focus to this client | ||
84 | |||
85 | /** | ||
86 | * Changes width and height to the nearest (lower) value | ||
87 | * that conforms to it's size hints. | ||
88 | * | ||
89 | * display_* give the values that would be displayed | ||
90 | * to the user when resizing. | ||
91 | * We use pointers for display_* since they are optional. | ||
92 | */ | ||
93 | void applySizeHints(int &width, int &height, int *display_width = 0, int *display_height = 0); | ||
94 | |||
95 | |||
96 | void setGroupLeftWindow(Window win); | ||
97 | |||
98 | void saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs); | ||
99 | |||
100 | // does this client have a pending unmap or destroy event? | ||
101 | bool validateClient() const; | ||
102 | |||
103 | // | ||
104 | // accessors | ||
105 | // | ||
106 | |||
107 | bool getAttrib(XWindowAttributes &attr) const; | ||
108 | bool getWMName(XTextProperty &textprop) const; | ||
109 | bool getWMIconName(XTextProperty &textprop) const; | ||
110 | /// @return name member of class structure | ||
111 | const std::string &getWMClassName() const; | ||
112 | /// @return class member of class structure | ||
113 | const std::string &getWMClassClass() const; | ||
114 | |||
115 | BScreen &screen() { return m_screen; } | ||
116 | const BScreen &screen() const { return m_screen; } | ||
117 | /// notifies when this client dies | ||
118 | FbTk::Subject &dieSig() { return m_diesig; } | ||
119 | |||
120 | inline WinClient *transientFor() { return transient_for; } | ||
121 | inline const WinClient *transientFor() const { return transient_for; } | ||
122 | inline TransientList &transientList() { return transients; } | ||
123 | inline const TransientList &transientList() const { return transients; } | ||
124 | inline bool isTransient() const { return transient_for != 0; } | ||
125 | |||
126 | inline bool isModal() const { return m_modal > 0; } | ||
127 | |||
128 | inline bool operator == (const FluxboxWindow &win) const { | ||
129 | return (m_win == &win); | ||
130 | } | ||
131 | |||
132 | |||
133 | inline const std::string &title() const { return m_title; } | ||
134 | inline const std::string &iconTitle() const { return m_icon_title; } | ||
135 | inline const FluxboxWindow *fbwindow() const { return m_win; } | ||
136 | inline FluxboxWindow *fbwindow() { return m_win; } | ||
137 | inline int gravity() const { return m_win_gravity; } | ||
138 | |||
139 | bool hasGroupLeftWindow() const; | ||
140 | // grouping is tracked by remembering the window to the left in the group | ||
141 | Window getGroupLeftWindow() const; | ||
142 | |||
143 | inline int getFocusMode() const { return m_focus_mode; } | ||
144 | inline const FluxboxWindow::BlackboxHints *getBlackboxHint() const { return m_blackbox_hint; } | ||
145 | inline const MwmHints *getMwmHint() const { return m_mwm_hint; } | ||
146 | |||
147 | |||
148 | static const int PropBlackboxHintsElements = 5; | ||
149 | static const int PropMwmHintsElements = 3; | ||
150 | |||
151 | /** | ||
152 | !! TODO !! | ||
153 | remove or move these to private | ||
154 | */ | ||
155 | |||
156 | WinClient *transient_for; // which window are we a transient for? | ||
157 | std::list<WinClient *> transients; // which windows are our transients? | ||
158 | Window window_group; | ||
159 | |||
160 | |||
161 | int x, y, old_bw; | ||
162 | unsigned int | ||
163 | min_width, min_height, max_width, max_height, width_inc, height_inc, | ||
164 | min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y, | ||
165 | base_width, base_height; | ||
166 | unsigned long initial_state, normal_hint_flags, wm_hint_flags; | ||
167 | |||
168 | |||
169 | FluxboxWindow *m_win; | ||
170 | class WinClientSubj: public FbTk::Subject { | ||
171 | public: | ||
172 | explicit WinClientSubj(WinClient &client):m_winclient(client) { } | ||
173 | WinClient &winClient() { return m_winclient; } | ||
174 | private: | ||
175 | WinClient &m_winclient; | ||
176 | }; | ||
177 | |||
178 | enum FocusMode { F_NOINPUT = 0, F_PASSIVE, F_LOCALLYACTIVE, F_GLOBALLYACTIVE }; | ||
179 | |||
180 | private: | ||
181 | // number of transients which we are modal for | ||
182 | // or indicates that we are modal if don't have any transients | ||
183 | int m_modal; | ||
184 | bool send_focus_message, send_close_message; | ||
185 | |||
186 | int m_win_gravity; | ||
187 | |||
188 | std::string m_title, m_icon_title; | ||
189 | std::string m_class_name, m_instance_name; | ||
190 | |||
191 | FluxboxWindow::BlackboxHints *m_blackbox_hint; | ||
192 | MwmHints *m_mwm_hint; | ||
193 | |||
194 | int m_focus_mode; | ||
195 | |||
196 | WinClientSubj m_diesig; | ||
197 | BScreen &m_screen; | ||
198 | |||
199 | Strut *m_strut; | ||
200 | |||
201 | }; | ||
202 | |||
203 | #endif // WINCLIENT_HH | ||