diff options
author | fluxgen <fluxgen> | 2002-09-08 19:51:30 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-09-08 19:51:30 (GMT) |
commit | 6221cd41ebd7f35cc8cd5006fe38f0248e86ae49 (patch) | |
tree | e61dfc66be4a5469ae41f9b3174a580a3f1ff993 /src | |
parent | f2f0606c2ee353d37b21cae7f5628a4e397599b3 (diff) | |
download | fluxbox_paul-6221cd41ebd7f35cc8cd5006fe38f0248e86ae49.zip fluxbox_paul-6221cd41ebd7f35cc8cd5006fe38f0248e86ae49.tar.bz2 |
new transient handling, minor indentation issues, cleaning in destructor
Diffstat (limited to 'src')
-rw-r--r-- | src/Window.cc | 217 |
1 files changed, 91 insertions, 126 deletions
diff --git a/src/Window.cc b/src/Window.cc index 2df8f30..838a0a2 100644 --- a/src/Window.cc +++ b/src/Window.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: Window.cc,v 1.79 2002/09/07 20:16:43 fluxgen Exp $ | 25 | // $Id: Window.cc,v 1.80 2002/09/08 19:51:30 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -139,7 +139,7 @@ tab(0) { | |||
139 | functions.close = decorations.close = false; | 139 | functions.close = decorations.close = false; |
140 | 140 | ||
141 | client.wm_hint_flags = client.normal_hint_flags = 0; | 141 | client.wm_hint_flags = client.normal_hint_flags = 0; |
142 | client.transient_for = client.transient = 0; | 142 | client.transient_for = 0; |
143 | client.mwm_hint = (MwmHints *) 0; | 143 | client.mwm_hint = (MwmHints *) 0; |
144 | client.blackbox_hint = 0; | 144 | client.blackbox_hint = 0; |
145 | 145 | ||
@@ -335,7 +335,8 @@ tab(0) { | |||
335 | FluxboxWindow::~FluxboxWindow() { | 335 | FluxboxWindow::~FluxboxWindow() { |
336 | if (screen == 0) //the window wasn't created | 336 | if (screen == 0) //the window wasn't created |
337 | return; | 337 | return; |
338 | 338 | timer.stop(); | |
339 | |||
339 | Fluxbox *fluxbox = Fluxbox::instance(); | 340 | Fluxbox *fluxbox = Fluxbox::instance(); |
340 | 341 | ||
341 | if (moving || resizing) { | 342 | if (moving || resizing) { |
@@ -343,13 +344,11 @@ FluxboxWindow::~FluxboxWindow() { | |||
343 | XUngrabPointer(display, CurrentTime); | 344 | XUngrabPointer(display, CurrentTime); |
344 | } | 345 | } |
345 | 346 | ||
346 | if (!iconic) { | 347 | if (iconic) |
347 | Workspace *workspace = screen->getWorkspace(workspace_number); | ||
348 | if (workspace) | ||
349 | workspace->removeWindow(this); | ||
350 | } else //it's iconic | ||
351 | screen->removeIcon(this); | 348 | screen->removeIcon(this); |
352 | 349 | ||
350 | screen->removeWindow(this); | ||
351 | |||
353 | if (windowmenu) { | 352 | if (windowmenu) { |
354 | delete windowmenu; | 353 | delete windowmenu; |
355 | windowmenu = 0; | 354 | windowmenu = 0; |
@@ -371,32 +370,20 @@ FluxboxWindow::~FluxboxWindow() { | |||
371 | } | 370 | } |
372 | 371 | ||
373 | 372 | ||
374 | if (isTransient()) { | 373 | if (client.transient_for != 0) { |
375 | //guard from having transient_for = this | 374 | client.transient_for->client.transients.remove(this); |
376 | if (client.transient_for == this) { | 375 | client.transient_for = 0; |
377 | #ifdef DEBUG | 376 | } |
378 | cerr<<__FILE__<<"("<<__LINE__<<"): WARNING! client.transient_for == this WARNING!"<<endl; | 377 | |
379 | assert(0); | 378 | while (!client.transients.empty()) { |
380 | #endif //DEBUG | 379 | client.transients.back()->client.transient_for = 0; |
381 | client.transient_for = 0; | 380 | client.transients.pop_back(); |
382 | |||
383 | } | ||
384 | if (client.transient == this) { | ||
385 | client.transient = 0; | ||
386 | assert(0); | ||
387 | } | ||
388 | fluxbox->setFocusedWindow(client.transient_for); | ||
389 | } | 381 | } |
390 | 382 | ||
391 | if (client.window_group) { | 383 | if (client.window_group) { |
392 | fluxbox->removeGroupSearch(client.window_group); | 384 | fluxbox->removeGroupSearch(client.window_group); |
393 | client.window_group = 0; | 385 | client.window_group = 0; |
394 | } | 386 | } |
395 | |||
396 | if (transient && client.transient_for) | ||
397 | client.transient_for->client.transient = client.transient; | ||
398 | if (client.transient) | ||
399 | client.transient->client.transient_for = client.transient_for; | ||
400 | 387 | ||
401 | destroyTitlebar(); | 388 | destroyTitlebar(); |
402 | 389 | ||
@@ -430,17 +417,11 @@ FluxboxWindow::~FluxboxWindow() { | |||
430 | frame.window = 0; | 417 | frame.window = 0; |
431 | } | 418 | } |
432 | 419 | ||
433 | // Make sure we don't remove | 420 | fluxbox->removeWindowSearch(client.window); |
434 | // a slit client from the list | ||
435 | if (managed) { | ||
436 | fluxbox->removeWindowSearch(client.window); | ||
437 | screen->removeNetizen(client.window); | ||
438 | } | ||
439 | |||
440 | 421 | ||
441 | #ifdef DEBUG | 422 | #ifdef DEBUG |
442 | cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow(this="<<this<<") done"<<endl; | 423 | cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; |
443 | #endif | 424 | #endif // DEBUG |
444 | } | 425 | } |
445 | 426 | ||
446 | Window FluxboxWindow::createToplevelWindow( | 427 | Window FluxboxWindow::createToplevelWindow( |
@@ -1524,37 +1505,38 @@ bool FluxboxWindow::setInputFocus() { | |||
1524 | frame.y + screen->getBorderWidth(), frame.width, frame.height); | 1505 | frame.y + screen->getBorderWidth(), frame.width, frame.height); |
1525 | } | 1506 | } |
1526 | 1507 | ||
1527 | Fluxbox *fluxbox = Fluxbox::instance(); | ||
1528 | fluxbox->grab(); | ||
1529 | if (! validateClient()) | 1508 | if (! validateClient()) |
1530 | return false; | 1509 | return false; |
1531 | 1510 | ||
1532 | bool ret = false; | 1511 | bool ret = false; |
1533 | 1512 | ||
1534 | if (client.transient && modal) { | 1513 | if (client.transients.size() && modal) { |
1535 | fluxbox->ungrab(); | 1514 | std::list<FluxboxWindow *>::iterator it = client.transients.begin(); |
1536 | return client.transient->setInputFocus(); | 1515 | std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); |
1516 | for (; it != it_end; ++it) { | ||
1517 | if ((*it)->modal) | ||
1518 | return (*it)->setInputFocus(); | ||
1519 | } | ||
1537 | } else { | 1520 | } else { |
1538 | if (! focused) { | 1521 | if (! focused) { |
1539 | if (focus_mode == F_LOCALLYACTIVE || focus_mode == F_PASSIVE) { | 1522 | if (focus_mode == F_LOCALLYACTIVE || focus_mode == F_PASSIVE) { |
1540 | XSetInputFocus(display, client.window, | 1523 | XSetInputFocus(display, client.window, |
1541 | RevertToPointerRoot, CurrentTime); | 1524 | RevertToPointerRoot, CurrentTime); |
1542 | } else { | 1525 | } else { |
1543 | fluxbox->ungrab(); | ||
1544 | return false; | 1526 | return false; |
1545 | } | 1527 | } |
1546 | 1528 | Fluxbox *fb = Fluxbox::instance(); | |
1547 | fluxbox->setFocusedWindow(this); | 1529 | fb->setFocusedWindow(this); |
1548 | 1530 | ||
1549 | if (send_focus_message) { | 1531 | if (send_focus_message) { |
1550 | XEvent ce; | 1532 | XEvent ce; |
1551 | ce.xclient.type = ClientMessage; | 1533 | ce.xclient.type = ClientMessage; |
1552 | ce.xclient.message_type = fluxbox->getWMProtocolsAtom(); | 1534 | ce.xclient.message_type = fb->getWMProtocolsAtom(); |
1553 | ce.xclient.display = display; | 1535 | ce.xclient.display = display; |
1554 | ce.xclient.window = client.window; | 1536 | ce.xclient.window = client.window; |
1555 | ce.xclient.format = 32; | 1537 | ce.xclient.format = 32; |
1556 | ce.xclient.data.l[0] = fluxbox->getWMTakeFocusAtom(); | 1538 | ce.xclient.data.l[0] = fb->getWMTakeFocusAtom(); |
1557 | ce.xclient.data.l[1] = fluxbox->getLastTime(); | 1539 | ce.xclient.data.l[1] = fb->getLastTime(); |
1558 | ce.xclient.data.l[2] = 0l; | 1540 | ce.xclient.data.l[2] = 0l; |
1559 | ce.xclient.data.l[3] = 0l; | 1541 | ce.xclient.data.l[3] = 0l; |
1560 | ce.xclient.data.l[4] = 0l; | 1542 | ce.xclient.data.l[4] = 0l; |
@@ -1569,8 +1551,6 @@ bool FluxboxWindow::setInputFocus() { | |||
1569 | } | 1551 | } |
1570 | } | 1552 | } |
1571 | 1553 | ||
1572 | fluxbox->ungrab(); | ||
1573 | |||
1574 | return ret; | 1554 | return ret; |
1575 | } | 1555 | } |
1576 | 1556 | ||
@@ -1624,9 +1604,13 @@ void FluxboxWindow::iconify() { | |||
1624 | if (tab) //if this window got a tab then iconify it too | 1604 | if (tab) //if this window got a tab then iconify it too |
1625 | tab->iconify(); | 1605 | tab->iconify(); |
1626 | 1606 | ||
1627 | if (client.transient) { | 1607 | if (client.transients.size()) { |
1628 | if (! client.transient->iconic) | 1608 | std::list<FluxboxWindow *>::iterator it = client.transients.begin(); |
1629 | client.transient->iconify(); | 1609 | std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); |
1610 | for (; it != it_end; ++it) { | ||
1611 | if (! (*it)->iconic) | ||
1612 | (*it)->iconify(); | ||
1613 | } | ||
1630 | } | 1614 | } |
1631 | 1615 | ||
1632 | } | 1616 | } |
@@ -1648,12 +1632,20 @@ void FluxboxWindow::deiconify(bool reassoc, bool raise) { | |||
1648 | XMapSubwindows(display, frame.window); | 1632 | XMapSubwindows(display, frame.window); |
1649 | XMapWindow(display, frame.window); | 1633 | XMapWindow(display, frame.window); |
1650 | 1634 | ||
1651 | if (iconic && screen->doFocusNew()) setInputFocus(); | 1635 | if (iconic && screen->doFocusNew()) |
1636 | setInputFocus(); | ||
1652 | 1637 | ||
1653 | visible = true; | 1638 | visible = true; |
1654 | iconic = false; | 1639 | iconic = false; |
1655 | 1640 | ||
1656 | if (reassoc && client.transient) client.transient->deiconify(true, false); | 1641 | if (reassoc && client.transients.size()) { |
1642 | // deiconify all transients | ||
1643 | std::list<FluxboxWindow *>::iterator it = client.transients.begin(); | ||
1644 | std::list<FluxboxWindow *>::iterator it_end = client.transients.end(); | ||
1645 | for (; it != it_end; ++it) { | ||
1646 | (*it)->deiconify(true, false); | ||
1647 | } | ||
1648 | } | ||
1657 | 1649 | ||
1658 | if (tab) | 1650 | if (tab) |
1659 | tab->deiconify(); | 1651 | tab->deiconify(); |
@@ -2405,18 +2397,18 @@ void FluxboxWindow::restoreGravity() { | |||
2405 | // restore y coordinate | 2397 | // restore y coordinate |
2406 | switch (client.win_gravity) { | 2398 | switch (client.win_gravity) { |
2407 | // handle Northbound gravity | 2399 | // handle Northbound gravity |
2408 | case NorthWestGravity: | 2400 | case NorthWestGravity: |
2409 | case NorthGravity: | 2401 | case NorthGravity: |
2410 | case NorthEastGravity: | 2402 | case NorthEastGravity: |
2411 | default: | 2403 | default: |
2412 | client.y = frame.y; | 2404 | client.y = frame.y; |
2413 | break; | 2405 | break; |
2414 | 2406 | ||
2415 | // handle Southbound gravity | 2407 | // handle Southbound gravity |
2416 | case SouthWestGravity: | 2408 | case SouthWestGravity: |
2417 | case SouthGravity: | 2409 | case SouthGravity: |
2418 | case SouthEastGravity: | 2410 | case SouthEastGravity: |
2419 | client.y = (frame.y + frame.height) - client.height; | 2411 | client.y = (frame.y + frame.height) - client.height; |
2420 | break; | 2412 | break; |
2421 | } | 2413 | } |
2422 | } | 2414 | } |
@@ -2710,11 +2702,12 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) { | |||
2710 | windowmenu->reconfigure(); | 2702 | windowmenu->reconfigure(); |
2711 | } | 2703 | } |
2712 | } else { | 2704 | } else { |
2705 | |||
2706 | #ifdef NEWWMSPEC | ||
2713 | bool val = false; | 2707 | bool val = false; |
2714 | #ifdef NEWWMSPEC | ||
2715 | if (!val) | 2708 | if (!val) |
2716 | handleNETWMPropertyNotify(atom); | 2709 | handleNETWMPropertyNotify(atom); |
2717 | #endif | 2710 | #endif // NEWWMSPEC |
2718 | } | 2711 | } |
2719 | break; | 2712 | break; |
2720 | } | 2713 | } |
@@ -3485,77 +3478,49 @@ void FluxboxWindow::destroyHandle() { | |||
3485 | } | 3478 | } |
3486 | 3479 | ||
3487 | void FluxboxWindow::checkTransient() { | 3480 | void FluxboxWindow::checkTransient() { |
3488 | // default values | 3481 | // remove us from parent |
3482 | if (client.transient_for != 0) { | ||
3483 | client.transient_for->client.transients.remove(this); | ||
3484 | } | ||
3489 | client.transient_for = 0; | 3485 | client.transient_for = 0; |
3490 | client.transient = 0; | ||
3491 | 3486 | ||
3492 | Fluxbox *fluxbox = Fluxbox::instance(); | ||
3493 | // determine if this is a transient window | 3487 | // determine if this is a transient window |
3494 | Window win; | 3488 | Window win; |
3495 | if (!XGetTransientForHint(display, client.window, &win)) { | 3489 | if (!XGetTransientForHint(display, client.window, &win)) { |
3496 | client.transient_for = 0; | 3490 | client.transient_for = 0; |
3497 | return; | 3491 | return; |
3498 | } | 3492 | } |
3499 | 3493 | ||
3494 | |||
3500 | if (win == client.window) | 3495 | if (win == client.window) |
3501 | return; | 3496 | return; |
3502 | 3497 | ||
3503 | if (win && (win != client.window)) { | ||
3504 | FluxboxWindow *tr = fluxbox->searchWindow(win); | ||
3505 | if (tr != 0) { | ||
3506 | |||
3507 | while (tr->client.transient != 0) { | ||
3508 | tr = tr->client.transient; | ||
3509 | if (tr == tr->client.transient) { //ops! something is wrong with transient | ||
3510 | tr->client.transient = 0; | ||
3511 | if (tr->client.transient_for == tr) | ||
3512 | tr->client.transient_for = 0; | ||
3513 | break; | ||
3514 | } | ||
3515 | } | ||
3516 | |||
3517 | if (tr != this) { | ||
3518 | client.transient_for = tr; | ||
3519 | tr->client.transient = this; | ||
3520 | transient = true; | ||
3521 | } else { | ||
3522 | client.transient_for = 0; | ||
3523 | client.transient = 0; | ||
3524 | } | ||
3525 | if (client.transient_for != 0) { | ||
3526 | stuck = client.transient_for->stuck; | ||
3527 | } | ||
3528 | |||
3529 | } else if (win == client.window_group) { | ||
3530 | if ((tr = fluxbox->searchGroup(win, this))) { | ||
3531 | |||
3532 | while (tr->client.transient != 0) { | ||
3533 | tr = tr->client.transient; | ||
3534 | if (tr && tr == tr->client.transient) { //ops! somehtin is wrong with transient | ||
3535 | tr->client.transient = 0; | ||
3536 | } | ||
3537 | } | ||
3538 | |||
3539 | if (tr != this) { | ||
3540 | client.transient_for = tr; | ||
3541 | tr->client.transient = this; | ||
3542 | transient = true; | ||
3543 | } else { | ||
3544 | client.transient_for = 0; | ||
3545 | client.transient = 0; | ||
3546 | } | ||
3547 | |||
3548 | if (client.transient_for != 0) { | ||
3549 | stuck = client.transient_for->stuck; | ||
3550 | } | ||
3551 | |||
3552 | } | ||
3553 | } | ||
3554 | } | ||
3555 | |||
3556 | if (win == screen->getRootWindow()) | 3498 | if (win == screen->getRootWindow()) |
3557 | modal = true; | 3499 | modal = true; |
3558 | 3500 | ||
3501 | client.transient_for = Fluxbox::instance()->searchWindow(win); | ||
3502 | if (client.transient_for != 0 && | ||
3503 | client.window_group != None && win == client.window_group) { | ||
3504 | |||
3505 | FluxboxWindow *leader = Fluxbox::instance()->searchGroup(win, this); | ||
3506 | if (leader != 0) | ||
3507 | client.transient_for = leader; | ||
3508 | return; | ||
3509 | } | ||
3510 | |||
3511 | // make sure we don't have deadlock loop in transient chain | ||
3512 | for (FluxboxWindow *w = this; w != 0; w = w->client.transient_for) { | ||
3513 | if (w == w->client.transient_for) { | ||
3514 | w->client.transient_for = 0; | ||
3515 | } | ||
3516 | } | ||
3517 | |||
3518 | if (client.transient_for != 0) { | ||
3519 | client.transient_for->client.transients.push_back(this); | ||
3520 | // make sure we only have on instance of this | ||
3521 | client.transient_for->client.transients.unique(); | ||
3522 | stuck = client.transient_for->stuck; | ||
3523 | } | ||
3559 | } | 3524 | } |
3560 | 3525 | ||
3561 | void FluxboxWindow::restore(bool remap) { | 3526 | void FluxboxWindow::restore(bool remap) { |