diff options
author | fluxgen <fluxgen> | 2002-02-08 14:06:35 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-02-08 14:06:35 (GMT) |
commit | be93c21b2f271fc431f0933237bdae75d3783e03 (patch) | |
tree | d8e91a63325f260cb4c2f3b242d32104f90aed26 | |
parent | affd3c2afb1b304e470c090375d12ab56ac466da (diff) | |
download | fluxbox_lack-be93c21b2f271fc431f0933237bdae75d3783e03.zip fluxbox_lack-be93c21b2f271fc431f0933237bdae75d3783e03.tar.bz2 |
to stl
-rw-r--r-- | src/Workspace.cc | 153 | ||||
-rw-r--r-- | src/Workspace.hh | 9 |
2 files changed, 89 insertions, 73 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc index a98f970..677e697 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Workspace.cc,v 1.6 2002/01/20 02:08:12 fluxgen Exp $ | 22 | // $Id: Workspace.cc,v 1.7 2002/02/08 14:04:51 fluxgen Exp $ |
23 | 23 | ||
24 | // use GNU extensions | 24 | // use GNU extensions |
25 | #ifndef _GNU_SOURCE | 25 | #ifndef _GNU_SOURCE |
@@ -51,6 +51,8 @@ | |||
51 | #include <X11/Xlib.h> | 51 | #include <X11/Xlib.h> |
52 | #include <X11/Xatom.h> | 52 | #include <X11/Xatom.h> |
53 | 53 | ||
54 | #include <algorithm> | ||
55 | |||
54 | Workspace::Workspace(BScreen *scrn, int i): | 56 | Workspace::Workspace(BScreen *scrn, int i): |
55 | screen(scrn), | 57 | screen(scrn), |
56 | lastfocus(0), | 58 | lastfocus(0), |
@@ -63,8 +65,6 @@ cascade_x(32), cascade_y(32) | |||
63 | 65 | ||
64 | id = i; | 66 | id = i; |
65 | 67 | ||
66 | stackingList = new LinkedList<FluxboxWindow>; | ||
67 | windowList = new LinkedList<FluxboxWindow>; | ||
68 | clientmenu = new Clientmenu(this); | 68 | clientmenu = new Clientmenu(this); |
69 | 69 | ||
70 | char *tmp; | 70 | char *tmp; |
@@ -77,8 +77,6 @@ cascade_x(32), cascade_y(32) | |||
77 | 77 | ||
78 | 78 | ||
79 | Workspace::~Workspace() { | 79 | Workspace::~Workspace() { |
80 | delete stackingList; | ||
81 | delete windowList; | ||
82 | delete clientmenu; | 80 | delete clientmenu; |
83 | } | 81 | } |
84 | 82 | ||
@@ -91,10 +89,10 @@ const int Workspace::addWindow(FluxboxWindow *w, Bool place) { | |||
91 | placeWindow(w); | 89 | placeWindow(w); |
92 | 90 | ||
93 | w->setWorkspace(id); | 91 | w->setWorkspace(id); |
94 | w->setWindowNumber(windowList->count()); | 92 | w->setWindowNumber(windowList.size()); |
95 | 93 | ||
96 | stackingList->insert(w, 0); | 94 | stackingList.push_front(w); |
97 | windowList->insert(w); | 95 | windowList.push_back(w); |
98 | 96 | ||
99 | clientmenu->insert((const char **) w->getTitle()); | 97 | clientmenu->insert((const char **) w->getTitle()); |
100 | clientmenu->update(); | 98 | clientmenu->update(); |
@@ -110,7 +108,7 @@ const int Workspace::addWindow(FluxboxWindow *w, Bool place) { | |||
110 | const int Workspace::removeWindow(FluxboxWindow *w) { | 108 | const int Workspace::removeWindow(FluxboxWindow *w) { |
111 | if (! w) return -1; | 109 | if (! w) return -1; |
112 | 110 | ||
113 | stackingList->remove(w); | 111 | stackingList.remove(w); |
114 | 112 | ||
115 | if (w->isFocused()) { | 113 | if (w->isFocused()) { |
116 | if (screen->isSloppyFocus()) | 114 | if (screen->isSloppyFocus()) |
@@ -120,7 +118,7 @@ const int Workspace::removeWindow(FluxboxWindow *w) { | |||
120 | w->getTransientFor()->setInputFocus(); | 118 | w->getTransientFor()->setInputFocus(); |
121 | else { | 119 | else { |
122 | 120 | ||
123 | FluxboxWindow *top = stackingList->first(); | 121 | FluxboxWindow *top = stackingList.front(); |
124 | 122 | ||
125 | if (! top || ! top->setInputFocus()) { | 123 | if (! top || ! top->setInputFocus()) { |
126 | Fluxbox::instance()->setFocusedWindow((FluxboxWindow *) 0); | 124 | Fluxbox::instance()->setFocusedWindow((FluxboxWindow *) 0); |
@@ -134,45 +132,49 @@ const int Workspace::removeWindow(FluxboxWindow *w) { | |||
134 | if (lastfocus == w) | 132 | if (lastfocus == w) |
135 | lastfocus = (FluxboxWindow *) 0; | 133 | lastfocus = (FluxboxWindow *) 0; |
136 | 134 | ||
137 | windowList->remove(w->getWindowNumber()); | 135 | windowList.erase(windowList.begin() + w->getWindowNumber()); |
138 | clientmenu->remove(w->getWindowNumber()); | 136 | clientmenu->remove(w->getWindowNumber()); |
139 | clientmenu->update(); | 137 | clientmenu->update(); |
140 | 138 | ||
141 | screen->updateNetizenWindowDel(w->getClientWindow()); | 139 | screen->updateNetizenWindowDel(w->getClientWindow()); |
142 | 140 | ||
143 | LinkedListIterator<FluxboxWindow> it(windowList); | 141 | { |
144 | for (int i = 0; it.current(); it++, i++) | 142 | Windows::iterator it = windowList.begin(); |
145 | it.current()->setWindowNumber(i); | 143 | Windows::const_iterator it_end = windowList.end(); |
144 | for (int i = 0; it != it_end; ++it, ++i) { | ||
145 | (*it)->setWindowNumber(i); | ||
146 | } | ||
147 | } | ||
146 | 148 | ||
147 | return windowList->count(); | 149 | return windowList.size(); |
148 | } | 150 | } |
149 | 151 | ||
150 | 152 | ||
151 | void Workspace::showAll(void) { | 153 | void Workspace::showAll(void) { |
152 | LinkedListIterator<FluxboxWindow> it(stackingList); | 154 | WindowStack::iterator it = stackingList.begin(); |
153 | for (; it.current(); it++) | 155 | WindowStack::iterator it_end = stackingList.end(); |
154 | it.current()->deiconify(False, False); | 156 | for (; it != it_end; ++it) { |
157 | (*it)->deiconify(False, False); | ||
158 | } | ||
155 | } | 159 | } |
156 | 160 | ||
157 | 161 | ||
158 | void Workspace::hideAll(void) { | 162 | void Workspace::hideAll(void) { |
159 | LinkedList<FluxboxWindow> lst; | 163 | WindowStack::reverse_iterator it = stackingList.rbegin(); |
160 | 164 | WindowStack::reverse_iterator it_end = stackingList.rend(); | |
161 | LinkedListIterator<FluxboxWindow> it(stackingList); | 165 | for (; it != it_end; ++it) { |
162 | for (; it.current(); it++) | 166 | if (! (*it)->isStuck()) |
163 | lst.insert(it.current(), 0); | 167 | (*it)->withdraw(); |
164 | 168 | } | |
165 | LinkedListIterator<FluxboxWindow> it2(&lst); | ||
166 | for (; it2.current(); it2++) | ||
167 | if (! it2.current()->isStuck()) | ||
168 | it2.current()->withdraw(); | ||
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void Workspace::removeAll(void) { | 172 | void Workspace::removeAll(void) { |
173 | LinkedListIterator<FluxboxWindow> it(windowList); | 173 | Windows::iterator it = windowList.begin(); |
174 | for (; it.current(); it++) | 174 | Windows::const_iterator it_end = windowList.end(); |
175 | it.current()->iconify(); | 175 | for (; it != it_end; ++it) { |
176 | (*it)->iconify(); | ||
177 | } | ||
176 | } | 178 | } |
177 | 179 | ||
178 | 180 | ||
@@ -200,8 +202,8 @@ void Workspace::raiseWindow(FluxboxWindow *w) { | |||
200 | 202 | ||
201 | if (! win->isIconic()) { | 203 | if (! win->isIconic()) { |
202 | wkspc = screen->getWorkspace(win->getWorkspaceNumber()); | 204 | wkspc = screen->getWorkspace(win->getWorkspaceNumber()); |
203 | wkspc->stackingList->remove(win); | 205 | wkspc->stackingList.remove(win); |
204 | wkspc->stackingList->insert(win, 0); | 206 | wkspc->stackingList.push_front(win); |
205 | } | 207 | } |
206 | 208 | ||
207 | if (! win->hasTransient() || ! win->getTransient()) | 209 | if (! win->hasTransient() || ! win->getTransient()) |
@@ -239,8 +241,8 @@ void Workspace::lowerWindow(FluxboxWindow *w) { | |||
239 | 241 | ||
240 | if (! win->isIconic()) { | 242 | if (! win->isIconic()) { |
241 | wkspc = screen->getWorkspace(win->getWorkspaceNumber()); | 243 | wkspc = screen->getWorkspace(win->getWorkspaceNumber()); |
242 | wkspc->stackingList->remove(win); | 244 | wkspc->stackingList.remove(win); |
243 | wkspc->stackingList->insert(win); | 245 | wkspc->stackingList.push_back(win); |
244 | } | 246 | } |
245 | 247 | ||
246 | if (! win->getTransientFor()) | 248 | if (! win->getTransientFor()) |
@@ -263,23 +265,25 @@ void Workspace::lowerWindow(FluxboxWindow *w) { | |||
263 | void Workspace::reconfigure(void) { | 265 | void Workspace::reconfigure(void) { |
264 | clientmenu->reconfigure(); | 266 | clientmenu->reconfigure(); |
265 | 267 | ||
266 | LinkedListIterator<FluxboxWindow> it(windowList); | 268 | Windows::iterator it = windowList.begin(); |
267 | for (; it.current(); it++) | 269 | Windows::iterator it_end = windowList.end(); |
268 | if (it.current()->validateClient()) | 270 | for (; it != it_end; ++it) { |
269 | it.current()->reconfigure(); | 271 | if ((*it)->validateClient()) |
272 | (*it)->reconfigure(); | ||
273 | } | ||
270 | } | 274 | } |
271 | 275 | ||
272 | 276 | ||
273 | FluxboxWindow *Workspace::getWindow(int index) { | 277 | FluxboxWindow *Workspace::getWindow(int index) { |
274 | if ((index >= 0) && (index < windowList->count())) | 278 | if ((index >= 0) && (index < windowList.size())) |
275 | return windowList->find(index); | 279 | return windowList[index]; |
276 | else | 280 | else |
277 | return 0; | 281 | return 0; |
278 | } | 282 | } |
279 | 283 | ||
280 | 284 | ||
281 | const int Workspace::getCount(void) { | 285 | const int Workspace::getCount(void) { |
282 | return windowList->count(); | 286 | return windowList.size(); |
283 | } | 287 | } |
284 | 288 | ||
285 | 289 | ||
@@ -295,7 +299,7 @@ Bool Workspace::isCurrent(void) { | |||
295 | 299 | ||
296 | 300 | ||
297 | Bool Workspace::isLastWindow(FluxboxWindow *w) { | 301 | Bool Workspace::isLastWindow(FluxboxWindow *w) { |
298 | return (w == windowList->last()); | 302 | return (w == windowList.back()); |
299 | } | 303 | } |
300 | 304 | ||
301 | void Workspace::setCurrent(void) { | 305 | void Workspace::setCurrent(void) { |
@@ -328,16 +332,17 @@ void Workspace::setName(char *new_name) { | |||
328 | 332 | ||
329 | 333 | ||
330 | void Workspace::shutdown(void) { | 334 | void Workspace::shutdown(void) { |
331 | while (windowList->count()) { | 335 | Windows::iterator it = windowList.begin(); |
332 | windowList->first()->restore(); | 336 | Windows::iterator it_end= windowList.end(); |
333 | delete windowList->first(); | 337 | for (; it != it_end; ++it) { |
338 | (*it)->restore(); | ||
339 | delete (*it); | ||
334 | } | 340 | } |
335 | } | 341 | } |
336 | 342 | ||
337 | 343 | ||
338 | void Workspace::placeWindow(FluxboxWindow *win) { | 344 | void Workspace::placeWindow(FluxboxWindow *win) { |
339 | Bool placed = False; | 345 | Bool placed = False; |
340 | LinkedListIterator<FluxboxWindow> it(windowList); | ||
341 | int win_w = win->getWidth() + (screen->getBorderWidth2x() * 2), | 346 | int win_w = win->getWidth() + (screen->getBorderWidth2x() * 2), |
342 | win_h = win->getHeight() + (screen->getBorderWidth2x() * 2), | 347 | win_h = win->getHeight() + (screen->getBorderWidth2x() * 2), |
343 | #ifdef SLIT | 348 | #ifdef SLIT |
@@ -374,26 +379,29 @@ void Workspace::placeWindow(FluxboxWindow *win) { | |||
374 | ! placed) { | 379 | ! placed) { |
375 | test_x = screen->getBorderWidth() + screen->getEdgeSnapThreshold(); | 380 | test_x = screen->getBorderWidth() + screen->getEdgeSnapThreshold(); |
376 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) | 381 | if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) |
377 | test_x = screen->getWidth() - win_w - test_x; | 382 | test_x = screen->getWidth() - win_w - test_x; |
378 | 383 | ||
379 | while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? | 384 | while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ? |
380 | test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && | 385 | test_x > 0 : test_x + win_w < (signed) screen->getWidth()) && |
381 | ! placed) { | 386 | ! placed) { |
382 | placed = True; | 387 | placed = True; |
383 | 388 | ||
384 | it.reset(); | 389 | Windows::iterator it = windowList.begin(); |
385 | for (; it.current() && placed; it++) { | 390 | Windows::iterator it_end = windowList.end(); |
386 | curr_w = it.current()->getWidth() + screen->getBorderWidth2x() + | 391 | for (; it != it_end && placed; ++it) { |
392 | curr_w = (*it)->getWidth() + screen->getBorderWidth2x() + | ||
387 | screen->getBorderWidth2x(); | 393 | screen->getBorderWidth2x(); |
388 | curr_h = | 394 | curr_h = |
389 | ((it.current()->isShaded()) ? it.current()->getTitleHeight() : | 395 | (((*it)->isShaded()) |
390 | it.current()->getHeight()) + | 396 | ? (*it)->getTitleHeight() |
391 | screen->getBorderWidth2x() + screen->getBorderWidth2x(); | 397 | : (*it)->getHeight()) + |
392 | 398 | screen->getBorderWidth2x() + | |
393 | if (it.current()->getXFrame() < test_x + win_w && | 399 | screen->getBorderWidth2x(); |
394 | it.current()->getXFrame() + curr_w > test_x && | 400 | |
395 | it.current()->getYFrame() < test_y + win_h && | 401 | if ((*it)->getXFrame() < test_x + win_w && |
396 | it.current()->getYFrame() + curr_h > test_y) | 402 | (*it)->getXFrame() + curr_w > test_x && |
403 | (*it)->getYFrame() < test_y + win_h && | ||
404 | (*it)->getYFrame() + curr_h > test_y) | ||
397 | placed = False; | 405 | placed = False; |
398 | } | 406 | } |
399 | 407 | ||
@@ -436,26 +444,29 @@ void Workspace::placeWindow(FluxboxWindow *win) { | |||
436 | ! placed) { | 444 | ! placed) { |
437 | test_y = screen->getBorderWidth() + screen->getEdgeSnapThreshold(); | 445 | test_y = screen->getBorderWidth() + screen->getEdgeSnapThreshold(); |
438 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) | 446 | if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP) |
439 | test_y = screen->getHeight() - win_h - test_y; | 447 | test_y = screen->getHeight() - win_h - test_y; |
440 | 448 | ||
441 | while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? | 449 | while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ? |
442 | test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && | 450 | test_y > 0 : test_y + win_h < (signed) screen->getHeight()) && |
443 | ! placed) { | 451 | ! placed) { |
444 | placed = True; | 452 | placed = True; |
445 | 453 | ||
446 | it.reset(); | 454 | Windows::iterator it = windowList.begin(); |
447 | for (; it.current() && placed; it++) { | 455 | Windows::iterator it_end = windowList.end(); |
448 | curr_w = it.current()->getWidth() + screen->getBorderWidth2x() + | 456 | for (; it != it_end && placed; ++it) { |
457 | curr_w = (*it)->getWidth() + screen->getBorderWidth2x() + | ||
449 | screen->getBorderWidth2x(); | 458 | screen->getBorderWidth2x(); |
450 | curr_h = | 459 | curr_h = |
451 | ((it.current()->isShaded()) ? it.current()->getTitleHeight() : | 460 | (((*it)->isShaded()) |
452 | it.current()->getHeight()) + | 461 | ? (*it)->getTitleHeight() |
453 | screen->getBorderWidth2x() + screen->getBorderWidth2x(); | 462 | : (*it)->getHeight()) + |
454 | 463 | screen->getBorderWidth2x() + | |
455 | if (it.current()->getXFrame() < test_x + win_w && | 464 | screen->getBorderWidth2x(); |
456 | it.current()->getXFrame() + curr_w > test_x && | 465 | |
457 | it.current()->getYFrame() < test_y + win_h && | 466 | if ((*it)->getXFrame() < test_x + win_w && |
458 | it.current()->getYFrame() + curr_h > test_y) | 467 | (*it)->getXFrame() + curr_w > test_x && |
468 | (*it)->getYFrame() < test_y + win_h && | ||
469 | (*it)->getYFrame() + curr_h > test_y) | ||
459 | placed = False; | 470 | placed = False; |
460 | } | 471 | } |
461 | 472 | ||
diff --git a/src/Workspace.hh b/src/Workspace.hh index 9e621c3..08c5ad9 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh | |||
@@ -22,9 +22,10 @@ | |||
22 | #ifndef _WORKSPACE_HH_ | 22 | #ifndef _WORKSPACE_HH_ |
23 | #define _WORKSPACE_HH_ | 23 | #define _WORKSPACE_HH_ |
24 | 24 | ||
25 | #include "LinkedList.hh" | ||
26 | #include <X11/Xlib.h> | 25 | #include <X11/Xlib.h> |
27 | #include <string> | 26 | #include <string> |
27 | #include <vector> | ||
28 | #include <list> | ||
28 | 29 | ||
29 | class BScreen; | 30 | class BScreen; |
30 | class Clientmenu; | 31 | class Clientmenu; |
@@ -38,7 +39,11 @@ private: | |||
38 | FluxboxWindow *lastfocus; | 39 | FluxboxWindow *lastfocus; |
39 | Clientmenu *clientmenu; | 40 | Clientmenu *clientmenu; |
40 | 41 | ||
41 | LinkedList<FluxboxWindow> *stackingList, *windowList; | 42 | typedef std::list<FluxboxWindow *> WindowStack; |
43 | typedef std::vector<FluxboxWindow *> Windows; | ||
44 | |||
45 | WindowStack stackingList; | ||
46 | Windows windowList; | ||
42 | 47 | ||
43 | std::string name; | 48 | std::string name; |
44 | int id, cascade_x, cascade_y; | 49 | int id, cascade_x, cascade_y; |