diff options
author | fluxgen <fluxgen> | 2003-04-14 15:01:55 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-04-14 15:01:55 (GMT) |
commit | 2928b32f3a399527113325de3db39cd75db4ee8e (patch) | |
tree | 53c9d8e3676e35a200314df700344ef2711fb7b4 /src/Workspace.cc | |
parent | b6ca956c821e1e968dda10ee7852c6933b549b08 (diff) | |
download | fluxbox_pavel-2928b32f3a399527113325de3db39cd75db4ee8e.zip fluxbox_pavel-2928b32f3a399527113325de3db39cd75db4ee8e.tar.bz2 |
merged with embedded-tab-branch
Diffstat (limited to 'src/Workspace.cc')
-rw-r--r-- | src/Workspace.cc | 474 |
1 files changed, 179 insertions, 295 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc index 6b79c19..2d95c77 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc | |||
@@ -1,5 +1,5 @@ | |||
1 | // Workspace.cc for Fluxbox | 1 | // Workspace.cc for Fluxbox |
2 | // Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) | 2 | // Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen[at]users.sourceforge.net) |
3 | // | 3 | // |
4 | // Workspace.cc for Blackbox - an X11 Window manager | 4 | // Workspace.cc for Blackbox - an X11 Window manager |
5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) | 5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) |
@@ -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.50 2003/02/20 21:00:29 fluxgen Exp $ | 25 | // $Id: Workspace.cc,v 1.51 2003/04/14 14:59:15 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Workspace.hh" | 27 | #include "Workspace.hh" |
28 | 28 | ||
@@ -32,6 +32,7 @@ | |||
32 | #include "Window.hh" | 32 | #include "Window.hh" |
33 | #include "StringUtil.hh" | 33 | #include "StringUtil.hh" |
34 | #include "SimpleCommand.hh" | 34 | #include "SimpleCommand.hh" |
35 | #include "WinClient.hh" | ||
35 | 36 | ||
36 | // use GNU extensions | 37 | // use GNU extensions |
37 | #ifndef _GNU_SOURCE | 38 | #ifndef _GNU_SOURCE |
@@ -50,6 +51,7 @@ | |||
50 | 51 | ||
51 | #include <algorithm> | 52 | #include <algorithm> |
52 | #include <iostream> | 53 | #include <iostream> |
54 | #include <iterator> | ||
53 | 55 | ||
54 | using namespace std; | 56 | using namespace std; |
55 | 57 | ||
@@ -68,24 +70,42 @@ int countTransients(const FluxboxWindow &win) { | |||
68 | return ret; | 70 | return ret; |
69 | } | 71 | } |
70 | 72 | ||
71 | class RaiseFocusAndSetWorkspace: public FbTk::Command { | 73 | class ClientMenuItem:public FbTk::MenuItem { |
72 | public: | 74 | public: |
73 | RaiseFocusAndSetWorkspace(Workspace &space, FluxboxWindow &win): | 75 | ClientMenuItem(WinClient &client, Workspace &space): |
74 | m_space(space), m_win(win) { } | 76 | FbTk::MenuItem(client.title().c_str()), |
75 | void execute() { | 77 | m_client(client), m_space(space) { |
78 | |||
79 | } | ||
80 | void click(int button, int time) { | ||
81 | if (m_client.fbwindow() == 0) | ||
82 | return; | ||
83 | FluxboxWindow &win = *m_client.fbwindow(); | ||
84 | BScreen &scr = win.getScreen(); | ||
76 | // determine workspace change | 85 | // determine workspace change |
77 | for (size_t i=0; i<m_space.getScreen().getCount(); i++) { | 86 | for (size_t i=0; i<scr.getCount(); i++) { |
78 | if (m_space.getScreen().getWorkspace(i) == &m_space) { | 87 | if (scr.getWorkspace(i) == &m_space) { |
79 | m_space.getScreen().changeWorkspaceID(i); | 88 | scr.changeWorkspaceID(i); |
80 | break; | 89 | break; |
81 | } | 90 | } |
82 | } | 91 | } |
83 | 92 | ||
84 | m_win.raiseAndFocus(); | 93 | win.setCurrentClient(m_client); |
94 | win.raiseAndFocus(); | ||
95 | } | ||
96 | |||
97 | const std::string &label() const { return m_client.title(); } | ||
98 | bool isSelected() const { | ||
99 | if (m_client.fbwindow() == 0) | ||
100 | return false; | ||
101 | if (m_client.fbwindow()->isFocused() == false) | ||
102 | return false; | ||
103 | return (&(m_client.fbwindow()->winClient()) == &m_client); | ||
104 | |||
85 | } | 105 | } |
86 | private: | 106 | private: |
107 | WinClient &m_client; | ||
87 | Workspace &m_space; | 108 | Workspace &m_space; |
88 | FluxboxWindow &m_win; | ||
89 | }; | 109 | }; |
90 | 110 | ||
91 | }; | 111 | }; |
@@ -119,15 +139,18 @@ void Workspace::setLastFocusedWindow(FluxboxWindow *win) { | |||
119 | lastfocus = 0; | 139 | lastfocus = 0; |
120 | } | 140 | } |
121 | 141 | ||
122 | int Workspace::addWindow(FluxboxWindow *w, bool place) { | 142 | int Workspace::addWindow(FluxboxWindow &w, bool place) { |
123 | if (w == 0) | 143 | // we don't need to add a window that already exist in our list |
144 | if (find(m_windowlist.begin(), m_windowlist.end(), &w) != | ||
145 | m_windowlist.end()) | ||
124 | return -1; | 146 | return -1; |
125 | 147 | ||
148 | w.setWorkspace(m_id); | ||
149 | w.setWindowNumber(m_windowlist.size()); | ||
150 | |||
126 | if (place) | 151 | if (place) |
127 | placeWindow(w); | 152 | placeWindow(w); |
128 | 153 | ||
129 | w->setWorkspace(m_id); | ||
130 | w->setWindowNumber(m_windowlist.size()); | ||
131 | 154 | ||
132 | //insert window after the currently focused window | 155 | //insert window after the currently focused window |
133 | //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); | 156 | //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); |
@@ -168,18 +191,19 @@ int Workspace::addWindow(FluxboxWindow *w, bool place) { | |||
168 | m_windowlist.insert(insert_point_it, w); | 191 | m_windowlist.insert(insert_point_it, w); |
169 | else // we didn't find it, so we just add it to stack | 192 | else // we didn't find it, so we just add it to stack |
170 | */ | 193 | */ |
171 | m_windowlist.push_back(w); | 194 | m_windowlist.push_back(&w); |
172 | updateClientmenu(); | 195 | updateClientmenu(); |
173 | 196 | ||
174 | 197 | ||
175 | if (!w->isStuck()) | 198 | if (!w.isStuck()) |
176 | screen.updateNetizenWindowAdd(w->getClientWindow(), m_id); | 199 | screen.updateNetizenWindowAdd(w.getClientWindow(), m_id); |
177 | 200 | ||
178 | return w->getWindowNumber(); | 201 | return w.getWindowNumber(); |
179 | } | 202 | } |
180 | 203 | ||
181 | 204 | ||
182 | int Workspace::removeWindow(FluxboxWindow *w) { | 205 | int Workspace::removeWindow(FluxboxWindow *w) { |
206 | |||
183 | if (w == 0) | 207 | if (w == 0) |
184 | return -1; | 208 | return -1; |
185 | 209 | ||
@@ -200,38 +224,38 @@ int Workspace::removeWindow(FluxboxWindow *w) { | |||
200 | // it gets the next item down, then scans through our windowlist to see if it is | 224 | // it gets the next item down, then scans through our windowlist to see if it is |
201 | // in this workspace. If not, goes down more | 225 | // in this workspace. If not, goes down more |
202 | /* //!! TODO! FbTk::XLayerItem *item = 0, *lastitem = w->getLayerItem(); | 226 | /* //!! TODO! FbTk::XLayerItem *item = 0, *lastitem = w->getLayerItem(); |
203 | do { | 227 | do { |
204 | item = m_layermanager.getItemBelow(*lastitem); | 228 | item = m_layermanager.getItemBelow(*lastitem); |
205 | Windows::iterator it = m_windowlist.begin(); | 229 | Windows::iterator it = m_windowlist.begin(); |
206 | Windows::iterator it_end = m_windowlist.end(); | 230 | Windows::iterator it_end = m_windowlist.end(); |
207 | for (; it != it_end; ++it) { | 231 | for (; it != it_end; ++it) { |
208 | if ((*it)->getLayerItem() == item) { | 232 | if ((*it)->getLayerItem() == item) { |
209 | // found one! | 233 | // found one! |
210 | top = *it; | 234 | top = *it; |
211 | } | 235 | } |
212 | } | 236 | } |
213 | 237 | ||
214 | lastitem = item; | 238 | lastitem = item; |
215 | 239 | ||
216 | } while (item && !top); | 240 | } while (item && !top); |
217 | 241 | ||
218 | if (!top) { | 242 | if (!top) { |
219 | // look upwards | 243 | // look upwards |
220 | lastitem = w->getLayerItem(); | 244 | lastitem = w->getLayerItem(); |
221 | do { | 245 | do { |
222 | item = m_layermanager.getItemAbove(*lastitem); | 246 | item = m_layermanager.getItemAbove(*lastitem); |
223 | Windows::iterator it = m_windowlist.begin(); | 247 | Windows::iterator it = m_windowlist.begin(); |
224 | Windows::iterator it_end = m_windowlist.end(); | 248 | Windows::iterator it_end = m_windowlist.end(); |
225 | for (; it != it_end; ++it) { | 249 | for (; it != it_end; ++it) { |
226 | if ((*it)->getLayerItem() == item) { | 250 | if ((*it)->getLayerItem() == item) { |
227 | // found one! | 251 | // found one! |
228 | top = *it; | 252 | top = *it; |
229 | } | 253 | } |
230 | } | 254 | } |
231 | lastitem = item; | 255 | lastitem = item; |
232 | } while (item && !top); | 256 | } while (item && !top); |
233 | 257 | ||
234 | } | 258 | } |
235 | */ | 259 | */ |
236 | if (top == 0|| !top->setInputFocus()) { | 260 | if (top == 0|| !top->setInputFocus()) { |
237 | Fluxbox::instance()->setFocusedWindow(0); // set focused window to none | 261 | Fluxbox::instance()->setFocusedWindow(0); // set focused window to none |
@@ -240,34 +264,32 @@ int Workspace::removeWindow(FluxboxWindow *w) { | |||
240 | } | 264 | } |
241 | 265 | ||
242 | // we don't remove it from the layermanager, as it may be being moved | 266 | // we don't remove it from the layermanager, as it may be being moved |
267 | Windows::iterator erase_it = remove(m_windowlist.begin(), | ||
268 | m_windowlist.end(), w); | ||
269 | if (erase_it != m_windowlist.end()) | ||
270 | m_windowlist.erase(erase_it); | ||
243 | 271 | ||
244 | Windows::iterator it = m_windowlist.begin(); | ||
245 | Windows::iterator it_end = m_windowlist.end(); | ||
246 | for (; it != it_end; ++it) { | ||
247 | if (*it == w) { | ||
248 | m_windowlist.erase(it); | ||
249 | break; | ||
250 | } | ||
251 | } | ||
252 | updateClientmenu(); | 272 | updateClientmenu(); |
253 | 273 | ||
254 | if (!w->isStuck()) | ||
255 | screen.updateNetizenWindowDel(w->getClientWindow()); | ||
256 | |||
257 | { | ||
258 | Windows::iterator it = m_windowlist.begin(); | ||
259 | Windows::const_iterator it_end = m_windowlist.end(); | ||
260 | for (int i = 0; it != it_end; ++it, ++i) { | ||
261 | (*it)->setWindowNumber(i); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | if (lastfocus == w || m_windowlist.empty()) | 274 | if (lastfocus == w || m_windowlist.empty()) |
266 | lastfocus = 0; | 275 | lastfocus = 0; |
267 | 276 | ||
268 | return m_windowlist.size(); | 277 | return m_windowlist.size(); |
269 | } | 278 | } |
270 | 279 | ||
280 | void Workspace::removeWindow(WinClient &client) { | ||
281 | if (client.m_win == 0) | ||
282 | return; | ||
283 | |||
284 | if (client.m_win->numClients() == 0) { | ||
285 | Windows::iterator erase_it = remove(m_windowlist.begin(), | ||
286 | m_windowlist.end(), client.m_win); | ||
287 | if (erase_it != m_windowlist.end()) | ||
288 | m_windowlist.erase(erase_it); | ||
289 | } | ||
290 | |||
291 | updateClientmenu(); | ||
292 | } | ||
271 | 293 | ||
272 | void Workspace::showAll() { | 294 | void Workspace::showAll() { |
273 | Windows::iterator it = m_windowlist.begin(); | 295 | Windows::iterator it = m_windowlist.begin(); |
@@ -375,16 +397,7 @@ void Workspace::checkGrouping(FluxboxWindow &win) { | |||
375 | // make sure the window is groupable | 397 | // make sure the window is groupable |
376 | if ( !(*wit)->isGroupable()) | 398 | if ( !(*wit)->isGroupable()) |
377 | break; // try next name | 399 | break; // try next name |
378 | //toggle tab on | 400 | cerr<<__FILE__<<"("<<__FUNCTION__<<") TODO attach client here!"<<endl; |
379 | if ((*wit)->getTab() == 0) | ||
380 | (*wit)->setTab(true); | ||
381 | if (win.getTab() == 0) | ||
382 | win.setTab(true); | ||
383 | // did we succefully set the tab? | ||
384 | if ((*wit)->getTab() == 0) | ||
385 | break; // try another window | ||
386 | (*wit)->getTab()->insert(win.getTab()); | ||
387 | |||
388 | return; // grouping done | 401 | return; // grouping done |
389 | } | 402 | } |
390 | } | 403 | } |
@@ -438,7 +451,8 @@ void Workspace::setName(const std::string &name) { | |||
438 | char tname[128]; | 451 | char tname[128]; |
439 | sprintf(tname, I18n::instance()-> | 452 | sprintf(tname, I18n::instance()-> |
440 | getMessage( | 453 | getMessage( |
441 | FBNLS::WorkspaceSet, FBNLS::WorkspaceDefaultNameFormat, | 454 | FBNLS::WorkspaceSet, |
455 | FBNLS::WorkspaceDefaultNameFormat, | ||
442 | "Workspace %d"), m_id + 1); //m_id starts at 0 | 456 | "Workspace %d"), m_id + 1); //m_id starts at 0 |
443 | m_name = tname; | 457 | m_name = tname; |
444 | } | 458 | } |
@@ -455,161 +469,103 @@ void Workspace::setName(const std::string &name) { | |||
455 | clears the m_windowlist | 469 | clears the m_windowlist |
456 | */ | 470 | */ |
457 | void Workspace::shutdown() { | 471 | void Workspace::shutdown() { |
472 | #ifdef DEBUG | ||
473 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): windowlist:"<<endl; | ||
474 | copy(m_windowlist.begin(), m_windowlist.end(), | ||
475 | ostream_iterator<FluxboxWindow *>(cerr, " \n")); | ||
476 | cerr<<endl; | ||
477 | #endif // DEBUG | ||
458 | // note: when the window dies it'll remove it self from the list | 478 | // note: when the window dies it'll remove it self from the list |
459 | while (!m_windowlist.empty()) { | 479 | while (!m_windowlist.empty()) { |
460 | m_windowlist.back()->restore(true); // restore with remap | 480 | // restore with remap on all clients in that window |
461 | delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist) | 481 | m_windowlist.back()->restore(true); |
482 | //delete window (the window removes it self from m_windowlist) | ||
483 | delete m_windowlist.back(); | ||
462 | } | 484 | } |
463 | } | 485 | } |
464 | 486 | ||
465 | void Workspace::updateClientmenu() { | 487 | void Workspace::updateClientmenu() { |
488 | // remove all items and then add them again | ||
466 | m_clientmenu.removeAll(); | 489 | m_clientmenu.removeAll(); |
490 | // for each fluxboxwindow add every client in them to our clientlist | ||
467 | Windows::iterator win_it = m_windowlist.begin(); | 491 | Windows::iterator win_it = m_windowlist.begin(); |
468 | Windows::iterator win_it_end = m_windowlist.end(); | 492 | Windows::iterator win_it_end = m_windowlist.end(); |
469 | for (; win_it != win_it_end; ++win_it) { | 493 | for (; win_it != win_it_end; ++win_it) { |
470 | FbTk::RefCount<FbTk::Command> | 494 | // add every client in this fluxboxwindow to menu |
471 | raise_and_focus(new RaiseFocusAndSetWorkspace(*this, *(*win_it))); | 495 | FluxboxWindow::ClientList::iterator client_it = |
472 | 496 | (*win_it)->clientList().begin(); | |
473 | m_clientmenu.insert((*win_it)->getTitle().c_str(), raise_and_focus); | 497 | FluxboxWindow::ClientList::iterator client_it_end = |
498 | (*win_it)->clientList().end(); | ||
499 | for (; client_it != client_it_end; ++client_it) { | ||
500 | /* FbTk::RefCount<FbTk::Command> | ||
501 | raise_and_focus(new RaiseFocusAndSetWorkspace(*this, | ||
502 | *(*client_it))); | ||
503 | */ | ||
504 | m_clientmenu.insert(new ClientMenuItem(*(*client_it), *this)); | ||
505 | } | ||
474 | } | 506 | } |
507 | |||
475 | m_clientmenu.update(); | 508 | m_clientmenu.update(); |
476 | } | 509 | } |
477 | 510 | ||
478 | void Workspace::placeWindow(FluxboxWindow *win) { | 511 | void Workspace::placeWindow(FluxboxWindow &win) { |
479 | Bool placed = False; | 512 | |
480 | int borderWidth4x = screen.getBorderWidth2x() * 2, | 513 | bool placed = false; |
481 | 514 | ||
482 | place_x = 0, place_y = 0, change_x = 1, change_y = 1; | 515 | int place_x = 0, place_y = 0, change_x = 1, change_y = 1; |
483 | 516 | ||
484 | if (screen.getColPlacementDirection() == BScreen::BOTTOMTOP) | 517 | if (screen.getColPlacementDirection() == BScreen::BOTTOMTOP) |
485 | change_y = -1; | 518 | change_y = -1; |
486 | if (screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) | 519 | if (screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) |
487 | change_x = -1; | 520 | change_x = -1; |
488 | 521 | ||
489 | #ifdef XINERAMA | ||
490 | int head = 0, | ||
491 | head_x = 0, | ||
492 | head_y = 0; | ||
493 | int head_w, head_h; | ||
494 | if (screen.hasXinerama()) { | ||
495 | head = screen.getCurrHead(); | ||
496 | head_x = screen.getHeadX(head); | ||
497 | head_y = screen.getHeadY(head); | ||
498 | head_w = screen.getHeadWidth(head); | ||
499 | head_h = screen.getHeadHeight(head); | ||
500 | |||
501 | } else { // no xinerama | ||
502 | head_w = screen.getWidth(); | ||
503 | head_h = screen.getHeight(); | ||
504 | } | ||
505 | |||
506 | #endif // XINERAMA | ||
507 | 522 | ||
508 | int win_w = win->getWidth() + screen.getBorderWidth2x(), | 523 | int win_w = win.getWidth() + screen.getBorderWidth2x(), |
509 | win_h = win->getHeight() + screen.getBorderWidth2x(); | 524 | win_h = win.getHeight() + screen.getBorderWidth2x(); |
510 | 525 | ||
511 | if (win->hasTab()) { | 526 | int test_x, test_y, curr_x, curr_y, curr_w, curr_h; |
512 | if ((! win->isShaded()) && | ||
513 | screen.getTabPlacement() == Tab::PLEFT || | ||
514 | screen.getTabPlacement() == Tab::PRIGHT) | ||
515 | win_w += (screen.isTabRotateVertical()) | ||
516 | ? screen.getTabHeight() | ||
517 | : screen.getTabWidth(); | ||
518 | else // tab placement top or bottom or win is shaded | ||
519 | win_h += screen.getTabHeight(); | ||
520 | } | ||
521 | |||
522 | register int test_x, test_y, curr_x, curr_y, curr_w, curr_h; | ||
523 | 527 | ||
524 | switch (screen.getPlacementPolicy()) { | 528 | switch (screen.getPlacementPolicy()) { |
525 | case BScreen::ROWSMARTPLACEMENT: { | 529 | case BScreen::ROWSMARTPLACEMENT: { |
526 | #ifdef XINERAMA | 530 | |
527 | test_y = head_y; | ||
528 | #else // !XINERAMA | ||
529 | test_y = 0; | 531 | test_y = 0; |
530 | #endif // XINERAMA | 532 | |
531 | if (screen.getColPlacementDirection() == BScreen::BOTTOMTOP) | 533 | if (screen.getColPlacementDirection() == BScreen::BOTTOMTOP) |
532 | #ifdef XINERAMA | 534 | test_y = screen.getHeight() - win_h - test_y; |
533 | test_y = (head_y + head_h) - win_h - test_y; | 535 | |
534 | #else // !XINERAMA | ||
535 | test_y = screen.getHeight() - win_h - test_y; | ||
536 | #endif // XINERAMA | ||
537 | 536 | ||
538 | while (((screen.getColPlacementDirection() == BScreen::BOTTOMTOP) ? | 537 | while (((screen.getColPlacementDirection() == BScreen::BOTTOMTOP) ? |
539 | #ifdef XINERAMA | 538 | test_y > 0 : test_y + win_h < (signed) screen.getHeight()) && |
540 | test_y >= head_y : test_y + win_h <= (head_y + head_h) | 539 | ! placed) { |
541 | #else // !XINERAMA | 540 | |
542 | test_y > 0 : test_y + win_h < (signed) screen.getHeight() | ||
543 | #endif // XINERAMA | ||
544 | ) && ! placed) { | ||
545 | |||
546 | #ifdef XINERAMA | ||
547 | test_x = head_x; | ||
548 | #else // !XINERAMA | ||
549 | test_x = 0; | 541 | test_x = 0; |
550 | #endif // XINERAMA | 542 | |
551 | if (screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) | 543 | if (screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) |
552 | #ifdef XINERAMA | 544 | test_x = screen.getWidth() - win_w - test_x; |
553 | test_x = (head_x + head_w) - win_w - test_x; | 545 | |
554 | #else // !XINERAMA | ||
555 | test_x = screen.getWidth() - win_w - test_x; | ||
556 | #endif // XINERAMA | ||
557 | 546 | ||
558 | while (((screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) ? | 547 | while (((screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) ? |
559 | #ifdef XINERAMA | 548 | test_x > 0 : test_x + win_w < (signed) screen.getWidth()) && ! placed) { |
560 | test_x >= head_x : test_x + win_w <= (head_x + head_w) | ||
561 | #else // !XINERAMA | ||
562 | test_x > 0 : test_x + win_w < (signed) screen.getWidth() | ||
563 | #endif // XINERAMA | ||
564 | ) && ! placed) { | ||
565 | 549 | ||
566 | placed = True; | 550 | placed = true; |
567 | 551 | ||
568 | Windows::iterator it = m_windowlist.begin(); | 552 | Windows::iterator win_it = m_windowlist.begin(); |
569 | Windows::iterator it_end = m_windowlist.end(); | 553 | const Windows::iterator win_it_end = m_windowlist.end(); |
570 | 554 | ||
571 | for (; it != it_end && placed; ++it) { | 555 | for (; win_it != win_it_end && placed; ++win_it) { |
572 | curr_x = (*it)->getXFrame(); | 556 | FluxboxWindow &window = **win_it; |
573 | curr_y = (*it)->getYFrame(); | 557 | |
574 | curr_w = (*it)->getWidth() + screen.getBorderWidth2x(); | 558 | curr_x = window.getXFrame(); |
575 | curr_h = | 559 | curr_y = window.getYFrame(); |
576 | (((*it)->isShaded()) | 560 | curr_w = window.getWidth() + screen.getBorderWidth2x(); |
577 | ? (*it)->getTitleHeight() | 561 | curr_h = window.isShaded() ? window.getTitleHeight() : |
578 | : (*it)->getHeight()) + | 562 | window.getHeight() + screen.getBorderWidth2x(); |
579 | screen.getBorderWidth2x(); | ||
580 | |||
581 | if ((*it)->hasTab()) { | ||
582 | if (! (*it)->isShaded()) { // not shaded window | ||
583 | switch(screen.getTabPlacement()) { | ||
584 | case Tab::PTOP: | ||
585 | curr_y -= screen.getTabHeight(); | ||
586 | case Tab::PBOTTOM: | ||
587 | curr_h += screen.getTabHeight(); | ||
588 | break; | ||
589 | case Tab::PLEFT: | ||
590 | curr_x -= (screen.isTabRotateVertical()) | ||
591 | ? screen.getTabHeight() | ||
592 | : screen.getTabWidth(); | ||
593 | case Tab::PRIGHT: | ||
594 | curr_w += (screen.isTabRotateVertical()) | ||
595 | ? screen.getTabHeight() | ||
596 | : screen.getTabWidth(); | ||
597 | break; | ||
598 | case Tab::PNONE: | ||
599 | break; | ||
600 | } | ||
601 | } else { // shaded window | ||
602 | if (screen.getTabPlacement() == Tab::PTOP) | ||
603 | curr_y -= screen.getTabHeight(); | ||
604 | curr_h += screen.getTabHeight(); | ||
605 | } | ||
606 | } // tab cheking done | ||
607 | 563 | ||
608 | if (curr_x < test_x + win_w && | 564 | if (curr_x < test_x + win_w && |
609 | curr_x + curr_w > test_x && | 565 | curr_x + curr_w > test_x && |
610 | curr_y < test_y + win_h && | 566 | curr_y < test_y + win_h && |
611 | curr_y + curr_h > test_y) { | 567 | curr_y + curr_h > test_y) { |
612 | placed = False; | 568 | placed = false; |
613 | } | 569 | } |
614 | } | 570 | } |
615 | 571 | ||
@@ -622,53 +578,33 @@ void Workspace::placeWindow(FluxboxWindow *win) { | |||
622 | } | 578 | } |
623 | 579 | ||
624 | test_x += change_x; | 580 | test_x += change_x; |
625 | } | 581 | } // end while |
626 | 582 | ||
627 | test_y += change_y; | 583 | test_y += change_y; |
628 | } | 584 | } // end while |
629 | 585 | ||
630 | break; } | 586 | break; |
587 | } // end case ROWSMARTPLACEMENT | ||
631 | 588 | ||
632 | case BScreen::COLSMARTPLACEMENT: { | 589 | case BScreen::COLSMARTPLACEMENT: { |
633 | #ifdef XINERAMA | ||
634 | test_x = head_x; | ||
635 | #else // !XINERAMA | ||
636 | test_x = 0; | 590 | test_x = 0; |
637 | #endif // XINERAMA | 591 | |
638 | if (screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) | 592 | if (screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) |
639 | #ifdef XINERAMA | 593 | |
640 | test_x = (head_x + head_w) - win_w - test_x; | 594 | test_x = screen.getWidth() - win_w - test_x; |
641 | #else // !XINERAMA | 595 | |
642 | test_x = screen.getWidth() - win_w - test_x; | ||
643 | #endif // XINERAMA | ||
644 | 596 | ||
645 | while (((screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) ? | 597 | while (((screen.getRowPlacementDirection() == BScreen::RIGHTLEFT) ? |
646 | #ifdef XINERAMA | 598 | test_x > 0 : test_x + win_w < (signed) screen.getWidth()) && |
647 | test_x >= 0 : test_x + win_w <= (head_x + head_w) | 599 | !placed) { |
648 | #else // !XINERAMA | 600 | |
649 | test_x > 0 : test_x + win_w < (signed) screen.getWidth() | ||
650 | #endif // XINERAMA | ||
651 | ) && ! placed) { | ||
652 | |||
653 | #ifdef XINERAMA | ||
654 | test_y = head_y; | ||
655 | #else // !XINERAMA | ||
656 | test_y = 0; | 601 | test_y = 0; |
657 | #endif // XINERAMA | ||
658 | if (screen.getColPlacementDirection() == BScreen::BOTTOMTOP) | 602 | if (screen.getColPlacementDirection() == BScreen::BOTTOMTOP) |
659 | #ifdef XINERAMA | 603 | test_y = screen.getHeight() - win_h - test_y; |
660 | test_y = (head_y + head_h) - win_h - test_y; | ||
661 | #else // !XINERAMA | ||
662 | test_y = screen.getHeight() - win_h - test_y; | ||
663 | #endif // XINERAMA | ||
664 | 604 | ||
665 | while (((screen.getColPlacementDirection() == BScreen::BOTTOMTOP) ? | 605 | while (((screen.getColPlacementDirection() == BScreen::BOTTOMTOP) ? |
666 | #ifdef XINERAMA | 606 | test_y > 0 : test_y + win_h < (signed) screen.getHeight()) && |
667 | test_y >= head_y : test_y + win_h <= (head_y + head_h) | 607 | !placed) { |
668 | #else // !XINERAMA | ||
669 | test_y > 0 : test_y + win_h < (signed) screen.getHeight() | ||
670 | #endif // XINERAMA | ||
671 | ) && ! placed) { | ||
672 | placed = True; | 608 | placed = True; |
673 | 609 | ||
674 | Windows::iterator it = m_windowlist.begin(); | 610 | Windows::iterator it = m_windowlist.begin(); |
@@ -683,36 +619,6 @@ void Workspace::placeWindow(FluxboxWindow *win) { | |||
683 | : (*it)->getHeight()) + | 619 | : (*it)->getHeight()) + |
684 | screen.getBorderWidth2x();; | 620 | screen.getBorderWidth2x();; |
685 | 621 | ||
686 | if ((*it)->hasTab()) { | ||
687 | if (! (*it)->isShaded()) { // not shaded window | ||
688 | switch(screen.getTabPlacement()) { | ||
689 | case Tab::PTOP: | ||
690 | curr_y -= screen.getTabHeight(); | ||
691 | case Tab::PBOTTOM: | ||
692 | curr_h += screen.getTabHeight(); | ||
693 | break; | ||
694 | case Tab::PLEFT: | ||
695 | curr_x -= (screen.isTabRotateVertical()) | ||
696 | ? screen.getTabHeight() | ||
697 | : screen.getTabWidth(); | ||
698 | case Tab::PRIGHT: | ||
699 | curr_w += (screen.isTabRotateVertical()) | ||
700 | ? screen.getTabHeight() | ||
701 | : screen.getTabWidth(); | ||
702 | break; | ||
703 | default: | ||
704 | #ifdef DEBUG | ||
705 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | ||
706 | "Unsupported Placement" << endl; | ||
707 | #endif // DEBUG | ||
708 | break; | ||
709 | } | ||
710 | } else { // shaded window | ||
711 | if (screen.getTabPlacement() == Tab::PTOP) | ||
712 | curr_y -= screen.getTabHeight(); | ||
713 | curr_h += screen.getTabHeight(); | ||
714 | } | ||
715 | } // tab cheking done | ||
716 | 622 | ||
717 | if (curr_x < test_x + win_w && | 623 | if (curr_x < test_x + win_w && |
718 | curr_x + curr_w > test_x && | 624 | curr_x + curr_w > test_x && |
@@ -729,57 +635,35 @@ void Workspace::placeWindow(FluxboxWindow *win) { | |||
729 | } | 635 | } |
730 | 636 | ||
731 | test_y += change_y; | 637 | test_y += change_y; |
732 | } | 638 | } // end while |
733 | 639 | ||
734 | test_x += change_x; | 640 | test_x += change_x; |
735 | } | 641 | } // end while |
642 | |||
643 | break; | ||
644 | } // end COLSMARTPLACEMENT | ||
736 | 645 | ||
737 | break; } | ||
738 | } | 646 | } |
739 | 647 | ||
740 | // cascade placement or smart placement failed | 648 | // cascade placement or smart placement failed |
741 | if (! placed) { | 649 | if (! placed) { |
742 | #ifdef XINERAMA | 650 | |
743 | if ((cascade_x > (head_w / 2)) || | 651 | if (((unsigned) cascade_x > (screen.getWidth() / 2)) || |
744 | (cascade_y > (head_h / 2))) | 652 | ((unsigned) cascade_y > (screen.getHeight() / 2))) |
745 | #else // !XINERAMA | 653 | cascade_x = cascade_y = 32; |
746 | if (((unsigned) cascade_x > (screen.getWidth() / 2)) || | 654 | |
747 | ((unsigned) cascade_y > (screen.getHeight() / 2))) | ||
748 | #endif // XINERAMA | ||
749 | |||
750 | cascade_x = cascade_y = 32; | ||
751 | #ifdef XINERAMA | ||
752 | place_x = head_x + cascade_x; | ||
753 | place_y = head_y + cascade_y; | ||
754 | #else // !XINERAMA | ||
755 | place_x = cascade_x; | 655 | place_x = cascade_x; |
756 | place_y = cascade_y; | 656 | place_y = cascade_y; |
757 | #endif // XINERAMA | 657 | |
758 | cascade_x += win->getTitleHeight(); | 658 | cascade_x += win.getTitleHeight(); |
759 | cascade_y += win->getTitleHeight(); | 659 | cascade_y += win.getTitleHeight(); |
760 | } | 660 | } |
761 | 661 | ||
762 | #ifdef XINERAMA | ||
763 | if (place_x + win_w > (head_x + head_w)) | ||
764 | place_x = head_x + ((head_w - win_w) / 2); | ||
765 | if (place_y + win_h > (head_y + head_h)) | ||
766 | place_y = head_y + ((head_h - win_h) / 2); | ||
767 | #else // !XINERAMA | ||
768 | if (place_x + win_w > (signed) screen.getWidth()) | 662 | if (place_x + win_w > (signed) screen.getWidth()) |
769 | place_x = (((signed) screen.getWidth()) - win_w) / 2; | 663 | place_x = (((signed) screen.getWidth()) - win_w) / 2; |
770 | if (place_y + win_h > (signed) screen.getHeight()) | 664 | if (place_y + win_h > (signed) screen.getHeight()) |
771 | place_y = (((signed) screen.getHeight()) - win_h) / 2; | 665 | place_y = (((signed) screen.getHeight()) - win_h) / 2; |
772 | #endif // XINERAMA | ||
773 | |||
774 | // fix window placement, think of tabs | ||
775 | if (win->hasTab()) { | ||
776 | if (screen.getTabPlacement() == Tab::PTOP) | ||
777 | place_y += screen.getTabHeight(); | ||
778 | else if (screen.getTabPlacement() == Tab::PLEFT) | ||
779 | place_x += (screen.isTabRotateVertical()) | ||
780 | ? screen.getTabHeight() | ||
781 | : screen.getTabWidth(); | ||
782 | } | ||
783 | 666 | ||
784 | win->moveResize(place_x, place_y, win->getWidth(), win->getHeight()); | 667 | |
668 | win.moveResize(place_x, place_y, win.getWidth(), win.getHeight()); | ||
785 | } | 669 | } |