aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-07-14 18:28:05 (GMT)
committerfluxgen <fluxgen>2004-07-14 18:28:05 (GMT)
commit7794867005b9fe72e58af8c8d3c8cd36ad02c038 (patch)
tree1144fd8b7c6f440102c2577578f7b160a9691a49 /src
parent80a4b5834f52800d73f38658e74ca223edd1f480 (diff)
downloadfluxbox-7794867005b9fe72e58af8c8d3c8cd36ad02c038.zip
fluxbox-7794867005b9fe72e58af8c8d3c8cd36ad02c038.tar.bz2
improved algoritm for transient_for in initWindows
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc128
1 files changed, 62 insertions, 66 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 41f9ec5..ace87d9 100644
--- a/src/Screen.cc
+++ b/src/Screen.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: Screen.cc,v 1.284 2004/07/14 12:13:29 fluxgen Exp $ 25// $Id: Screen.cc,v 1.285 2004/07/14 18:28:05 fluxgen Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -436,26 +436,13 @@ void BScreen::initWindows() {
436 Display *disp = FbTk::App::instance()->display(); 436 Display *disp = FbTk::App::instance()->display();
437 XQueryTree(disp, rootWindow().window(), &r, &p, &children, &nchild); 437 XQueryTree(disp, rootWindow().window(), &r, &p, &children, &nchild);
438 438
439 // Count number of windows created and when this counter reaches zero
440 // we've created all windows.
441 // We need to do this because sometimes the transient windows are
442 // before the transient_for windows in the list and we need to
443 // postpone the creation of transient windows until the transient_for
444 // is created (see: WinClient::updateTransientInfo())
445 //
446 // - Henrik
447 int created = nchild; // number of created/managed windows
448
449 Fluxbox *fluxbox = Fluxbox::instance(); 439 Fluxbox *fluxbox = Fluxbox::instance();
450 440
451 // preen the window list of all icon windows... for better dockapp support 441 // preen the window list of all icon windows... for better dockapp support
452 for (int i = 0; i < (int) nchild; i++) { 442 for (int i = 0; i < (int) nchild; i++) {
453 443
454 if (children[i] == None) { 444 if (children[i] == None)
455 // we dont use this window, decrease counter
456 created--;
457 continue; 445 continue;
458 }
459 446
460 XWMHints *wmhints = XGetWMHints(disp, children[i]); 447 XWMHints *wmhints = XGetWMHints(disp, children[i]);
461 448
@@ -464,6 +451,10 @@ void BScreen::initWindows() {
464 (wmhints->icon_window != children[i])) 451 (wmhints->icon_window != children[i]))
465 for (int j = 0; j < (int) nchild; j++) { 452 for (int j = 0; j < (int) nchild; j++) {
466 if (children[j] == wmhints->icon_window) { 453 if (children[j] == wmhints->icon_window) {
454#ifdef DEBUG
455 cerr<<"BScreen::initWindows(): children[j] = 0x"<<hex<<children[j]<<dec<<endl;
456 cerr<<"BScreen::initWindows(): = icon_window"<<endl;
457#endif // DEBUG
467 children[j] = None; 458 children[j] = None;
468 break; 459 break;
469 } 460 }
@@ -471,73 +462,78 @@ void BScreen::initWindows() {
471 XFree(wmhints); 462 XFree(wmhints);
472 } 463 }
473 464
474 // we dont use this window, decrease counter
475 if (children[i] == None || (! fluxbox->validateWindow(children[i])))
476 created--;
477 } 465 }
478 466
479 // manage shown windows 467 // manage shown windows
480 Window transient_for = 0; 468 // complexity: O(n^2) if we have lots of transients to transient_for
481 int safety_counter = nchild*nchild; 469 // but usually O(n)
482 while (created > 0) { 470 Window transient_for = 0;
483 471 for (int i = 0; i < (int) nchild; ++i) {
484 if (--safety_counter < 0) { 472 if (children[i] == None)
485 cerr<<"BScreen::initWindows() Warning!!! Safety counter reached!"<<endl; 473 continue;
486 cerr<<"--------------"<<endl; 474 else if (!fluxbox->validateWindow(children[i])) {
487 cerr<<"created = "<<created<<hex<<endl; 475#ifdef DEBUG
488 for (int i=0; i < nchild; ++i) 476 cerr<<"BScreen::initWindows(): not valid window = "<<hex<<children[i]<<dec<<endl;
489 cerr<<"child("<<i<<") = 0x"<<children[i]<<endl; 477#endif // DEBUG
490 cerr<<dec<<"--------------"<<endl; 478 children[i] = None;
491 cerr<<"Please report this to fluxbox development team."<<endl; 479 continue;
492
493 break;
494 } 480 }
495 481
496 for (int i = 0; i < (int) nchild; ++i) { 482 // if we have a transient_for window and it isn't created yet...
497 if (children[i] == None || (! fluxbox->validateWindow(children[i]))) { 483 // postpone creation of this window and find transient_for window
484 // in the list and swap place with it so we can create transient_for window
485 // first
486 if (XGetTransientForHint(disp, children[i], &transient_for) &&
487 fluxbox->searchWindow(transient_for) == 0) {
488 // search forward for transient_for
489 // and swap place with it so it gets created first
490 int j = i + 1;
491 for (; j < nchild; ++j) {
492 if (children[j] == transient_for) {
493 swap(children[i], children[j]);
494 break;
495 }
496 }
497 // reevaluate window
498 if (!fluxbox->validateWindow(children[i]))
499 continue;
500
498#ifdef DEBUG 501#ifdef DEBUG
499 cerr<<"BScreen::initWindows(): created = "<<created<<endl; 502 cerr<<"BScreen::initWindows(): j = "<<j<<" i = "<<i<<" nchild = "<<nchild<<endl;
500#endif // DEBUG 503#endif // DEBUG
501 continue; 504
502 } 505#ifdef DEBUG
503 506 if (j < nchild)
504 // if we have a transient_for window and it isn't created yet... 507 cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[j]<<dec<<endl;
505 // postpone creation of this window until transient_for is created 508 else
506 // See comment at the begining 509 cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[i]<<dec<<endl;
507 if (XGetTransientForHint(disp, children[i], &transient_for) && 510 cerr<<"BScreen::initWindows(): transient_for = 0x"<<hex<<transient_for<<dec<<endl;
508 fluxbox->searchWindow(transient_for) == 0) 511#endif // DEBUG
509 continue; 512 }
510 513
511 514
512 XWindowAttributes attrib; 515 XWindowAttributes attrib;
513 if (XGetWindowAttributes(disp, children[i], 516 if (XGetWindowAttributes(disp, children[i],
514 &attrib)) { 517 &attrib)) {
515 if (attrib.override_redirect) { 518 if (attrib.override_redirect) {
516 children[i] = None; // we dont need this anymore, since we already created a window for it 519 children[i] = None; // we dont need this anymore, since we already created a window for it
517 // we "created" a window...decrease creation counter 520 continue;
518 if (--created <= 0) 521 }
519 break; // end for-loop
520 continue;
521 }
522 522
523 if (attrib.map_state != IsUnmapped) { 523 if (attrib.map_state != IsUnmapped) {
524 FluxboxWindow *win = createWindow(children[i]); 524 FluxboxWindow *win = createWindow(children[i]);
525 525
526 if (win) { 526 if (win) {
527 XMapRequestEvent mre; 527 XMapRequestEvent mre;
528 mre.window = children[i]; 528 mre.window = children[i];
529 win->mapRequestEvent(mre); 529 win->mapRequestEvent(mre);
530 }
531 } 530 }
532 } 531 }
533 children[i] = None; // we dont need this anymore, since we already created a window for it
534 // we created a window...decrease creation counter
535 if (--created <= 0)
536 break; // end for-loop
537
538 } 532 }
533 children[i] = None; // we dont need this anymore, since we already created a window for it
539 } 534 }
540 535
536
541 XFree(children); 537 XFree(children);
542 538
543} 539}