all repos — fluxbox @ 7de8cabccfa4ad89923017198c4ace19152046b7

custom fork of the fluxbox windowmanager

don't switch windows with transients in initWindows() - just do transient later
markt markt
commit

7de8cabccfa4ad89923017198c4ace19152046b7

parent

0954a0b61d067d86047d0755a64b953bd12e4c20

2 files changed, 24 insertions(+), 25 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,5 +1,10 @@

(Format: Year/Month/Day) Changes for 1.0rc3: +*06/07/27: + * Don't change the order of creating windows with transients on restart. + Rather, just move the transient to the end of the list. This preserves the + focused order and also reduces the complexity to O(n). (Mark) + Screen.cc *06/07/26: * Fixed torn menus so they don't close on exec items (Mark) FbTk/Menu.cc
M src/Screen.ccsrc/Screen.cc

@@ -569,10 +569,19 @@

Fluxbox *fluxbox = Fluxbox::instance(); // manage shown windows - // complexity: O(n^2) if we have lots of transients to transient_for - // but usually O(n) Window transient_for = 0; - for (unsigned int i = 0; i < nchild; ++i) { + bool safety_flag = false; + unsigned int num_transients = 0; + for (unsigned int i = 0; i <= nchild; ++i) { + if (i == nchild) { + if (num_transients) { + nchild = num_transients; + i = num_transients = 0; + safety_flag = true; + } else + break; + } + if (children[i] == None) continue; else if (!fluxbox->validateWindow(children[i])) {

@@ -584,33 +593,18 @@ continue;

} // if we have a transient_for window and it isn't created yet... - // postpone creation of this window and find transient_for window - // in the list and swap place with it so we can create transient_for window - // first + // postpone creation of this window until after all others if (XGetTransientForHint(disp, children[i], &transient_for) && - fluxbox->searchWindow(transient_for) == 0) { - // search forward for transient_for - // and swap place with it so it gets created first - unsigned int j = i + 1; - for (; j < nchild; ++j) { - if (children[j] == transient_for) { - swap(children[i], children[j]); - break; - } - } - // reevaluate window - if (!fluxbox->validateWindow(children[i])) - continue; + fluxbox->searchWindow(transient_for) == 0 && !safety_flag) { + // add this window back to the beginning of the list of children + children[num_transients] = children[i]; + num_transients++; #ifdef DEBUG - cerr<<"BScreen::initWindows(): j = "<<j<<" i = "<<i<<" nchild = "<<nchild<<endl; - - if (j < nchild) - cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[j]<<dec<<endl; - else - cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[i]<<dec<<endl; + cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[i]<<dec<<endl; cerr<<"BScreen::initWindows(): transient_for = 0x"<<hex<<transient_for<<dec<<endl; #endif // DEBUG + continue; }