aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 38ca9ff..d067177 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -569,10 +569,19 @@ void BScreen::initWindows() {
569 Fluxbox *fluxbox = Fluxbox::instance(); 569 Fluxbox *fluxbox = Fluxbox::instance();
570 570
571 // manage shown windows 571 // manage shown windows
572 // complexity: O(n^2) if we have lots of transients to transient_for
573 // but usually O(n)
574 Window transient_for = 0; 572 Window transient_for = 0;
575 for (unsigned int i = 0; i < nchild; ++i) { 573 bool safety_flag = false;
574 unsigned int num_transients = 0;
575 for (unsigned int i = 0; i <= nchild; ++i) {
576 if (i == nchild) {
577 if (num_transients) {
578 nchild = num_transients;
579 i = num_transients = 0;
580 safety_flag = true;
581 } else
582 break;
583 }
584
576 if (children[i] == None) 585 if (children[i] == None)
577 continue; 586 continue;
578 else if (!fluxbox->validateWindow(children[i])) { 587 else if (!fluxbox->validateWindow(children[i])) {
@@ -584,33 +593,18 @@ void BScreen::initWindows() {
584 } 593 }
585 594
586 // if we have a transient_for window and it isn't created yet... 595 // if we have a transient_for window and it isn't created yet...
587 // postpone creation of this window and find transient_for window 596 // postpone creation of this window until after all others
588 // in the list and swap place with it so we can create transient_for window
589 // first
590 if (XGetTransientForHint(disp, children[i], &transient_for) && 597 if (XGetTransientForHint(disp, children[i], &transient_for) &&
591 fluxbox->searchWindow(transient_for) == 0) { 598 fluxbox->searchWindow(transient_for) == 0 && !safety_flag) {
592 // search forward for transient_for 599 // add this window back to the beginning of the list of children
593 // and swap place with it so it gets created first 600 children[num_transients] = children[i];
594 unsigned int j = i + 1; 601 num_transients++;
595 for (; j < nchild; ++j) {
596 if (children[j] == transient_for) {
597 swap(children[i], children[j]);
598 break;
599 }
600 }
601 // reevaluate window
602 if (!fluxbox->validateWindow(children[i]))
603 continue;
604 602
605#ifdef DEBUG 603#ifdef DEBUG
606 cerr<<"BScreen::initWindows(): j = "<<j<<" i = "<<i<<" nchild = "<<nchild<<endl; 604 cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[i]<<dec<<endl;
607
608 if (j < nchild)
609 cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[j]<<dec<<endl;
610 else
611 cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[i]<<dec<<endl;
612 cerr<<"BScreen::initWindows(): transient_for = 0x"<<hex<<transient_for<<dec<<endl; 605 cerr<<"BScreen::initWindows(): transient_for = 0x"<<hex<<transient_for<<dec<<endl;
613#endif // DEBUG 606#endif // DEBUG
607 continue;
614 } 608 }
615 609
616 610