aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-08-22 12:52:23 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-08-22 12:52:23 (GMT)
commit0ae3ca9e8a2a3398cf07789e0d141887d40dcb6f (patch)
tree4e4d66fc15fea3956106affb772ea28f3bc909dd /src/Window.cc
parent8681220f5361fef500d7eda28d9f22bbf0a006e4 (diff)
downloadfluxbox_pavel-0ae3ca9e8a2a3398cf07789e0d141887d40dcb6f.zip
fluxbox_pavel-0ae3ca9e8a2a3398cf07789e0d141887d40dcb6f.tar.bz2
move fullscreen and maximization handling to FbWinFrame
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc158
1 files changed, 19 insertions, 139 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 79419d0..c91e875 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -271,7 +271,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer):
271 m_creation_time(0), 271 m_creation_time(0),
272 moving(false), resizing(false), shaded(false), iconic(false), 272 moving(false), resizing(false), shaded(false), iconic(false),
273 stuck(false), m_initialized(false), fullscreen(false), 273 stuck(false), m_initialized(false), fullscreen(false),
274 maximized(MAX_NONE), 274 maximized(FbWinFrame::MAX_NONE),
275 m_attaching_tab(0), 275 m_attaching_tab(0),
276 display(FbTk::App::instance()->display()), 276 display(FbTk::App::instance()->display()),
277 m_button_grab_x(0), m_button_grab_y(0), 277 m_button_grab_x(0), m_button_grab_y(0),
@@ -287,8 +287,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer):
287 m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)), 287 m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)),
288 m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)), 288 m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)),
289 m_click_focus(true), 289 m_click_focus(true),
290 m_old_pos_x(0), m_old_pos_y(0),
291 m_old_width(1), m_old_height(1),
292 m_last_button_x(0), m_last_button_y(0), 290 m_last_button_x(0), m_last_button_y(0),
293 m_button_theme(*this, screen().focusedWinButtonTheme(), 291 m_button_theme(*this, screen().focusedWinButtonTheme(),
294 screen().unfocusedWinButtonTheme()), 292 screen().unfocusedWinButtonTheme()),
@@ -561,7 +559,7 @@ void FluxboxWindow::init() {
561 559
562 if (maximized) { 560 if (maximized) {
563 int tmp = maximized; 561 int tmp = maximized;
564 maximized = MAX_NONE; 562 maximized = FbWinFrame::MAX_NONE;
565 setMaximizedState(tmp); 563 setMaximizedState(tmp);
566 } 564 }
567 565
@@ -1444,35 +1442,16 @@ void FluxboxWindow::setFullscreen(bool flag) {
1444 return; 1442 return;
1445 } 1443 }
1446 1444
1447 const int head = screen().getHead(fbWindow());
1448
1449 if (flag && !isFullscreen()) { 1445 if (flag && !isFullscreen()) {
1450 1446
1451 if (isShaded()) 1447 if (isShaded())
1452 shade(); 1448 shade();
1453 1449
1454 m_old_layernum = layerNum(); 1450 m_old_layernum = layerNum();
1455 if (!maximized) {
1456 m_old_pos_x = frame().x();
1457 m_old_pos_y = frame().y();
1458 m_old_width = frame().width();
1459 m_old_height = frame().height();
1460 }
1461
1462 fullscreen = true; 1451 fullscreen = true;
1463 frame().setFullscreen(true); 1452 frame().setFullscreen(true);
1464 1453
1465 // dont call Window::moveResize here, it might ignore the 1454 setFullscreenLayer(); // calls stateSig().notify()
1466 // resize if win state is not resizable;
1467 // instead we call frame resize directly
1468 // (see tests/fullscreentest.cc)
1469
1470 // be xinerama aware
1471 frame().moveResize(screen().getHeadX(head), screen().getHeadY(head),
1472 screen().getHeadWidth(head), screen().getHeadHeight(head));
1473 sendConfigureNotify();
1474
1475 setFullscreenLayer();
1476 if (!isFocused()) 1455 if (!isFocused())
1477 screen().focusedWindowSig().attach(this); 1456 screen().focusedWindowSig().attach(this);
1478 1457
@@ -1481,21 +1460,8 @@ void FluxboxWindow::setFullscreen(bool flag) {
1481 fullscreen = false; 1460 fullscreen = false;
1482 frame().setFullscreen(false); 1461 frame().setFullscreen(false);
1483 1462
1484 // ensure we apply the sizehints here, otherwise some
1485 // apps (eg xterm) end up a little bit .. crappy (visually)
1486 frame().applySizeHints(m_old_width, m_old_height);
1487
1488 moveResize(m_old_pos_x, m_old_pos_y, m_old_width, m_old_height);
1489 moveToLayer(m_old_layernum); 1463 moveToLayer(m_old_layernum);
1490 1464 stateSig().notify();
1491 m_old_layernum = ::Layer::NORMAL;
1492
1493 if (maximized) {
1494 int tmp = maximized;
1495 maximized = MAX_NONE;
1496 setMaximizedState(tmp);
1497 } else
1498 stateSig().notify();
1499 } 1465 }
1500} 1466}
1501 1467
@@ -1507,8 +1473,7 @@ void FluxboxWindow::setFullscreenLayer() {
1507 getOnHead() != foc->getOnHead()) { 1473 getOnHead() != foc->getOnHead()) {
1508 moveToLayer(::Layer::ABOVE_DOCK); 1474 moveToLayer(::Layer::ABOVE_DOCK);
1509 } else { 1475 } else {
1510 moveToLayer(m_old_layernum); 1476 moveToLayer(::Layer::DESKTOP);
1511 lower();
1512 } 1477 }
1513 stateSig().notify(); 1478 stateSig().notify();
1514 1479
@@ -1520,7 +1485,7 @@ void FluxboxWindow::setFullscreenLayer() {
1520void FluxboxWindow::maximize(int type) { 1485void FluxboxWindow::maximize(int type) {
1521 1486
1522 // nothing to do 1487 // nothing to do
1523 if (type == MAX_NONE) 1488 if (type == FbWinFrame::MAX_NONE)
1524 return; 1489 return;
1525 1490
1526 int new_max = maximized; 1491 int new_max = maximized;
@@ -1529,19 +1494,21 @@ void FluxboxWindow::maximize(int type) {
1529 // when _don't_ we want to toggle? 1494 // when _don't_ we want to toggle?
1530 // - type is horizontal maximise, or 1495 // - type is horizontal maximise, or
1531 // - type is full and we are not maximised horz but already vertically 1496 // - type is full and we are not maximised horz but already vertically
1532 if (type != MAX_HORZ && !(type == MAX_FULL && maximized == MAX_VERT)) 1497 if (type != FbWinFrame::MAX_HORZ &&
1533 new_max ^= MAX_VERT; 1498 (type != FbWinFrame::MAX_FULL || maximized != FbWinFrame::MAX_VERT))
1499 new_max ^= FbWinFrame::MAX_VERT;
1534 1500
1535 // maximize horizontally? 1501 // maximize horizontally?
1536 if (type != MAX_VERT && !(type == MAX_FULL && maximized == MAX_HORZ)) 1502 if (type != FbWinFrame::MAX_VERT &&
1537 new_max ^= MAX_HORZ; 1503 (type != FbWinFrame::MAX_FULL || maximized != FbWinFrame::MAX_HORZ))
1504 new_max ^= FbWinFrame::MAX_HORZ;
1538 1505
1539 setMaximizedState(new_max); 1506 setMaximizedState(new_max);
1540} 1507}
1541 1508
1542void FluxboxWindow::setMaximizedState(int type) { 1509void FluxboxWindow::setMaximizedState(int type) {
1543 1510
1544 if (!m_initialized || isFullscreen() || type == maximized) { 1511 if (!m_initialized || type == maximized) {
1545 // this will interfere with window placement, so we delay it 1512 // this will interfere with window placement, so we delay it
1546 maximized = type; 1513 maximized = type;
1547 return; 1514 return;
@@ -1553,69 +1520,8 @@ void FluxboxWindow::setMaximizedState(int type) {
1553 if (isResizing()) 1520 if (isResizing())
1554 stopResizing(); 1521 stopResizing();
1555 1522
1556 int head = screen().getHead(frame().window()); 1523 maximized = type;
1557 int new_x = frame().x(), new_y = frame().y(); 1524 frame().setMaximized(type);
1558 unsigned int new_w = frame().width(), new_h = frame().height();
1559
1560 // These evaluate whether we need to TOGGLE the value for that field
1561 // Why? If maximize is only set to zero outside this,
1562 // and we only EVER toggle them, then:
1563 // 1) We will never loose the old_ values
1564 // 2) It shouldn't get confused
1565
1566 // Worst case being that some action will toggle the wrong way, but
1567 // we still won't lose the state in that case.
1568
1569 // toggle maximize vertically?
1570 if ((maximized ^ type) & MAX_VERT) {
1571 // already maximized in that direction?
1572 if (maximized & MAX_VERT) {
1573 new_y = m_old_pos_y;
1574 new_h = m_old_height;
1575 } else {
1576 m_old_pos_y = new_y;
1577 m_old_height = new_h;
1578 new_y = screen().maxTop(head);
1579 new_h = screen().maxBottom(head) - new_y - 2*frame().window().borderWidth();
1580 if (!screen().getMaxOverTabs()) {
1581 new_y += yOffset();
1582 new_h -= heightOffset();
1583 }
1584 }
1585 maximized ^= MAX_VERT;
1586 }
1587
1588 // toggle maximize horizontally?
1589 if ((maximized ^ type) & MAX_HORZ) {
1590 // already maximized in that direction?
1591 if (maximized & MAX_HORZ) {
1592 new_x = m_old_pos_x;
1593 new_w = m_old_width;
1594 } else {
1595 // only save if we weren't already maximized
1596 m_old_pos_x = new_x;
1597 m_old_width = new_w;
1598 new_x = screen().maxLeft(head);
1599 new_w = screen().maxRight(head) - new_x - 2*frame().window().borderWidth();
1600 if (!screen().getMaxOverTabs()) {
1601 new_x += xOffset();
1602 new_w -= widthOffset();
1603 }
1604 }
1605 maximized ^= MAX_HORZ;
1606 }
1607
1608 frame().setMaximized(maximized);
1609 // ensure we apply the sizehints here, otherwise some
1610 // apps (eg xterm) end up a little bit .. crappy (visually)
1611
1612 // frankly, that xterm bug was pretty obscure, and it's really annoying not
1613 // being able to maximize my terminals, so we make an option
1614 // but we do fix size hints when restoring the window to normal size
1615 if (!screen().getMaxIgnoreIncrement() || !maximized)
1616 frame().applySizeHints(new_w, new_h, maximized ? true : false);
1617
1618 moveResize(new_x, new_y, new_w, new_h);
1619 1525
1620 // notify listeners that we changed state 1526 // notify listeners that we changed state
1621 stateSig().notify(); 1527 stateSig().notify();
@@ -1625,21 +1531,21 @@ void FluxboxWindow::setMaximizedState(int type) {
1625 * Maximize window horizontal 1531 * Maximize window horizontal
1626 */ 1532 */
1627void FluxboxWindow::maximizeHorizontal() { 1533void FluxboxWindow::maximizeHorizontal() {
1628 maximize(MAX_HORZ); 1534 maximize(FbWinFrame::MAX_HORZ);
1629} 1535}
1630 1536
1631/** 1537/**
1632 * Maximize window vertical 1538 * Maximize window vertical
1633 */ 1539 */
1634void FluxboxWindow::maximizeVertical() { 1540void FluxboxWindow::maximizeVertical() {
1635 maximize(MAX_VERT); 1541 maximize(FbWinFrame::MAX_VERT);
1636} 1542}
1637 1543
1638/** 1544/**
1639 * Maximize window fully 1545 * Maximize window fully
1640 */ 1546 */
1641void FluxboxWindow::maximizeFull() { 1547void FluxboxWindow::maximizeFull() {
1642 maximize(MAX_FULL); 1548 maximize(FbWinFrame::MAX_FULL);
1643} 1549}
1644 1550
1645void FluxboxWindow::setWorkspace(int n) { 1551void FluxboxWindow::setWorkspace(int n) {
@@ -3248,7 +3154,7 @@ void FluxboxWindow::startResizing(int x, int y, ReferenceCorner dir) {
3248 m_resize_corner = dir; 3154 m_resize_corner = dir;
3249 3155
3250 resizing = true; 3156 resizing = true;
3251 maximized = MAX_NONE; 3157 maximized = FbWinFrame::MAX_NONE;
3252 frame().setMaximized(maximized); 3158 frame().setMaximized(maximized);
3253 3159
3254 const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme()->upperLeftAngleCursor() : 3160 const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme()->upperLeftAngleCursor() :
@@ -3541,32 +3447,6 @@ bool FluxboxWindow::isTransient() const {
3541 return (m_client && m_client->isTransient()); 3447 return (m_client && m_client->isTransient());
3542} 3448}
3543 3449
3544int FluxboxWindow::normalX() const {
3545 if (maximized & MAX_HORZ || fullscreen)
3546 return m_old_pos_x;
3547 return x();
3548}
3549
3550int FluxboxWindow::normalY() const {
3551 if (maximized & MAX_VERT || fullscreen)
3552 return m_old_pos_y;
3553 return y();
3554}
3555
3556unsigned int FluxboxWindow::normalWidth() const {
3557 if (maximized & MAX_HORZ || fullscreen)
3558 return m_old_width;
3559 return width();
3560}
3561
3562unsigned int FluxboxWindow::normalHeight() const {
3563 if (maximized & MAX_VERT || fullscreen)
3564 return m_old_height;
3565 if (shaded)
3566 return frame().normalHeight();
3567 return height();
3568}
3569
3570int FluxboxWindow::initialState() const { return m_client->initial_state; } 3450int FluxboxWindow::initialState() const { return m_client->initial_state; }
3571 3451
3572void FluxboxWindow::fixsize() { 3452void FluxboxWindow::fixsize() {