From 7de8cabccfa4ad89923017198c4ace19152046b7 Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 27 Jul 2006 00:04:11 +0000 Subject: don't switch windows with transients in initWindows() - just do transient later --- ChangeLog | 5 +++++ src/Screen.cc | 44 +++++++++++++++++++------------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e5618e..44801b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 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() { 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 @@ void BScreen::initWindows() { } // 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 = "<