summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Workspace.cc212
1 files changed, 122 insertions, 90 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc
index 531e7fb..631fe69 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.26 2002/08/31 10:40:50 fluxgen Exp $ 25// $Id: Workspace.cc,v 1.27 2002/09/08 19:38:48 fluxgen Exp $
26 26
27#include "Workspace.hh" 27#include "Workspace.hh"
28 28
@@ -55,6 +55,23 @@
55 55
56using namespace std; 56using namespace std;
57 57
58namespace { // anonymous
59
60int countTransients(const FluxboxWindow &win) {
61 if (win.getTransients().size() == 0)
62 return 0;
63 // now go throu the entire tree and count transients
64 size_t ret = win.getTransients().size();
65 std::list<FluxboxWindow *>::const_iterator it = win.getTransients().begin();
66 std::list<FluxboxWindow *>::const_iterator it_end = win.getTransients().end();
67 for (; it != it_end; ++it)
68 ret += countTransients(*(*it));
69
70 return ret;
71}
72
73};
74
58Workspace::GroupList Workspace::m_groups; 75Workspace::GroupList Workspace::m_groups;
59 76
60Workspace::Workspace(BScreen *scrn, unsigned int i): 77Workspace::Workspace(BScreen *scrn, unsigned int i):
@@ -76,7 +93,7 @@ Workspace::~Workspace() {
76 93
77 94
78int Workspace::addWindow(FluxboxWindow *w, bool place) { 95int Workspace::addWindow(FluxboxWindow *w, bool place) {
79 if (! w) 96 if (w == 0)
80 return -1; 97 return -1;
81 98
82 if (place) 99 if (place)
@@ -129,7 +146,7 @@ int Workspace::addWindow(FluxboxWindow *w, bool place) {
129 146
130 147
131int Workspace::removeWindow(FluxboxWindow *w) { 148int Workspace::removeWindow(FluxboxWindow *w) {
132 if (! w) 149 if (w == 0)
133 return -1; 150 return -1;
134 151
135 stackingList.remove(w); 152 stackingList.remove(w);
@@ -193,7 +210,11 @@ void Workspace::showAll(void) {
193 WindowStack::iterator it = stackingList.begin(); 210 WindowStack::iterator it = stackingList.begin();
194 WindowStack::iterator it_end = stackingList.end(); 211 WindowStack::iterator it_end = stackingList.end();
195 for (; it != it_end; ++it) { 212 for (; it != it_end; ++it) {
196 (*it)->deiconify(False, False); 213 if ((*it) == 0) {
214 stackingList.erase(it);
215 } else {
216 (*it)->deiconify(False, False);
217 }
197 } 218 }
198} 219}
199 220
@@ -218,52 +239,28 @@ void Workspace::removeAll(void) {
218 239
219 240
220void Workspace::raiseWindow(FluxboxWindow *w) { 241void Workspace::raiseWindow(FluxboxWindow *w) {
221 FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; 242 FluxboxWindow *win = w;
222
223 while (bottom->isTransient() && bottom->getTransientFor() &&
224 bottom->getTransientFor() != bottom) { //prevent infinite loop
225#ifdef DEBUG
226 assert(bottom != bottom->getTransientFor());
227#endif // DEBUG
228 bottom = bottom->getTransientFor();
229
230 }
231
232 int i = 1;
233 win = bottom;
234 while (win->hasTransient() && win->getTransient() &&
235 win->getTransient() != win) {//prevent infinite loop
236#ifdef DEBUG
237 assert(win != win->getTransient());
238#endif // DEBUG
239 win = win->getTransient();
240 i++;
241 }
242 243
243 Window *nstack = new Window[i], *curr = nstack; 244 while (win->isTransient() && win->getTransientFor())
244 Workspace *wkspc; 245 win = win->getTransientFor();
245 246
246 win = bottom; 247 int i = 1 + countTransients(*win);
247 while (1) {
248 *(curr++) = win->getFrameWindow();
249 screen->updateNetizenWindowRaise(win->getClientWindow());
250
251 if (! win->isIconic()) {
252 wkspc = screen->getWorkspace(win->getWorkspaceNumber());
253 wkspc->stackingList.remove(win);
254 wkspc->stackingList.push_front(win);
255 }
256
257 if (! win->hasTransient() || ! win->getTransient() ||
258 win->getTransient() == win) //prevent infinite loop
259 break;
260
261 win = win->getTransient();
262 }
263 248
264 screen->raiseWindows(nstack, i); 249 Stack nstack(i);
250 Stack::iterator stackit = nstack.begin();
251
252 *(stackit++) = win->getFrameWindow();
253 screen->updateNetizenWindowRaise(win->getClientWindow());
254 if (! win->isIconic()) {
255 Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber());
256 wkspc->stackingList.remove(win);
257 wkspc->stackingList.push_front(win);
258 }
259
260 raiseAndFillStack(stackit, *win);
265 261
266 delete [] nstack; 262 screen->raiseWindows(nstack);
263
267} 264}
268 265
269void Workspace::lowerWindow(FluxboxWindow *w) { 266void Workspace::lowerWindow(FluxboxWindow *w) {
@@ -273,43 +270,24 @@ void Workspace::lowerWindow(FluxboxWindow *w) {
273 && bottom->getTransientFor() != bottom) //prevent infinite loop 270 && bottom->getTransientFor() != bottom) //prevent infinite loop
274 bottom = bottom->getTransientFor(); 271 bottom = bottom->getTransientFor();
275 272
276 int i = 1; 273 int i = 1 + countTransients(*w);
277 win = bottom; 274 win = bottom;
278 while (win->hasTransient() && win->getTransient() &&
279 win->getTransient() != win) { //prevent infinite loop
280 win = win->getTransient();
281
282 i++;
283 }
284
285 Window *nstack = new Window[i], *curr = nstack;
286 Workspace *wkspc;
287 275
288 while (True) { 276 Stack st(i);
289 *(curr++) = win->getFrameWindow(); 277 Stack::iterator stackit = st.begin();
290 screen->updateNetizenWindowLower(win->getClientWindow()); 278 lowerAndFillStack(stackit, *win);
291 279 (*stackit) = win->getFrameWindow();
292 if (! win->isIconic()) {
293 wkspc = screen->getWorkspace(win->getWorkspaceNumber());
294 wkspc->stackingList.remove(win);
295 wkspc->stackingList.push_back(win);
296 }
297
298 if (! win->getTransientFor() ||
299 win->getTransientFor() == win)//prevent infinite loop
300 break;
301 280
302 win = win->getTransientFor(); 281 screen->updateNetizenWindowLower(win->getClientWindow());
282 if (! win->isIconic()) {
283 Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber());
284 wkspc->stackingList.remove(win);
285 wkspc->stackingList.push_back(win);
303 } 286 }
304 287
305 Fluxbox::instance()->grab(); 288 XLowerWindow(BaseDisplay::getXDisplay(), st.front());
306 289 XRestackWindows(BaseDisplay::getXDisplay(), &st[0], st.size());
307 XLowerWindow(screen->getBaseDisplay()->getXDisplay(), *nstack);
308 XRestackWindows(screen->getBaseDisplay()->getXDisplay(), nstack, i);
309
310 Fluxbox::instance()->ungrab();
311 290
312 delete [] nstack;
313} 291}
314 292
315 293
@@ -583,19 +561,21 @@ void Workspace::placeWindow(FluxboxWindow *win) {
583 if ((*it)->hasTab()) { 561 if ((*it)->hasTab()) {
584 if (! (*it)->isShaded()) { // not shaded window 562 if (! (*it)->isShaded()) { // not shaded window
585 switch(screen->getTabPlacement()) { 563 switch(screen->getTabPlacement()) {
586 case Tab::PTOP: 564 case Tab::PTOP:
587 curr_y -= screen->getTabHeight(); 565 curr_y -= screen->getTabHeight();
588 case Tab::PBOTTOM: 566 case Tab::PBOTTOM:
589 curr_h += screen->getTabHeight(); 567 curr_h += screen->getTabHeight();
590 break; 568 break;
591 case Tab::PLEFT: 569 case Tab::PLEFT:
592 curr_x -= (screen->isTabRotateVertical()) 570 curr_x -= (screen->isTabRotateVertical())
593 ? screen->getTabHeight() 571 ? screen->getTabHeight()
594 : screen->getTabWidth(); 572 : screen->getTabWidth();
595 case Tab::PRIGHT: 573 case Tab::PRIGHT:
596 curr_w += (screen->isTabRotateVertical()) 574 curr_w += (screen->isTabRotateVertical())
597 ? screen->getTabHeight() 575 ? screen->getTabHeight()
598 : screen->getTabWidth(); 576 : screen->getTabWidth();
577 break;
578 case Tab::PNONE:
599 break; 579 break;
600 } 580 }
601 } else { // shaded window 581 } else { // shaded window
@@ -809,3 +789,55 @@ void Workspace::placeWindow(FluxboxWindow *win) {
809 789
810 win->configure(place_x, place_y, win->getWidth(), win->getHeight()); 790 win->configure(place_x, place_y, win->getWidth(), win->getHeight());
811} 791}
792
793
794void Workspace::raiseAndFillStack(Stack::iterator &stackit, const FluxboxWindow &w) {
795 if (w.getTransients().empty())
796 return;
797
798 std::list<FluxboxWindow *>::const_iterator it = w.getTransients().begin();
799 std::list<FluxboxWindow *>::const_iterator it_end = w.getTransients().end();
800 for (; it != it_end; ++it) {
801 *stackit++ = (*it)->getFrameWindow();
802
803 screen->updateNetizenWindowRaise((*it)->getClientWindow());
804
805 if (! (*it)->isIconic()) {
806 Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber());
807 wkspc->stackingList.remove((*it));
808 wkspc->stackingList.push_front((*it));
809 }
810
811
812 }
813
814 it = w.getTransients().begin();
815 for (; it != it_end; ++it)
816 raiseAndFillStack(stackit, *(*it));
817
818
819}
820
821void Workspace::lowerAndFillStack(Stack::iterator &stackit, const FluxboxWindow &win) {
822 if (win.getTransients().empty()) // nothing to lower and stack
823 return;
824
825 std::list<FluxboxWindow *>::const_reverse_iterator it = win.getTransients().rbegin();
826 std::list<FluxboxWindow *>::const_reverse_iterator it_end = win.getTransients().rend();
827 for (; it != it_end; ++it)
828 lowerAndFillStack(stackit, *(*it));
829
830 it = win.getTransients().rbegin();
831
832 for (; it != it_end; ++it) {
833 (*stackit) = (*it)->getFrameWindow();
834 ++stackit;
835 screen->updateNetizenWindowLower((*it)->getClientWindow());
836 if (! (*it)->isIconic()) {
837 Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber());
838 wkspc->stackingList.remove((*it));
839 wkspc->stackingList.push_back((*it));
840 }
841 }
842
843}