diff options
author | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
commit | 28b5c604490094e187494dcc566bd3d7a05a2c25 (patch) | |
tree | 8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/Workspace.cc | |
parent | b9134162f9633784d9097df18769a699a62650fe (diff) | |
download | fluxbox_pavel-28b5c604490094e187494dcc566bd3d7a05a2c25.zip fluxbox_pavel-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2 |
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/Workspace.cc')
-rw-r--r-- | src/Workspace.cc | 1260 |
1 files changed, 630 insertions, 630 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc index 5d96e7c..4cc098f 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // 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 |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Workspace.cc,v 1.36 2002/11/15 12:17:44 fluxgen Exp $ | 25 | // $Id: Workspace.cc,v 1.37 2002/12/01 13:42:05 rathnor Exp $ |
26 | 26 | ||
27 | #include "Workspace.hh" | 27 | #include "Workspace.hh" |
28 | 28 | ||
@@ -58,16 +58,16 @@ using namespace std; | |||
58 | namespace { // anonymous | 58 | namespace { // anonymous |
59 | 59 | ||
60 | int countTransients(const FluxboxWindow &win) { | 60 | int countTransients(const FluxboxWindow &win) { |
61 | if (win.getTransients().size() == 0) | 61 | if (win.getTransients().size() == 0) |
62 | return 0; | 62 | return 0; |
63 | // now go throu the entire tree and count transients | 63 | // now go throu the entire tree and count transients |
64 | size_t ret = win.getTransients().size(); | 64 | size_t ret = win.getTransients().size(); |
65 | std::list<FluxboxWindow *>::const_iterator it = win.getTransients().begin(); | 65 | std::list<FluxboxWindow *>::const_iterator it = win.getTransients().begin(); |
66 | std::list<FluxboxWindow *>::const_iterator it_end = win.getTransients().end(); | 66 | std::list<FluxboxWindow *>::const_iterator it_end = win.getTransients().end(); |
67 | for (; it != it_end; ++it) | 67 | for (; it != it_end; ++it) |
68 | ret += countTransients(*(*it)); | 68 | ret += countTransients(*(*it)); |
69 | 69 | ||
70 | return ret; | 70 | return ret; |
71 | } | 71 | } |
72 | 72 | ||
73 | }; | 73 | }; |
@@ -75,14 +75,14 @@ int countTransients(const FluxboxWindow &win) { | |||
75 | Workspace::GroupList Workspace::m_groups; | 75 | Workspace::GroupList Workspace::m_groups; |
76 | 76 | ||
77 | Workspace::Workspace(BScreen *scrn, unsigned int i): | 77 | Workspace::Workspace(BScreen *scrn, unsigned int i): |
78 | screen(scrn), | 78 | screen(scrn), |
79 | lastfocus(0), | 79 | lastfocus(0), |
80 | m_clientmenu(*this), | 80 | m_clientmenu(*this), |
81 | m_name(""), | 81 | m_name(""), |
82 | m_id(i), | 82 | m_id(i), |
83 | cascade_x(32), cascade_y(32) { | 83 | cascade_x(32), cascade_y(32) { |
84 | 84 | ||
85 | setName(screen->getNameOfWorkspace(m_id)); | 85 | setName(screen->getNameOfWorkspace(m_id)); |
86 | 86 | ||
87 | } | 87 | } |
88 | 88 | ||
@@ -92,258 +92,258 @@ Workspace::~Workspace() { | |||
92 | } | 92 | } |
93 | 93 | ||
94 | void Workspace::setLastFocusedWindow(FluxboxWindow *win) { | 94 | void Workspace::setLastFocusedWindow(FluxboxWindow *win) { |
95 | // make sure we have this window in the list | 95 | // make sure we have this window in the list |
96 | if (std::find(m_windowlist.begin(), m_windowlist.end(), win) != m_windowlist.end()) | 96 | if (std::find(m_windowlist.begin(), m_windowlist.end(), win) != m_windowlist.end()) |
97 | lastfocus = win; | 97 | lastfocus = win; |
98 | else | 98 | else |
99 | lastfocus = 0; | 99 | lastfocus = 0; |
100 | } | 100 | } |
101 | 101 | ||
102 | int Workspace::addWindow(FluxboxWindow *w, bool place) { | 102 | int Workspace::addWindow(FluxboxWindow *w, bool place) { |
103 | if (w == 0) | 103 | if (w == 0) |
104 | return -1; | 104 | return -1; |
105 | 105 | ||
106 | if (place) | 106 | if (place) |
107 | placeWindow(w); | 107 | placeWindow(w); |
108 | 108 | ||
109 | w->setWorkspace(m_id); | 109 | w->setWorkspace(m_id); |
110 | w->setWindowNumber(m_windowlist.size()); | 110 | w->setWindowNumber(m_windowlist.size()); |
111 | 111 | ||
112 | stackingList.push_front(w); | 112 | stackingList.push_front(w); |
113 | 113 | ||
114 | //insert window after the currently focused window | 114 | //insert window after the currently focused window |
115 | //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); | 115 | //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); |
116 | 116 | ||
117 | //if there isn't any window that's focused, just add it to the end of the list | 117 | //if there isn't any window that's focused, just add it to the end of the list |
118 | /* | 118 | /* |
119 | if (focused == 0) { | 119 | if (focused == 0) { |
120 | m_windowlist.push_back(w); | 120 | m_windowlist.push_back(w); |
121 | //Add client to clientmenu | 121 | //Add client to clientmenu |
122 | m_clientmenu.insert(w->getTitle().c_str()); | 122 | m_clientmenu.insert(w->getTitle().c_str()); |
123 | } else { | 123 | } else { |
124 | Windows::iterator it = m_windowlist.begin(); | 124 | Windows::iterator it = m_windowlist.begin(); |
125 | size_t client_insertpoint=0; | 125 | size_t client_insertpoint=0; |
126 | for (; it != m_windowlist.end(); ++it, ++client_insertpoint) { | 126 | for (; it != m_windowlist.end(); ++it, ++client_insertpoint) { |
127 | if (*it == focused) { | 127 | if (*it == focused) { |
128 | ++it; | 128 | ++it; |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | m_windowlist.insert(it, w); | 133 | m_windowlist.insert(it, w); |
134 | //Add client to clientmenu | 134 | //Add client to clientmenu |
135 | m_clientmenu.insert(w->getTitle().c_str(), client_insertpoint); | 135 | m_clientmenu.insert(w->getTitle().c_str(), client_insertpoint); |
136 | 136 | ||
137 | 137 | ||
138 | } | 138 | } |
139 | */ | 139 | */ |
140 | //add to list | 140 | //add to list |
141 | m_clientmenu.insert(w->getTitle().c_str()); | 141 | m_clientmenu.insert(w->getTitle().c_str()); |
142 | m_windowlist.push_back(w); | 142 | m_windowlist.push_back(w); |
143 | 143 | ||
144 | //update menugraphics | 144 | //update menugraphics |
145 | m_clientmenu.update(); | 145 | m_clientmenu.update(); |
146 | 146 | ||
147 | if (!w->isStuck()) | 147 | if (!w->isStuck()) |
148 | screen->updateNetizenWindowAdd(w->getClientWindow(), m_id); | 148 | screen->updateNetizenWindowAdd(w->getClientWindow(), m_id); |
149 | 149 | ||
150 | raiseWindow(w); | 150 | raiseWindow(w); |
151 | 151 | ||
152 | return w->getWindowNumber(); | 152 | return w->getWindowNumber(); |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | int Workspace::removeWindow(FluxboxWindow *w) { | 156 | int Workspace::removeWindow(FluxboxWindow *w) { |
157 | if (w == 0) | 157 | if (w == 0) |
158 | return -1; | 158 | return -1; |
159 | 159 | ||
160 | if (lastfocus == w) { | 160 | if (lastfocus == w) { |
161 | lastfocus = 0; | 161 | lastfocus = 0; |
162 | } | 162 | } |
163 | 163 | ||
164 | stackingList.remove(w); | 164 | stackingList.remove(w); |
165 | 165 | ||
166 | if (w->isFocused()) { | 166 | if (w->isFocused()) { |
167 | if (screen->isSloppyFocus()) { | 167 | if (screen->isSloppyFocus()) { |
168 | Fluxbox::instance()->setFocusedWindow(0); // set focused window to none | 168 | Fluxbox::instance()->setFocusedWindow(0); // set focused window to none |
169 | } else if (w->isTransient() && w->getTransientFor() && | 169 | } else if (w->isTransient() && w->getTransientFor() && |
170 | w->getTransientFor()->isVisible()) { | 170 | w->getTransientFor()->isVisible()) { |
171 | /* TODO: check transient | 171 | /* TODO: check transient |
172 | if (w->getTransientFor() == w) { // FATAL ERROR, this should not happend | 172 | if (w->getTransientFor() == w) { // FATAL ERROR, this should not happend |
173 | cerr<<"w->getTransientFor() == w: aborting!"<<endl; | 173 | cerr<<"w->getTransientFor() == w: aborting!"<<endl; |
174 | abort(); | 174 | abort(); |
175 | }*/ | 175 | }*/ |
176 | w->getTransientFor()->setInputFocus(); | 176 | w->getTransientFor()->setInputFocus(); |
177 | } else { | 177 | } else { |
178 | FluxboxWindow *top = 0; | 178 | FluxboxWindow *top = 0; |
179 | if (stackingList.size() != 0) | 179 | if (stackingList.size() != 0) |
180 | top = stackingList.front(); | 180 | top = stackingList.front(); |
181 | 181 | ||
182 | if (top == 0|| !top->setInputFocus()) { | 182 | if (top == 0|| !top->setInputFocus()) { |
183 | Fluxbox::instance()->setFocusedWindow(0); // set focused window to none | 183 | Fluxbox::instance()->setFocusedWindow(0); // set focused window to none |
184 | XSetInputFocus(Fluxbox::instance()->getXDisplay(), | 184 | XSetInputFocus(Fluxbox::instance()->getXDisplay(), |
185 | screen->getToolbar()->getWindowID(), | 185 | screen->getToolbar()->getWindowID(), |
186 | RevertToParent, CurrentTime); | 186 | RevertToParent, CurrentTime); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | 192 | ||
193 | Windows::iterator it = m_windowlist.begin(); | 193 | Windows::iterator it = m_windowlist.begin(); |
194 | Windows::iterator it_end = m_windowlist.end(); | 194 | Windows::iterator it_end = m_windowlist.end(); |
195 | for (; it != it_end; ++it) { | 195 | for (; it != it_end; ++it) { |
196 | if (*it == w) { | 196 | if (*it == w) { |
197 | m_windowlist.erase(it); | 197 | m_windowlist.erase(it); |
198 | break; | 198 | break; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | m_clientmenu.remove(w->getWindowNumber()); | 202 | m_clientmenu.remove(w->getWindowNumber()); |
203 | m_clientmenu.update(); | 203 | m_clientmenu.update(); |
204 | 204 | ||
205 | if (!w->isStuck()) | 205 | if (!w->isStuck()) |
206 | screen->updateNetizenWindowDel(w->getClientWindow()); | 206 | screen->updateNetizenWindowDel(w->getClientWindow()); |
207 | 207 | ||
208 | { | 208 | { |
209 | Windows::iterator it = m_windowlist.begin(); | 209 | Windows::iterator it = m_windowlist.begin(); |
210 | Windows::const_iterator it_end = m_windowlist.end(); | 210 | Windows::const_iterator it_end = m_windowlist.end(); |
211 | for (int i = 0; it != it_end; ++it, ++i) { | 211 | for (int i = 0; it != it_end; ++it, ++i) { |
212 | (*it)->setWindowNumber(i); | 212 | (*it)->setWindowNumber(i); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | if (lastfocus == w || m_windowlist.empty()) | 216 | if (lastfocus == w || m_windowlist.empty()) |
217 | lastfocus = 0; | 217 | lastfocus = 0; |
218 | 218 | ||
219 | return m_windowlist.size(); | 219 | return m_windowlist.size(); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void Workspace::showAll(void) { | 223 | void Workspace::showAll(void) { |
224 | WindowStack::iterator it = stackingList.begin(); | 224 | WindowStack::iterator it = stackingList.begin(); |
225 | WindowStack::iterator it_end = stackingList.end(); | 225 | WindowStack::iterator it_end = stackingList.end(); |
226 | for (; it != it_end; ++it) { | 226 | for (; it != it_end; ++it) { |
227 | (*it)->deiconify(false, false); | 227 | (*it)->deiconify(false, false); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void Workspace::hideAll(void) { | 232 | void Workspace::hideAll(void) { |
233 | WindowStack::reverse_iterator it = stackingList.rbegin(); | 233 | WindowStack::reverse_iterator it = stackingList.rbegin(); |
234 | WindowStack::reverse_iterator it_end = stackingList.rend(); | 234 | WindowStack::reverse_iterator it_end = stackingList.rend(); |
235 | for (; it != it_end; ++it) { | 235 | for (; it != it_end; ++it) { |
236 | if (! (*it)->isStuck()) | 236 | if (! (*it)->isStuck()) |
237 | (*it)->withdraw(); | 237 | (*it)->withdraw(); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void Workspace::removeAll(void) { | 242 | void Workspace::removeAll(void) { |
243 | Windows::iterator it = m_windowlist.begin(); | 243 | Windows::iterator it = m_windowlist.begin(); |
244 | Windows::const_iterator it_end = m_windowlist.end(); | 244 | Windows::const_iterator it_end = m_windowlist.end(); |
245 | for (; it != it_end; ++it) { | 245 | for (; it != it_end; ++it) { |
246 | (*it)->iconify(); | 246 | (*it)->iconify(); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | void Workspace::raiseWindow(FluxboxWindow *w) { | 251 | void Workspace::raiseWindow(FluxboxWindow *w) { |
252 | FluxboxWindow *win = w; | 252 | FluxboxWindow *win = w; |
253 | 253 | ||
254 | while (win->getTransientFor()) { | 254 | while (win->getTransientFor()) { |
255 | win = win->getTransientFor(); | 255 | win = win->getTransientFor(); |
256 | assert(win != win->getTransientFor()); | 256 | assert(win != win->getTransientFor()); |
257 | } | 257 | } |
258 | 258 | ||
259 | int i = 1 + countTransients(*win); | 259 | int i = 1 + countTransients(*win); |
260 | 260 | ||
261 | Stack nstack(i); | 261 | Stack nstack(i); |
262 | Stack::iterator stackit = nstack.begin(); | 262 | Stack::iterator stackit = nstack.begin(); |
263 | 263 | ||
264 | *(stackit++) = win->getFrameWindow(); | 264 | *(stackit++) = win->getFrameWindow(); |
265 | screen->updateNetizenWindowRaise(win->getClientWindow()); | 265 | screen->updateNetizenWindowRaise(win->getClientWindow()); |
266 | if (! win->isIconic()) { | 266 | if (! win->isIconic()) { |
267 | Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); | 267 | Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); |
268 | wkspc->stackingList.remove(win); | 268 | wkspc->stackingList.remove(win); |
269 | wkspc->stackingList.push_front(win); | 269 | wkspc->stackingList.push_front(win); |
270 | } | 270 | } |
271 | 271 | ||
272 | raiseAndFillStack(stackit, *win); | 272 | raiseAndFillStack(stackit, *win); |
273 | 273 | ||
274 | screen->raiseWindows(nstack); | 274 | screen->raiseWindows(nstack); |
275 | 275 | ||
276 | } | 276 | } |
277 | 277 | ||
278 | void Workspace::lowerWindow(FluxboxWindow *w) { | 278 | void Workspace::lowerWindow(FluxboxWindow *w) { |
279 | FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; | 279 | FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; |
280 | 280 | ||
281 | while (bottom->getTransientFor()) { | 281 | while (bottom->getTransientFor()) { |
282 | bottom = bottom->getTransientFor(); | 282 | bottom = bottom->getTransientFor(); |
283 | assert(bottom != bottom->getTransientFor()); | 283 | assert(bottom != bottom->getTransientFor()); |
284 | } | 284 | } |
285 | 285 | ||
286 | win = bottom; | 286 | win = bottom; |
287 | int i = 1 + countTransients(*win); | 287 | int i = 1 + countTransients(*win); |
288 | 288 | ||
289 | 289 | ||
290 | Stack st(i); | 290 | Stack st(i); |
291 | Stack::iterator stackit = st.begin(); | 291 | Stack::iterator stackit = st.begin(); |
292 | lowerAndFillStack(stackit, *win); | 292 | lowerAndFillStack(stackit, *win); |
293 | (*stackit) = win->getFrameWindow(); | 293 | (*stackit) = win->getFrameWindow(); |
294 | 294 | ||
295 | screen->updateNetizenWindowLower(win->getClientWindow()); | 295 | screen->updateNetizenWindowLower(win->getClientWindow()); |
296 | if (! win->isIconic()) { | 296 | if (! win->isIconic()) { |
297 | Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); | 297 | Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber()); |
298 | wkspc->stackingList.remove(win); | 298 | wkspc->stackingList.remove(win); |
299 | wkspc->stackingList.push_back(win); | 299 | wkspc->stackingList.push_back(win); |
300 | } | 300 | } |
301 | 301 | ||
302 | XLowerWindow(BaseDisplay::getXDisplay(), st.front()); | 302 | XLowerWindow(BaseDisplay::getXDisplay(), st.front()); |
303 | XRestackWindows(BaseDisplay::getXDisplay(), &st[0], st.size()); | 303 | XRestackWindows(BaseDisplay::getXDisplay(), &st[0], st.size()); |
304 | 304 | ||
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void Workspace::reconfigure() { | 308 | void Workspace::reconfigure() { |
309 | m_clientmenu.reconfigure(); | 309 | m_clientmenu.reconfigure(); |
310 | 310 | ||
311 | Windows::iterator it = m_windowlist.begin(); | 311 | Windows::iterator it = m_windowlist.begin(); |
312 | Windows::iterator it_end = m_windowlist.end(); | 312 | Windows::iterator it_end = m_windowlist.end(); |
313 | for (; it != it_end; ++it) { | 313 | for (; it != it_end; ++it) { |
314 | if ((*it)->validateClient()) | 314 | if ((*it)->validateClient()) |
315 | (*it)->reconfigure(); | 315 | (*it)->reconfigure(); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | const FluxboxWindow *Workspace::getWindow(unsigned int index) const { | 320 | const FluxboxWindow *Workspace::getWindow(unsigned int index) const { |
321 | if (index < m_windowlist.size()) | 321 | if (index < m_windowlist.size()) |
322 | return m_windowlist[index]; | 322 | return m_windowlist[index]; |
323 | return 0; | 323 | return 0; |
324 | } | 324 | } |
325 | 325 | ||
326 | FluxboxWindow *Workspace::getWindow(unsigned int index) { | 326 | FluxboxWindow *Workspace::getWindow(unsigned int index) { |
327 | if (index < m_windowlist.size()) | 327 | if (index < m_windowlist.size()) |
328 | return m_windowlist[index]; | 328 | return m_windowlist[index]; |
329 | return 0; | 329 | return 0; |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | int Workspace::getCount() const { | 333 | int Workspace::getCount() const { |
334 | return m_windowlist.size(); | 334 | return m_windowlist.size(); |
335 | } | 335 | } |
336 | 336 | ||
337 | namespace { | 337 | namespace { |
338 | // helper class for checkGrouping | 338 | // helper class for checkGrouping |
339 | class FindInGroup { | 339 | class FindInGroup { |
340 | public: | 340 | public: |
341 | FindInGroup(const FluxboxWindow &w):m_w(w) { } | 341 | FindInGroup(const FluxboxWindow &w):m_w(w) { } |
342 | bool operator ()(const string &name) { | 342 | bool operator ()(const string &name) { |
343 | return (name == m_w.instanceName()); | 343 | return (name == m_w.instanceName()); |
344 | } | 344 | } |
345 | private: | 345 | private: |
346 | const FluxboxWindow &m_w; | 346 | const FluxboxWindow &m_w; |
347 | }; | 347 | }; |
348 | 348 | ||
349 | }; | 349 | }; |
@@ -351,111 +351,111 @@ private: | |||
351 | //Note: this function doesn't check if the window is groupable | 351 | //Note: this function doesn't check if the window is groupable |
352 | void Workspace::checkGrouping(FluxboxWindow &win) { | 352 | void Workspace::checkGrouping(FluxboxWindow &win) { |
353 | #ifdef DEBUG | 353 | #ifdef DEBUG |
354 | cerr<<__FILE__<<"("<<__LINE__<<"): Checking grouping. ("<<win.instanceName()<<"/"<< | 354 | cerr<<__FILE__<<"("<<__LINE__<<"): Checking grouping. ("<<win.instanceName()<<"/"<< |
355 | win.className()<<")"<<endl; | 355 | win.className()<<")"<<endl; |
356 | #endif // DEBUG | 356 | #endif // DEBUG |
357 | if (!win.isGroupable()) { // make sure this window can hold a tab | 357 | if (!win.isGroupable()) { // make sure this window can hold a tab |
358 | #ifdef DEBUG | 358 | #ifdef DEBUG |
359 | cerr<<__FILE__<<"("<<__LINE__<<"): window can't use a tab"<<endl; | 359 | cerr<<__FILE__<<"("<<__LINE__<<"): window can't use a tab"<<endl; |
360 | #endif // DEBUG | 360 | #endif // DEBUG |
361 | return; | 361 | return; |
362 | } | 362 | } |
363 | 363 | ||
364 | // go throu every group and search for matching win instancename | 364 | // go throu every group and search for matching win instancename |
365 | GroupList::iterator g(m_groups.begin()); | 365 | GroupList::iterator g(m_groups.begin()); |
366 | GroupList::iterator g_end(m_groups.end()); | 366 | GroupList::iterator g_end(m_groups.end()); |
367 | for (; g != g_end; ++g) { | 367 | for (; g != g_end; ++g) { |
368 | Group::iterator name((*g).begin()); | 368 | Group::iterator name((*g).begin()); |
369 | Group::iterator name_end((*g).end()); | 369 | Group::iterator name_end((*g).end()); |
370 | for (; name != name_end; ++name) { | 370 | for (; name != name_end; ++name) { |
371 | 371 | ||
372 | if ((*name) != win.instanceName()) | 372 | if ((*name) != win.instanceName()) |
373 | continue; | 373 | continue; |
374 | 374 | ||
375 | // find a window with the specific name | 375 | // find a window with the specific name |
376 | Windows::iterator wit(m_windowlist.begin()); | 376 | Windows::iterator wit(m_windowlist.begin()); |
377 | Windows::iterator wit_end(m_windowlist.end()); | 377 | Windows::iterator wit_end(m_windowlist.end()); |
378 | for (; wit != wit_end; ++wit) { | 378 | for (; wit != wit_end; ++wit) { |
379 | #ifdef DEBUG | 379 | #ifdef DEBUG |
380 | cerr<<__FILE__<<" check group with : "<<(*wit)->instanceName()<<endl; | 380 | cerr<<__FILE__<<" check group with : "<<(*wit)->instanceName()<<endl; |
381 | #endif // DEBUG | 381 | #endif // DEBUG |
382 | if (find_if((*g).begin(), (*g).end(), FindInGroup(*(*wit))) != (*g).end()) { | 382 | if (find_if((*g).begin(), (*g).end(), FindInGroup(*(*wit))) != (*g).end()) { |
383 | // make sure the window is groupable | 383 | // make sure the window is groupable |
384 | if ( !(*wit)->isGroupable()) | 384 | if ( !(*wit)->isGroupable()) |
385 | break; // try next name | 385 | break; // try next name |
386 | //toggle tab on | 386 | //toggle tab on |
387 | if ((*wit)->getTab() == 0) | 387 | if ((*wit)->getTab() == 0) |
388 | (*wit)->setTab(true); | 388 | (*wit)->setTab(true); |
389 | if (win.getTab() == 0) | 389 | if (win.getTab() == 0) |
390 | win.setTab(true); | 390 | win.setTab(true); |
391 | // did we succefully set the tab? | 391 | // did we succefully set the tab? |
392 | if ((*wit)->getTab() == 0) | 392 | if ((*wit)->getTab() == 0) |
393 | break; // try another window | 393 | break; // try another window |
394 | (*wit)->getTab()->insert(win.getTab()); | 394 | (*wit)->getTab()->insert(win.getTab()); |
395 | 395 | ||
396 | return; // grouping done | 396 | return; // grouping done |
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | } | 400 | } |
401 | 401 | ||
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | bool Workspace::loadGroups(const std::string &filename) { | 405 | bool Workspace::loadGroups(const std::string &filename) { |
406 | ifstream infile(filename.c_str()); | 406 | ifstream infile(filename.c_str()); |
407 | if (!infile) | 407 | if (!infile) |
408 | return false; | 408 | return false; |
409 | m_groups.clear(); // erase old groups | 409 | m_groups.clear(); // erase old groups |
410 | 410 | ||
411 | // load new groups | 411 | // load new groups |
412 | while (!infile.eof()) { | 412 | while (!infile.eof()) { |
413 | string line; | 413 | string line; |
414 | vector<string> names; | 414 | vector<string> names; |
415 | getline(infile, line); | 415 | getline(infile, line); |
416 | StringUtil::stringtok(names, line); | 416 | StringUtil::stringtok(names, line); |
417 | m_groups.push_back(names); | 417 | m_groups.push_back(names); |
418 | } | 418 | } |
419 | 419 | ||
420 | return true; | 420 | return true; |
421 | } | 421 | } |
422 | 422 | ||
423 | void Workspace::update() { | 423 | void Workspace::update() { |
424 | m_clientmenu.update(); | 424 | m_clientmenu.update(); |
425 | screen->getToolbar()->redrawWindowLabel(True); | 425 | screen->getToolbar()->redrawWindowLabel(True); |
426 | } | 426 | } |
427 | 427 | ||
428 | 428 | ||
429 | bool Workspace::isCurrent() const{ | 429 | bool Workspace::isCurrent() const{ |
430 | return (m_id == screen->getCurrentWorkspaceID()); | 430 | return (m_id == screen->getCurrentWorkspaceID()); |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | bool Workspace::isLastWindow(FluxboxWindow *w) const{ | 434 | bool Workspace::isLastWindow(FluxboxWindow *w) const{ |
435 | return (w == m_windowlist.back()); | 435 | return (w == m_windowlist.back()); |
436 | } | 436 | } |
437 | 437 | ||
438 | void Workspace::setCurrent() { | 438 | void Workspace::setCurrent() { |
439 | screen->changeWorkspaceID(m_id); | 439 | screen->changeWorkspaceID(m_id); |
440 | } | 440 | } |
441 | 441 | ||
442 | 442 | ||
443 | void Workspace::setName(const std::string &name) { | 443 | void Workspace::setName(const std::string &name) { |
444 | if (name.size() != 0) { | 444 | if (name.size() != 0) { |
445 | m_name = name; | 445 | m_name = name; |
446 | } else { //if name == 0 then set default name from nls | 446 | } else { //if name == 0 then set default name from nls |
447 | char tname[128]; | 447 | char tname[128]; |
448 | sprintf(tname, I18n::instance()-> | 448 | sprintf(tname, I18n::instance()-> |
449 | getMessage( | 449 | getMessage( |
450 | FBNLS::WorkspaceSet, FBNLS::WorkspaceDefaultNameFormat, | 450 | FBNLS::WorkspaceSet, FBNLS::WorkspaceDefaultNameFormat, |
451 | "Workspace %d"), m_id + 1); //m_id starts at 0 | 451 | "Workspace %d"), m_id + 1); //m_id starts at 0 |
452 | m_name = tname; | 452 | m_name = tname; |
453 | } | 453 | } |
454 | 454 | ||
455 | screen->updateWorkspaceNamesAtom(); | 455 | screen->updateWorkspaceNamesAtom(); |
456 | 456 | ||
457 | m_clientmenu.setLabel(m_name.c_str()); | 457 | m_clientmenu.setLabel(m_name.c_str()); |
458 | m_clientmenu.update(); | 458 | m_clientmenu.update(); |
459 | } | 459 | } |
460 | 460 | ||
461 | //------------ shutdown --------- | 461 | //------------ shutdown --------- |
@@ -464,406 +464,406 @@ void Workspace::setName(const std::string &name) { | |||
464 | // clears the m_windowlist | 464 | // clears the m_windowlist |
465 | //------------------------------- | 465 | //------------------------------- |
466 | void Workspace::shutdown() { | 466 | void Workspace::shutdown() { |
467 | // note: when the window dies it'll remove it self from the list | 467 | // note: when the window dies it'll remove it self from the list |
468 | while (!m_windowlist.empty()) { | 468 | while (!m_windowlist.empty()) { |
469 | m_windowlist.back()->restore(true); // restore with remap | 469 | m_windowlist.back()->restore(true); // restore with remap |
470 | delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist) | 470 | delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist) |
471 | } | 471 | } |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | void Workspace::placeWindow(FluxboxWindow *win) { | 475 | void Workspace::placeWindow(FluxboxWindow *win) { |
476 | Bool placed = False; | 476 | Bool placed = False; |
477 | int borderWidth4x = screen->getBorderWidth2x() * 2, | 477 | int borderWidth4x = screen->getBorderWidth2x() * 2, |
478 | #ifdef SLIT | 478 | #ifdef SLIT |
479 | slit_x = screen->getSlit()->x() - screen->getBorderWidth(), | 479 | slit_x = screen->getSlit()->x() - screen->getBorderWidth(), |
480 | slit_y = screen->getSlit()->y() - screen->getBorderWidth(), | 480 | slit_y = screen->getSlit()->y() - screen->getBorderWidth(), |
481 | slit_w = screen->getSlit()->width() + borderWidth4x, | 481 | slit_w = screen->getSlit()->width() + borderWidth4x, |
482 | slit_h = screen->getSlit()->height() + borderWidth4x, | 482 | slit_h = screen->getSlit()->height() + borderWidth4x, |
483 | #endif // SLIT | 483 | #endif // SLIT |
484 | toolbar_x = screen->getToolbar()->x() - screen->getBorderWidth(), | 484 | toolbar_x = screen->getToolbar()->x() - screen->getBorderWidth(), |
485 | toolbar_y = screen->getToolbar()->y() - screen->getBorderWidth(), | 485 | toolbar_y = screen->getToolbar()->y() - screen->getBorderWidth(), |
486 | toolbar_w = screen->getToolbar()->width() + borderWidth4x, | 486 | toolbar_w = screen->getToolbar()->width() + borderWidth4x, |
487 | toolbar_h = screen->getToolbar()->height() + borderWidth4x, | 487 | toolbar_h = screen->getToolbar()->height() + borderWidth4x, |
488 | place_x = 0, place_y = 0, change_x = 1, change_y = 1; | 488 | place_x = 0, place_y = 0, change_x = 1, change_y = 1; |
489 | |||
490 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) | ||
491 | change_y = -1; | ||
492 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) | ||
493 | change_x = -1; | ||
494 | |||
495 | #ifdef XINERAMA | ||
496 | int head = 0, | ||
497 | head_x = 0, | ||
498 | head_y = 0; | ||
499 | int head_w, head_h; | ||
500 | if (screen->hasXinerama()) { | ||
501 | head = screen->getCurrHead(); | ||
502 | head_x = screen->getHeadX(head); | ||
503 | head_y = screen->getHeadY(head); | ||
504 | head_w = screen->getHeadWidth(head); | ||
505 | head_h = screen->getHeadHeight(head); | ||
506 | |||
507 | } else { // no xinerama | ||
508 | head_w = screen->getWidth(); | ||
509 | head_h = screen->getHeight(); | ||
510 | } | ||
511 | |||
512 | #endif // XINERAMA | ||
489 | 513 | ||
490 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) | 514 | int win_w = win->getWidth() + screen->getBorderWidth2x(), |
491 | change_y = -1; | 515 | win_h = win->getHeight() + screen->getBorderWidth2x(); |
492 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) | 516 | |
493 | change_x = -1; | 517 | if (win->hasTab()) { |
518 | if ((! win->isShaded()) && | ||
519 | screen->getTabPlacement() == Tab::PLEFT || | ||
520 | screen->getTabPlacement() == Tab::PRIGHT) | ||
521 | win_w += (screen->isTabRotateVertical()) | ||
522 | ? screen->getTabHeight() | ||
523 | : screen->getTabWidth(); | ||
524 | else // tab placement top or bottom or win is shaded | ||
525 | win_h += screen->getTabHeight(); | ||
526 | } | ||
527 | |||
528 | register int test_x, test_y, curr_x, curr_y, curr_w, curr_h; | ||
529 | |||
530 | switch (screen->getPlacementPolicy()) { | ||
531 | case BScreen::ROWSMARTPLACEMENT: { | ||
532 | #ifdef XINERAMA | ||
533 | test_y = head_y; | ||
534 | #else // !XINERAMA | ||
535 | test_y = 0; | ||
536 | #endif // XINERAMA | ||
537 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) | ||
538 | #ifdef XINERAMA | ||
539 | test_y = (head_y + head_h) - win_h - test_y; | ||
540 | #else // !XINERAMA | ||
541 | test_y = screen->getHeight() - win_h - test_y; | ||
542 | #endif // XINERAMA | ||
494 | 543 | ||
544 | while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? | ||
495 | #ifdef XINERAMA | 545 | #ifdef XINERAMA |
496 | int head = 0, | 546 | test_y >= head_y : test_y + win_h <= (head_y + head_h)) && |
497 | head_x = 0, | 547 | #else // !XINERAMA |
498 | head_y = 0; | 548 | test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && |
499 | int head_w, head_h; | 549 | #endif // XINERAMA |
500 | if (screen->hasXinerama()) { | 550 | ! placed) { |
501 | head = screen->getCurrHead(); | ||
502 | head_x = screen->getHeadX(head); | ||
503 | head_y = screen->getHeadY(head); | ||
504 | head_w = screen->getHeadWidth(head); | ||
505 | head_h = screen->getHeadHeight(head); | ||
506 | |||
507 | } else { // no xinerama | ||
508 | head_w = screen->getWidth(); | ||
509 | head_h = screen->getHeight(); | ||
510 | } | ||
511 | 551 | ||
552 | #ifdef XINERAMA | ||
553 | test_x = head_x; | ||
554 | #else // !XINERAMA | ||
555 | test_x = 0; | ||
556 | #endif // XINERAMA | ||
557 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) | ||
558 | #ifdef XINERAMA | ||
559 | test_x = (head_x + head_w) - win_w - test_x; | ||
560 | #else // !XINERAMA | ||
561 | test_x = screen->getWidth() - win_w - test_x; | ||
512 | #endif // XINERAMA | 562 | #endif // XINERAMA |
513 | 563 | ||
514 | int win_w = win->getWidth() + screen->getBorderWidth2x(), | 564 | while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? |
515 | win_h = win->getHeight() + screen->getBorderWidth2x(); | 565 | #ifdef XINERAMA |
516 | 566 | test_x >= head_x : test_x + win_w <= (head_x + head_w)) && | |
517 | if (win->hasTab()) { | 567 | #else // !XINERAMA |
518 | if ((! win->isShaded()) && | 568 | test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && |
519 | screen->getTabPlacement() == Tab::PLEFT || | 569 | #endif // XINERAMA |
520 | screen->getTabPlacement() == Tab::PRIGHT) | 570 | ! placed) { |
521 | win_w += (screen->isTabRotateVertical()) | 571 | |
522 | ? screen->getTabHeight() | 572 | placed = True; |
523 | : screen->getTabWidth(); | 573 | |
524 | else // tab placement top or bottom or win is shaded | 574 | Windows::iterator it = m_windowlist.begin(); |
525 | win_h += screen->getTabHeight(); | 575 | Windows::iterator it_end = m_windowlist.end(); |
526 | } | 576 | |
527 | 577 | for (; it != it_end && placed; ++it) { | |
528 | register int test_x, test_y, curr_x, curr_y, curr_w, curr_h; | 578 | curr_x = (*it)->getXFrame(); |
529 | 579 | curr_y = (*it)->getYFrame(); | |
530 | switch (screen->getPlacementPolicy()) { | 580 | curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); |
531 | case BScreen::ROWSMARTPLACEMENT: { | 581 | curr_h = |
532 | #ifdef XINERAMA | 582 | (((*it)->isShaded()) |
533 | test_y = head_y; | 583 | ? (*it)->getTitleHeight() |
534 | #else // !XINERAMA | 584 | : (*it)->getHeight()) + |
535 | test_y = 0; | 585 | screen->getBorderWidth2x(); |
536 | #endif // XINERAMA | 586 | |
537 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) | 587 | if ((*it)->hasTab()) { |
538 | #ifdef XINERAMA | 588 | if (! (*it)->isShaded()) { // not shaded window |
539 | test_y = (head_y + head_h) - win_h - test_y; | 589 | switch(screen->getTabPlacement()) { |
540 | #else // !XINERAMA | 590 | case Tab::PTOP: |
541 | test_y = screen->getHeight() - win_h - test_y; | 591 | curr_y -= screen->getTabHeight(); |
542 | #endif // XINERAMA | 592 | case Tab::PBOTTOM: |
543 | 593 | curr_h += screen->getTabHeight(); | |
544 | while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? | 594 | break; |
545 | #ifdef XINERAMA | 595 | case Tab::PLEFT: |
546 | test_y >= head_y : test_y + win_h <= (head_y + head_h)) && | 596 | curr_x -= (screen->isTabRotateVertical()) |
547 | #else // !XINERAMA | 597 | ? screen->getTabHeight() |
548 | test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && | 598 | : screen->getTabWidth(); |
549 | #endif // XINERAMA | 599 | case Tab::PRIGHT: |
550 | ! placed) { | 600 | curr_w += (screen->isTabRotateVertical()) |
551 | 601 | ? screen->getTabHeight() | |
552 | #ifdef XINERAMA | 602 | : screen->getTabWidth(); |
553 | test_x = head_x; | 603 | break; |
554 | #else // !XINERAMA | 604 | case Tab::PNONE: |
555 | test_x = 0; | 605 | break; |
556 | #endif // XINERAMA | 606 | } |
557 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) | 607 | } else { // shaded window |
558 | #ifdef XINERAMA | 608 | if (screen->getTabPlacement() == Tab::PTOP) |
559 | test_x = (head_x + head_w) - win_w - test_x; | 609 | curr_y -= screen->getTabHeight(); |
560 | #else // !XINERAMA | 610 | curr_h += screen->getTabHeight(); |
561 | test_x = screen->getWidth() - win_w - test_x; | 611 | } |
562 | #endif // XINERAMA | 612 | } // tab cheking done |
563 | 613 | ||
564 | while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? | 614 | if (curr_x < test_x + win_w && |
565 | #ifdef XINERAMA | 615 | curr_x + curr_w > test_x && |
566 | test_x >= head_x : test_x + win_w <= (head_x + head_w)) && | 616 | curr_y < test_y + win_h && |
567 | #else // !XINERAMA | 617 | curr_y + curr_h > test_y) { |
568 | test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && | 618 | placed = False; |
569 | #endif // XINERAMA | 619 | } |
570 | ! placed) { | 620 | } |
571 | 621 | ||
572 | placed = True; | 622 | if ((toolbar_x < test_x + win_w && |
573 | 623 | toolbar_x + toolbar_w > test_x && | |
574 | Windows::iterator it = m_windowlist.begin(); | 624 | toolbar_y < test_y + win_h && |
575 | Windows::iterator it_end = m_windowlist.end(); | 625 | toolbar_y + toolbar_h > test_y) |
576 | |||
577 | for (; it != it_end && placed; ++it) { | ||
578 | curr_x = (*it)->getXFrame(); | ||
579 | curr_y = (*it)->getYFrame(); | ||
580 | curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); | ||
581 | curr_h = | ||
582 | (((*it)->isShaded()) | ||
583 | ? (*it)->getTitleHeight() | ||
584 | : (*it)->getHeight()) + | ||
585 | screen->getBorderWidth2x(); | ||
586 | |||
587 | if ((*it)->hasTab()) { | ||
588 | if (! (*it)->isShaded()) { // not shaded window | ||
589 | switch(screen->getTabPlacement()) { | ||
590 | case Tab::PTOP: | ||
591 | curr_y -= screen->getTabHeight(); | ||
592 | case Tab::PBOTTOM: | ||
593 | curr_h += screen->getTabHeight(); | ||
594 | break; | ||
595 | case Tab::PLEFT: | ||
596 | curr_x -= (screen->isTabRotateVertical()) | ||
597 | ? screen->getTabHeight() | ||
598 | : screen->getTabWidth(); | ||
599 | case Tab::PRIGHT: | ||
600 | curr_w += (screen->isTabRotateVertical()) | ||
601 | ? screen->getTabHeight() | ||
602 | : screen->getTabWidth(); | ||
603 | break; | ||
604 | case Tab::PNONE: | ||
605 | break; | ||
606 | } | ||
607 | } else { // shaded window | ||
608 | if (screen->getTabPlacement() == Tab::PTOP) | ||
609 | curr_y -= screen->getTabHeight(); | ||
610 | curr_h += screen->getTabHeight(); | ||
611 | } | ||
612 | } // tab cheking done | ||
613 | |||
614 | if (curr_x < test_x + win_w && | ||
615 | curr_x + curr_w > test_x && | ||
616 | curr_y < test_y + win_h && | ||
617 | curr_y + curr_h > test_y) { | ||
618 | placed = False; | ||
619 | } | ||
620 | } | ||
621 | |||
622 | if ((toolbar_x < test_x + win_w && | ||
623 | toolbar_x + toolbar_w > test_x && | ||
624 | toolbar_y < test_y + win_h && | ||
625 | toolbar_y + toolbar_h > test_y) | ||
626 | #ifdef SLIT | 626 | #ifdef SLIT |
627 | || | 627 | || |
628 | (slit_x < test_x + win_w && | 628 | (slit_x < test_x + win_w && |
629 | slit_x + slit_w > test_x && | 629 | slit_x + slit_w > test_x && |
630 | slit_y < test_y + win_h && | 630 | slit_y < test_y + win_h && |
631 | slit_y + slit_h > test_y) | 631 | slit_y + slit_h > test_y) |
632 | #endif // SLIT | 632 | #endif // SLIT |
633 | ) | 633 | ) |
634 | placed = False; | 634 | placed = False; |
635 | 635 | ||
636 | if (placed) { | 636 | if (placed) { |
637 | place_x = test_x; | 637 | place_x = test_x; |
638 | place_y = test_y; | 638 | place_y = test_y; |
639 | 639 | ||
640 | break; | 640 | break; |
641 | } | 641 | } |
642 | 642 | ||
643 | test_x += change_x; | 643 | test_x += change_x; |
644 | } | 644 | } |
645 | 645 | ||
646 | test_y += change_y; | 646 | test_y += change_y; |
647 | } | 647 | } |
648 | 648 | ||
649 | break; } | 649 | break; } |
650 | 650 | ||
651 | case BScreen::COLSMARTPLACEMENT: { | 651 | case BScreen::COLSMARTPLACEMENT: { |
652 | #ifdef XINERAMA | 652 | #ifdef XINERAMA |
653 | test_x = head_x; | 653 | test_x = head_x; |
654 | #else // !XINERAMA | 654 | #else // !XINERAMA |
655 | test_x = 0; | 655 | test_x = 0; |
656 | #endif // XINERAMA | 656 | #endif // XINERAMA |
657 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) | 657 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) |
658 | #ifdef XINERAMA | 658 | #ifdef XINERAMA |
659 | test_x = (head_x + head_w) - win_w - test_x; | 659 | test_x = (head_x + head_w) - win_w - test_x; |
660 | #else // !XINERAMA | 660 | #else // !XINERAMA |
661 | test_x = screen->getWidth() - win_w - test_x; | 661 | test_x = screen->getWidth() - win_w - test_x; |
662 | #endif // XINERAMA | 662 | #endif // XINERAMA |
663 | 663 | ||
664 | while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? | 664 | while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? |
665 | #ifdef XINERAMA | 665 | #ifdef XINERAMA |
666 | test_x >= 0 : test_x + win_w <= (head_x + head_w)) && | 666 | test_x >= 0 : test_x + win_w <= (head_x + head_w)) && |
667 | #else // !XINERAMA | 667 | #else // !XINERAMA |
668 | test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && | 668 | test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && |
669 | #endif // XINERAMA | 669 | #endif // XINERAMA |
670 | ! placed) { | 670 | ! placed) { |
671 | 671 | ||
672 | #ifdef XINERAMA | 672 | #ifdef XINERAMA |
673 | test_y = head_y; | 673 | test_y = head_y; |
674 | #else // !XINERAMA | 674 | #else // !XINERAMA |
675 | test_y = 0; | 675 | test_y = 0; |
676 | #endif // XINERAMA | 676 | #endif // XINERAMA |
677 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) | 677 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) |
678 | #ifdef XINERAMA | 678 | #ifdef XINERAMA |
679 | test_y = (head_y + head_h) - win_h - test_y; | 679 | test_y = (head_y + head_h) - win_h - test_y; |
680 | #else // !XINERAMA | 680 | #else // !XINERAMA |
681 | test_y = screen->getHeight() - win_h - test_y; | 681 | test_y = screen->getHeight() - win_h - test_y; |
682 | #endif // XINERAMA | 682 | #endif // XINERAMA |
683 | 683 | ||
684 | while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? | 684 | while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? |
685 | #ifdef XINERAMA | 685 | #ifdef XINERAMA |
686 | test_y >= head_y : test_y + win_h <= (head_y + head_h)) && | 686 | test_y >= head_y : test_y + win_h <= (head_y + head_h)) && |
687 | #else // !XINERAMA | 687 | #else // !XINERAMA |
688 | test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && | 688 | test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && |
689 | #endif // XINERAMA | 689 | #endif // XINERAMA |
690 | ! placed) { | 690 | ! placed) { |
691 | placed = True; | 691 | placed = True; |
692 | 692 | ||
693 | Windows::iterator it = m_windowlist.begin(); | 693 | Windows::iterator it = m_windowlist.begin(); |
694 | Windows::iterator it_end = m_windowlist.end(); | 694 | Windows::iterator it_end = m_windowlist.end(); |
695 | for (; it != it_end && placed; ++it) { | 695 | for (; it != it_end && placed; ++it) { |
696 | curr_x = (*it)->getXFrame(); | 696 | curr_x = (*it)->getXFrame(); |
697 | curr_y = (*it)->getYFrame(); | 697 | curr_y = (*it)->getYFrame(); |
698 | curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); | 698 | curr_w = (*it)->getWidth() + screen->getBorderWidth2x(); |
699 | curr_h = | 699 | curr_h = |
700 | (((*it)->isShaded()) | 700 | (((*it)->isShaded()) |
701 | ? (*it)->getTitleHeight() | 701 | ? (*it)->getTitleHeight() |
702 | : (*it)->getHeight()) + | 702 | : (*it)->getHeight()) + |
703 | screen->getBorderWidth2x();; | 703 | screen->getBorderWidth2x();; |
704 | 704 | ||
705 | if ((*it)->hasTab()) { | 705 | if ((*it)->hasTab()) { |
706 | if (! (*it)->isShaded()) { // not shaded window | 706 | if (! (*it)->isShaded()) { // not shaded window |
707 | switch(screen->getTabPlacement()) { | 707 | switch(screen->getTabPlacement()) { |
708 | case Tab::PTOP: | 708 | case Tab::PTOP: |
709 | curr_y -= screen->getTabHeight(); | 709 | curr_y -= screen->getTabHeight(); |
710 | case Tab::PBOTTOM: | 710 | case Tab::PBOTTOM: |
711 | curr_h += screen->getTabHeight(); | 711 | curr_h += screen->getTabHeight(); |
712 | break; | 712 | break; |
713 | case Tab::PLEFT: | 713 | case Tab::PLEFT: |
714 | curr_x -= (screen->isTabRotateVertical()) | 714 | curr_x -= (screen->isTabRotateVertical()) |
715 | ? screen->getTabHeight() | 715 | ? screen->getTabHeight() |
716 | : screen->getTabWidth(); | 716 | : screen->getTabWidth(); |
717 | case Tab::PRIGHT: | 717 | case Tab::PRIGHT: |
718 | curr_w += (screen->isTabRotateVertical()) | 718 | curr_w += (screen->isTabRotateVertical()) |
719 | ? screen->getTabHeight() | 719 | ? screen->getTabHeight() |
720 | : screen->getTabWidth(); | 720 | : screen->getTabWidth(); |
721 | break; | 721 | break; |
722 | default: | 722 | default: |
723 | #ifdef DEBUG | 723 | #ifdef DEBUG |
724 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | 724 | cerr << __FILE__ << ":" <<__LINE__ << ": " << |
725 | "Unsupported Placement" << endl; | 725 | "Unsupported Placement" << endl; |
726 | #endif // DEBUG | 726 | #endif // DEBUG |
727 | break; | 727 | break; |
728 | } | 728 | } |
729 | } else { // shaded window | 729 | } else { // shaded window |
730 | if (screen->getTabPlacement() == Tab::PTOP) | 730 | if (screen->getTabPlacement() == Tab::PTOP) |
731 | curr_y -= screen->getTabHeight(); | 731 | curr_y -= screen->getTabHeight(); |
732 | curr_h += screen->getTabHeight(); | 732 | curr_h += screen->getTabHeight(); |
733 | } | 733 | } |
734 | } // tab cheking done | 734 | } // tab cheking done |
735 | 735 | ||
736 | if (curr_x < test_x + win_w && | 736 | if (curr_x < test_x + win_w && |
737 | curr_x + curr_w > test_x && | 737 | curr_x + curr_w > test_x && |
738 | curr_y < test_y + win_h && | 738 | curr_y < test_y + win_h && |
739 | curr_y + curr_h > test_y) { | 739 | curr_y + curr_h > test_y) { |
740 | placed = False; | 740 | placed = False; |
741 | } | 741 | } |
742 | } | 742 | } |
743 | 743 | ||
744 | if ((toolbar_x < test_x + win_w && | 744 | if ((toolbar_x < test_x + win_w && |
745 | toolbar_x + toolbar_w > test_x && | 745 | toolbar_x + toolbar_w > test_x && |
746 | toolbar_y < test_y + win_h && | 746 | toolbar_y < test_y + win_h && |
747 | toolbar_y + toolbar_h > test_y) | 747 | toolbar_y + toolbar_h > test_y) |
748 | #ifdef SLIT | 748 | #ifdef SLIT |
749 | || | 749 | || |
750 | (slit_x < test_x + win_w && | 750 | (slit_x < test_x + win_w && |
751 | slit_x + slit_w > test_x && | 751 | slit_x + slit_w > test_x && |
752 | slit_y < test_y + win_h && | 752 | slit_y < test_y + win_h && |
753 | slit_y + slit_h > test_y) | 753 | slit_y + slit_h > test_y) |
754 | #endif // SLIT | 754 | #endif // SLIT |
755 | ) | 755 | ) |
756 | placed = False; | 756 | placed = False; |
757 | 757 | ||
758 | if (placed) { | 758 | if (placed) { |
759 | place_x = test_x; | 759 | place_x = test_x; |
760 | place_y = test_y; | 760 | place_y = test_y; |
761 | } | 761 | } |
762 | 762 | ||
763 | test_y += change_y; | 763 | test_y += change_y; |
764 | } | 764 | } |
765 | 765 | ||
766 | test_x += change_x; | 766 | test_x += change_x; |
767 | } | 767 | } |
768 | 768 | ||
769 | break; } | 769 | break; } |
770 | } | 770 | } |
771 | 771 | ||
772 | // cascade placement or smart placement failed | 772 | // cascade placement or smart placement failed |
773 | if (! placed) { | 773 | if (! placed) { |
774 | #ifdef XINERAMA | 774 | #ifdef XINERAMA |
775 | if ((cascade_x > (head_w / 2)) || | 775 | if ((cascade_x > (head_w / 2)) || |
776 | (cascade_y > (head_h / 2))) | 776 | (cascade_y > (head_h / 2))) |
777 | #else // !XINERAMA | 777 | #else // !XINERAMA |
778 | if (((unsigned) cascade_x > (screen->getWidth() / 2)) || | 778 | if (((unsigned) cascade_x > (screen->getWidth() / 2)) || |
779 | ((unsigned) cascade_y > (screen->getHeight() / 2))) | 779 | ((unsigned) cascade_y > (screen->getHeight() / 2))) |
780 | #endif // XINERAMA | 780 | #endif // XINERAMA |
781 | 781 | ||
782 | cascade_x = cascade_y = 32; | 782 | cascade_x = cascade_y = 32; |
783 | #ifdef XINERAMA | 783 | #ifdef XINERAMA |
784 | place_x = head_x + cascade_x; | 784 | place_x = head_x + cascade_x; |
785 | place_y = head_y + cascade_y; | 785 | place_y = head_y + cascade_y; |
786 | #else // !XINERAMA | 786 | #else // !XINERAMA |
787 | place_x = cascade_x; | 787 | place_x = cascade_x; |
788 | place_y = cascade_y; | 788 | place_y = cascade_y; |
789 | #endif // XINERAMA | 789 | #endif // XINERAMA |
790 | cascade_x += win->getTitleHeight(); | 790 | cascade_x += win->getTitleHeight(); |
791 | cascade_y += win->getTitleHeight(); | 791 | cascade_y += win->getTitleHeight(); |
792 | } | 792 | } |
793 | 793 | ||
794 | #ifdef XINERAMA | 794 | #ifdef XINERAMA |
795 | if (place_x + win_w > (head_x + head_w)) | 795 | if (place_x + win_w > (head_x + head_w)) |
796 | place_x = head_x + ((head_w - win_w) / 2); | 796 | place_x = head_x + ((head_w - win_w) / 2); |
797 | if (place_y + win_h > (head_y + head_h)) | 797 | if (place_y + win_h > (head_y + head_h)) |
798 | place_y = head_y + ((head_h - win_h) / 2); | 798 | place_y = head_y + ((head_h - win_h) / 2); |
799 | #else // !XINERAMA | 799 | #else // !XINERAMA |
800 | if (place_x + win_w > (signed) screen->getWidth()) | 800 | if (place_x + win_w > (signed) screen->getWidth()) |
801 | place_x = (((signed) screen->getWidth()) - win_w) / 2; | 801 | place_x = (((signed) screen->getWidth()) - win_w) / 2; |
802 | if (place_y + win_h > (signed) screen->getHeight()) | 802 | if (place_y + win_h > (signed) screen->getHeight()) |
803 | place_y = (((signed) screen->getHeight()) - win_h) / 2; | 803 | place_y = (((signed) screen->getHeight()) - win_h) / 2; |
804 | #endif // XINERAMA | 804 | #endif // XINERAMA |
805 | 805 | ||
806 | // fix window placement, think of tabs | 806 | // fix window placement, think of tabs |
807 | if (win->hasTab()) { | 807 | if (win->hasTab()) { |
808 | if (screen->getTabPlacement() == Tab::PTOP) | 808 | if (screen->getTabPlacement() == Tab::PTOP) |
809 | place_y += screen->getTabHeight(); | 809 | place_y += screen->getTabHeight(); |
810 | else if (screen->getTabPlacement() == Tab::PLEFT) | 810 | else if (screen->getTabPlacement() == Tab::PLEFT) |
811 | place_x += (screen->isTabRotateVertical()) | 811 | place_x += (screen->isTabRotateVertical()) |
812 | ? screen->getTabHeight() | 812 | ? screen->getTabHeight() |
813 | : screen->getTabWidth(); | 813 | : screen->getTabWidth(); |
814 | } | 814 | } |
815 | 815 | ||
816 | win->configure(place_x, place_y, win->getWidth(), win->getHeight()); | 816 | win->configure(place_x, place_y, win->getWidth(), win->getHeight()); |
817 | } | 817 | } |
818 | 818 | ||
819 | 819 | ||
820 | void Workspace::raiseAndFillStack(Stack::iterator &stackit, const FluxboxWindow &w) { | 820 | void Workspace::raiseAndFillStack(Stack::iterator &stackit, const FluxboxWindow &w) { |
821 | if (w.getTransients().empty()) | 821 | if (w.getTransients().empty()) |
822 | return; | 822 | return; |
823 | 823 | ||
824 | std::list<FluxboxWindow *>::const_iterator it = w.getTransients().begin(); | 824 | std::list<FluxboxWindow *>::const_iterator it = w.getTransients().begin(); |
825 | std::list<FluxboxWindow *>::const_iterator it_end = w.getTransients().end(); | 825 | std::list<FluxboxWindow *>::const_iterator it_end = w.getTransients().end(); |
826 | for (; it != it_end; ++it) { | 826 | for (; it != it_end; ++it) { |
827 | *stackit++ = (*it)->getFrameWindow(); | 827 | *stackit++ = (*it)->getFrameWindow(); |
828 | 828 | ||
829 | screen->updateNetizenWindowRaise((*it)->getClientWindow()); | 829 | screen->updateNetizenWindowRaise((*it)->getClientWindow()); |
830 | 830 | ||
831 | if (! (*it)->isIconic()) { | 831 | if (! (*it)->isIconic()) { |
832 | Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); | 832 | Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); |
833 | wkspc->stackingList.remove((*it)); | 833 | wkspc->stackingList.remove((*it)); |
834 | wkspc->stackingList.push_front((*it)); | 834 | wkspc->stackingList.push_front((*it)); |
835 | } | 835 | } |
836 | 836 | ||
837 | 837 | ||
838 | } | 838 | } |
839 | 839 | ||
840 | it = w.getTransients().begin(); | 840 | it = w.getTransients().begin(); |
841 | for (; it != it_end; ++it) | 841 | for (; it != it_end; ++it) |
842 | raiseAndFillStack(stackit, *(*it)); | 842 | raiseAndFillStack(stackit, *(*it)); |
843 | 843 | ||
844 | 844 | ||
845 | } | 845 | } |
846 | 846 | ||
847 | void Workspace::lowerAndFillStack(Stack::iterator &stackit, const FluxboxWindow &win) { | 847 | void Workspace::lowerAndFillStack(Stack::iterator &stackit, const FluxboxWindow &win) { |
848 | if (win.getTransients().empty()) // nothing to lower and stack | 848 | if (win.getTransients().empty()) // nothing to lower and stack |
849 | return; | 849 | return; |
850 | 850 | ||
851 | std::list<FluxboxWindow *>::const_reverse_iterator it = win.getTransients().rbegin(); | 851 | std::list<FluxboxWindow *>::const_reverse_iterator it = win.getTransients().rbegin(); |
852 | std::list<FluxboxWindow *>::const_reverse_iterator it_end = win.getTransients().rend(); | 852 | std::list<FluxboxWindow *>::const_reverse_iterator it_end = win.getTransients().rend(); |
853 | for (; it != it_end; ++it) | 853 | for (; it != it_end; ++it) |
854 | lowerAndFillStack(stackit, *(*it)); | 854 | lowerAndFillStack(stackit, *(*it)); |
855 | 855 | ||
856 | it = win.getTransients().rbegin(); | 856 | it = win.getTransients().rbegin(); |
857 | 857 | ||
858 | for (; it != it_end; ++it) { | 858 | for (; it != it_end; ++it) { |
859 | (*stackit) = (*it)->getFrameWindow(); | 859 | (*stackit) = (*it)->getFrameWindow(); |
860 | ++stackit; | 860 | ++stackit; |
861 | screen->updateNetizenWindowLower((*it)->getClientWindow()); | 861 | screen->updateNetizenWindowLower((*it)->getClientWindow()); |
862 | if (! (*it)->isIconic()) { | 862 | if (! (*it)->isIconic()) { |
863 | Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); | 863 | Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber()); |
864 | wkspc->stackingList.remove((*it)); | 864 | wkspc->stackingList.remove((*it)); |
865 | wkspc->stackingList.push_back((*it)); | 865 | wkspc->stackingList.push_back((*it)); |
866 | } | 866 | } |
867 | } | 867 | } |
868 | 868 | ||
869 | } | 869 | } |