diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2008-08-14 05:52:39 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2008-08-14 05:52:39 (GMT) |
commit | e169d33552c8e7070aa6e13da0187f2013b4cfc3 (patch) | |
tree | ae9e92c7e885791c7f47645184070cbcd441ab94 /src/FbWinFrame.cc | |
parent | c82e7c0080f8a5c14dcf95ec92dc42f59ea9dd8b (diff) | |
parent | 91ca3bc5c8e2b892a9a81b18246f72aba7deebfd (diff) | |
download | fluxbox-e169d33552c8e7070aa6e13da0187f2013b4cfc3.zip fluxbox-e169d33552c8e7070aa6e13da0187f2013b4cfc3.tar.bz2 |
Merge branch 'master' into to_push
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r-- | src/FbWinFrame.cc | 191 |
1 files changed, 108 insertions, 83 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 234364e..afd5fb5 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -121,7 +121,6 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { | |||
121 | if (tabmode == EXTERNAL) { | 121 | if (tabmode == EXTERNAL) { |
122 | m_label.show(); | 122 | m_label.show(); |
123 | m_tab_container.setBorderWidth(m_window.borderWidth()); | 123 | m_tab_container.setBorderWidth(m_window.borderWidth()); |
124 | m_tab_container.setBorderColor(theme()->border().color()); | ||
125 | m_tab_container.setEventMask( | 124 | m_tab_container.setEventMask( |
126 | ButtonPressMask | ButtonReleaseMask | | 125 | ButtonPressMask | ButtonReleaseMask | |
127 | ButtonMotionMask | ExposureMask | | 126 | ButtonMotionMask | ExposureMask | |
@@ -487,12 +486,7 @@ void FbWinFrame::setFocus(bool newvalue) { | |||
487 | } | 486 | } |
488 | } | 487 | } |
489 | 488 | ||
490 | if (m_decoration_mask & DECORM_BORDER && | 489 | setBorderWidth(); |
491 | (theme().focusedTheme()->border().width() != | ||
492 | theme().unfocusedTheme()->border().width() || | ||
493 | theme().focusedTheme()->border().color().pixel() != | ||
494 | theme().unfocusedTheme()->border().color().pixel())) | ||
495 | setBorderWidth(theme()->border().width()); | ||
496 | 490 | ||
497 | applyAll(); | 491 | applyAll(); |
498 | clearAll(); | 492 | clearAll(); |
@@ -759,28 +753,6 @@ bool FbWinFrame::showHandle() { | |||
759 | return true; | 753 | return true; |
760 | } | 754 | } |
761 | 755 | ||
762 | bool FbWinFrame::hideAllDecorations() { | ||
763 | bool changed = false; | ||
764 | changed |= hideHandle(); | ||
765 | changed |= hideTitlebar(); | ||
766 | // resize done by hide* | ||
767 | reconfigure(); | ||
768 | |||
769 | return changed; | ||
770 | } | ||
771 | |||
772 | bool FbWinFrame::showAllDecorations() { | ||
773 | bool changed = false; | ||
774 | if (!m_use_handle) | ||
775 | changed |= showHandle(); | ||
776 | if (!m_use_titlebar) | ||
777 | changed |= showTitlebar(); | ||
778 | // resize shouldn't be necessary | ||
779 | reconfigure(); | ||
780 | |||
781 | return changed; | ||
782 | } | ||
783 | |||
784 | /** | 756 | /** |
785 | Set new event handler for the frame's windows | 757 | Set new event handler for the frame's windows |
786 | */ | 758 | */ |
@@ -871,8 +843,12 @@ void FbWinFrame::reconfigure() { | |||
871 | gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); | 843 | gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); |
872 | 844 | ||
873 | m_bevel = theme()->bevelWidth(); | 845 | m_bevel = theme()->bevelWidth(); |
874 | // reconfigure can't set borderwidth, as it doesn't know | 846 | setBorderWidth(); |
875 | // if it's meant to be borderless or not | 847 | |
848 | if (m_decoration_mask & DECORM_HANDLE && theme()->handleWidth() != 0) | ||
849 | showHandle(); | ||
850 | else | ||
851 | hideHandle(); | ||
876 | 852 | ||
877 | unsigned int orig_handle_h = handle().height(); | 853 | unsigned int orig_handle_h = handle().height(); |
878 | if (m_use_handle && orig_handle_h != theme()->handleWidth()) | 854 | if (m_use_handle && orig_handle_h != theme()->handleWidth()) |
@@ -1434,14 +1410,80 @@ void FbWinFrame::applyTabContainer() { | |||
1434 | } | 1410 | } |
1435 | } | 1411 | } |
1436 | 1412 | ||
1437 | void FbWinFrame::setBorderWidth(unsigned int border_width) { | 1413 | void FbWinFrame::applyDecorations() { |
1438 | int bw_changes = 0; | ||
1439 | |||
1440 | int grav_x=0, grav_y=0; | 1414 | int grav_x=0, grav_y=0; |
1441 | // negate gravity | 1415 | // negate gravity |
1442 | gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); | 1416 | gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, |
1417 | false); | ||
1418 | |||
1419 | bool client_move = setBorderWidth(false); | ||
1420 | |||
1421 | // tab deocration only affects if we're external | ||
1422 | // must do before the setTabMode in case it goes | ||
1423 | // to external and is meant to be hidden | ||
1424 | if (m_decoration_mask & DECORM_TAB) | ||
1425 | client_move |= showTabs(); | ||
1426 | else | ||
1427 | client_move |= hideTabs(); | ||
1428 | |||
1429 | // we rely on frame not doing anything if it is already shown/hidden | ||
1430 | if (m_decoration_mask & DECORM_TITLEBAR) { | ||
1431 | client_move |= showTitlebar(); | ||
1432 | if (m_screen.getDefaultInternalTabs()) | ||
1433 | client_move |= setTabMode(INTERNAL); | ||
1434 | else | ||
1435 | client_move |= setTabMode(EXTERNAL); | ||
1436 | } else { | ||
1437 | client_move |= hideTitlebar(); | ||
1438 | if (m_decoration_mask & DECORM_TAB) | ||
1439 | client_move |= setTabMode(EXTERNAL); | ||
1440 | } | ||
1441 | |||
1442 | if (m_decoration_mask & DECORM_HANDLE) | ||
1443 | client_move |= showHandle(); | ||
1444 | else | ||
1445 | client_move |= hideHandle(); | ||
1446 | |||
1447 | // apply gravity once more | ||
1448 | gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, | ||
1449 | false); | ||
1450 | |||
1451 | // if the location changes, shift it | ||
1452 | if (grav_x != 0 || grav_y != 0) { | ||
1453 | move(grav_x + x(), grav_y + y()); | ||
1454 | client_move = true; | ||
1455 | } | ||
1456 | |||
1457 | reconfigure(); | ||
1458 | if (client_move) | ||
1459 | frameExtentSig().notify(); | ||
1460 | } | ||
1461 | |||
1462 | bool FbWinFrame::setBorderWidth(bool do_move) { | ||
1463 | unsigned int border_width = theme()->border().width(); | ||
1464 | unsigned int win_bw = m_decoration_mask & DECORM_BORDER ? border_width : 0; | ||
1465 | |||
1466 | if (border_width && | ||
1467 | theme()->border().color().pixel() != window().borderColor()) { | ||
1468 | window().setBorderColor(theme()->border().color()); | ||
1469 | titlebar().setBorderColor(theme()->border().color()); | ||
1470 | handle().setBorderColor(theme()->border().color()); | ||
1471 | gripLeft().setBorderColor(theme()->border().color()); | ||
1472 | gripRight().setBorderColor(theme()->border().color()); | ||
1473 | tabcontainer().setBorderColor(theme()->border().color()); | ||
1474 | } | ||
1443 | 1475 | ||
1476 | if (border_width == handle().borderWidth() && | ||
1477 | win_bw == window().borderWidth()) | ||
1478 | return false; | ||
1479 | |||
1480 | int grav_x=0, grav_y=0; | ||
1481 | // negate gravity | ||
1482 | if (do_move) | ||
1483 | gravityTranslate(grav_x, grav_y, -m_active_gravity, | ||
1484 | m_active_orig_client_bw, false); | ||
1444 | 1485 | ||
1486 | int bw_changes = 0; | ||
1445 | // we need to change the size of the window | 1487 | // we need to change the size of the window |
1446 | // if the border width changes... | 1488 | // if the border width changes... |
1447 | if (m_use_titlebar) | 1489 | if (m_use_titlebar) |
@@ -1449,22 +1491,14 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { | |||
1449 | if (m_use_handle) | 1491 | if (m_use_handle) |
1450 | bw_changes += static_cast<signed>(border_width - handle().borderWidth()); | 1492 | bw_changes += static_cast<signed>(border_width - handle().borderWidth()); |
1451 | 1493 | ||
1452 | window().setBorderWidth(border_width); | 1494 | window().setBorderWidth(win_bw); |
1453 | window().setBorderColor(theme()->border().color()); | ||
1454 | 1495 | ||
1455 | setTabMode(NOTSET); | 1496 | setTabMode(NOTSET); |
1456 | 1497 | ||
1457 | titlebar().setBorderWidth(border_width); | 1498 | titlebar().setBorderWidth(border_width); |
1458 | titlebar().setBorderColor(theme()->border().color()); | ||
1459 | |||
1460 | handle().setBorderWidth(border_width); | 1499 | handle().setBorderWidth(border_width); |
1461 | handle().setBorderColor(theme()->border().color()); | ||
1462 | |||
1463 | gripLeft().setBorderWidth(border_width); | 1500 | gripLeft().setBorderWidth(border_width); |
1464 | gripLeft().setBorderColor(theme()->border().color()); | ||
1465 | |||
1466 | gripRight().setBorderWidth(border_width); | 1501 | gripRight().setBorderWidth(border_width); |
1467 | gripRight().setBorderColor(theme()->border().color()); | ||
1468 | 1502 | ||
1469 | if (bw_changes != 0) | 1503 | if (bw_changes != 0) |
1470 | resize(width(), height() + bw_changes); | 1504 | resize(width(), height() + bw_changes); |
@@ -1472,11 +1506,16 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { | |||
1472 | if (m_tabmode == EXTERNAL) | 1506 | if (m_tabmode == EXTERNAL) |
1473 | alignTabs(); | 1507 | alignTabs(); |
1474 | 1508 | ||
1475 | gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, false); | 1509 | if (do_move) { |
1476 | // if the location changes, shift it | 1510 | frameExtentSig().notify(); |
1477 | if (grav_x != 0 || grav_y != 0) | 1511 | gravityTranslate(grav_x, grav_y, m_active_gravity, |
1478 | move(grav_x + x(), grav_y + y()); | 1512 | m_active_orig_client_bw, false); |
1513 | // if the location changes, shift it | ||
1514 | if (grav_x != 0 || grav_y != 0) | ||
1515 | move(grav_x + x(), grav_y + y()); | ||
1516 | } | ||
1479 | 1517 | ||
1518 | return true; | ||
1480 | } | 1519 | } |
1481 | 1520 | ||
1482 | // this function translates its arguments according to win_gravity | 1521 | // this function translates its arguments according to win_gravity |
@@ -1519,44 +1558,30 @@ void FbWinFrame::gravityTranslate(int &x, int &y, | |||
1519 | // Note that the client window's x,y is offset by it's borderWidth, which | 1558 | // Note that the client window's x,y is offset by it's borderWidth, which |
1520 | // is removed by fluxbox, so the gravity needs to account for this change | 1559 | // is removed by fluxbox, so the gravity needs to account for this change |
1521 | 1560 | ||
1522 | // unsigned int width_offset = 0; // no side decorations | ||
1523 | |||
1524 | // these functions already check if the title/handle is used | 1561 | // these functions already check if the title/handle is used |
1525 | int height_offset = - titlebarHeight() - handleHeight(); | ||
1526 | |||
1527 | int bw_diff = client_bw - m_window.borderWidth(); | 1562 | int bw_diff = client_bw - m_window.borderWidth(); |
1563 | int height_diff = 2*bw_diff - titlebarHeight() - handleHeight(); | ||
1564 | int width_diff = 2*bw_diff; | ||
1528 | 1565 | ||
1529 | // mostly no X offset, since we don't have extra frame on the sides | 1566 | if (win_gravity == SouthWestGravity || win_gravity == SouthGravity || |
1530 | switch (win_gravity) { | 1567 | win_gravity == SouthEastGravity) |
1531 | case NorthEastGravity: | 1568 | y_offset = height_diff; |
1532 | x_offset += bw_diff; | 1569 | |
1533 | case NorthGravity: | 1570 | if (win_gravity == WestGravity || win_gravity == CenterGravity || |
1534 | x_offset += bw_diff; | 1571 | win_gravity == EastGravity) |
1535 | case NorthWestGravity: | 1572 | y_offset = height_diff/2; |
1536 | // no offset, since the top point is still the same | 1573 | |
1537 | break; | 1574 | if (win_gravity == NorthEastGravity || win_gravity == EastGravity || |
1538 | case SouthEastGravity: | 1575 | win_gravity == SouthEastGravity) |
1539 | x_offset += bw_diff; | 1576 | x_offset = width_diff; |
1540 | case SouthGravity: | 1577 | |
1541 | x_offset += bw_diff; | 1578 | if (win_gravity == NorthGravity || win_gravity == CenterGravity || |
1542 | case SouthWestGravity: | 1579 | win_gravity == SouthGravity) |
1543 | // window shifted down by height of titlebar, and the handle | 1580 | x_offset = width_diff/2; |
1544 | // since that's necessary to get the bottom of the frame | 1581 | |
1545 | // all the way up | 1582 | if (win_gravity == StaticGravity) { |
1546 | y_offset += 2*bw_diff + height_offset; | 1583 | x_offset = bw_diff; |
1547 | break; | 1584 | y_offset = bw_diff - titlebarHeight(); |
1548 | case EastGravity: | ||
1549 | x_offset += bw_diff; | ||
1550 | case CenterGravity: | ||
1551 | x_offset += bw_diff; | ||
1552 | case WestGravity: | ||
1553 | // these centered ones are a little more interesting | ||
1554 | y_offset += bw_diff + height_offset/2; | ||
1555 | break; | ||
1556 | case StaticGravity: | ||
1557 | x_offset += bw_diff; | ||
1558 | y_offset += -titlebarHeight() + bw_diff; | ||
1559 | break; | ||
1560 | } | 1585 | } |
1561 | 1586 | ||
1562 | if (invert) { | 1587 | if (invert) { |