diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-27 20:29:35 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-27 20:29:35 (GMT) |
commit | a2ec0c9bdd9ebcc713426a79209b9ca90b4db301 (patch) | |
tree | 3d7b659c38f3b01e4e09a4887dc7b7cf1f73689b /src/Window.cc | |
parent | 84c87a86f9365014b7425c56a2a1051c102df804 (diff) | |
download | fluxbox-a2ec0c9bdd9ebcc713426a79209b9ca90b4db301.zip fluxbox-a2ec0c9bdd9ebcc713426a79209b9ca90b4db301.tar.bz2 |
make FbWinFrame and FluxboxWindow share a WindowState object
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 102 |
1 files changed, 42 insertions, 60 deletions
diff --git a/src/Window.cc b/src/Window.cc index 8f97954..57fa1f5 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -269,9 +269,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): | |||
269 | m_layersig(*this), | 269 | m_layersig(*this), |
270 | m_workspacesig(*this), | 270 | m_workspacesig(*this), |
271 | m_creation_time(0), | 271 | m_creation_time(0), |
272 | moving(false), resizing(false), shaded(false), iconic(false), | 272 | moving(false), resizing(false), iconic(false), stuck(false), |
273 | stuck(false), m_initialized(false), fullscreen(false), | 273 | m_initialized(false), |
274 | maximized(WindowState::MAX_NONE), | ||
275 | m_attaching_tab(0), | 274 | m_attaching_tab(0), |
276 | display(FbTk::App::instance()->display()), | 275 | display(FbTk::App::instance()->display()), |
277 | m_button_grab_x(0), m_button_grab_y(0), | 276 | m_button_grab_x(0), m_button_grab_y(0), |
@@ -292,8 +291,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): | |||
292 | screen().unfocusedWinButtonTheme()), | 291 | screen().unfocusedWinButtonTheme()), |
293 | m_theme(*this, screen().focusedWinFrameTheme(), | 292 | m_theme(*this, screen().focusedWinFrameTheme(), |
294 | screen().unfocusedWinFrameTheme()), | 293 | screen().unfocusedWinFrameTheme()), |
295 | m_frame(client.screen(), m_theme, client.screen().imageControl(), layer, | 294 | m_frame(client.screen(), m_theme, layer, m_state), |
296 | 0, 0, 100, 100), | ||
297 | m_placed(false), | 295 | m_placed(false), |
298 | m_layernum(layer.getLayerNum()), | 296 | m_layernum(layer.getLayerNum()), |
299 | m_old_layernum(0), | 297 | m_old_layernum(0), |
@@ -509,11 +507,11 @@ void FluxboxWindow::init() { | |||
509 | unsigned int real_width = frame().width(), real_height = frame().height(); | 507 | unsigned int real_width = frame().width(), real_height = frame().height(); |
510 | frame().applySizeHints(real_width, real_height); | 508 | frame().applySizeHints(real_width, real_height); |
511 | 509 | ||
510 | screen().getWorkspace(m_workspace_number)->addWindow(*this); | ||
512 | if (m_placed) | 511 | if (m_placed) |
513 | moveResize(frame().x(), frame().y(), real_width, real_height); | 512 | moveResize(frame().x(), frame().y(), real_width, real_height); |
514 | 513 | else | |
515 | if (!m_placed) placeWindow(getOnHead()); | 514 | placeWindow(getOnHead()); |
516 | screen().getWorkspace(m_workspace_number)->addWindow(*this); | ||
517 | 515 | ||
518 | setFocusFlag(false); // update graphics before mapping | 516 | setFocusFlag(false); // update graphics before mapping |
519 | 517 | ||
@@ -522,8 +520,8 @@ void FluxboxWindow::init() { | |||
522 | stick(); | 520 | stick(); |
523 | } | 521 | } |
524 | 522 | ||
525 | if (shaded) { // start shaded | 523 | if (m_state.shaded) { // start shaded |
526 | shaded = false; | 524 | m_state.shaded = false; |
527 | shade(); | 525 | shade(); |
528 | } | 526 | } |
529 | 527 | ||
@@ -542,14 +540,14 @@ void FluxboxWindow::init() { | |||
542 | } | 540 | } |
543 | } | 541 | } |
544 | 542 | ||
545 | if (fullscreen) { | 543 | if (m_state.fullscreen) { |
546 | fullscreen = false; | 544 | m_state.fullscreen = false; |
547 | setFullscreen(true); | 545 | setFullscreen(true); |
548 | } | 546 | } |
549 | 547 | ||
550 | if (maximized) { | 548 | if (m_state.maximized) { |
551 | int tmp = maximized; | 549 | int tmp = m_state.maximized; |
552 | maximized = WindowState::MAX_NONE; | 550 | m_state.maximized = WindowState::MAX_NONE; |
553 | setMaximizedState(tmp); | 551 | setMaximizedState(tmp); |
554 | } | 552 | } |
555 | 553 | ||
@@ -1226,7 +1224,7 @@ void FluxboxWindow::moveResizeForClient(int new_x, int new_y, | |||
1226 | m_placed = true; | 1224 | m_placed = true; |
1227 | frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw); | 1225 | frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw); |
1228 | setFocusFlag(m_focused); | 1226 | setFocusFlag(m_focused); |
1229 | shaded = false; | 1227 | m_state.shaded = false; |
1230 | sendConfigureNotify(); | 1228 | sendConfigureNotify(); |
1231 | 1229 | ||
1232 | if (!moving) { | 1230 | if (!moving) { |
@@ -1449,15 +1447,15 @@ void FluxboxWindow::setFullscreen(bool flag) { | |||
1449 | 1447 | ||
1450 | if (!m_initialized) { | 1448 | if (!m_initialized) { |
1451 | // this will interfere with window placement, so we delay it | 1449 | // this will interfere with window placement, so we delay it |
1452 | fullscreen = flag; | 1450 | m_state.fullscreen = flag; |
1453 | return; | 1451 | return; |
1454 | } | 1452 | } |
1455 | 1453 | ||
1456 | if (flag && !isFullscreen()) { | 1454 | if (flag && !isFullscreen()) { |
1457 | 1455 | ||
1458 | m_old_layernum = layerNum(); | 1456 | m_old_layernum = layerNum(); |
1459 | fullscreen = true; | 1457 | m_state.fullscreen = true; |
1460 | frame().setFullscreen(true); | 1458 | frame().applyState(); |
1461 | 1459 | ||
1462 | setFullscreenLayer(); // calls stateSig().notify() | 1460 | setFullscreenLayer(); // calls stateSig().notify() |
1463 | if (!isFocused()) | 1461 | if (!isFocused()) |
@@ -1465,8 +1463,8 @@ void FluxboxWindow::setFullscreen(bool flag) { | |||
1465 | 1463 | ||
1466 | } else if (!flag && isFullscreen()) { | 1464 | } else if (!flag && isFullscreen()) { |
1467 | 1465 | ||
1468 | fullscreen = false; | 1466 | m_state.fullscreen = false; |
1469 | frame().setFullscreen(false); | 1467 | frame().applyState(); |
1470 | 1468 | ||
1471 | moveToLayer(m_old_layernum); | 1469 | moveToLayer(m_old_layernum); |
1472 | stateSig().notify(); | 1470 | stateSig().notify(); |
@@ -1491,45 +1489,26 @@ void FluxboxWindow::setFullscreenLayer() { | |||
1491 | Maximize window both horizontal and vertical | 1489 | Maximize window both horizontal and vertical |
1492 | */ | 1490 | */ |
1493 | void FluxboxWindow::maximize(int type) { | 1491 | void FluxboxWindow::maximize(int type) { |
1494 | 1492 | int new_max = m_state.queryToggleMaximized(type); | |
1495 | // nothing to do | ||
1496 | if (type == WindowState::MAX_NONE) | ||
1497 | return; | ||
1498 | |||
1499 | int new_max = maximized; | ||
1500 | |||
1501 | // toggle maximize vertically? | ||
1502 | // when _don't_ we want to toggle? | ||
1503 | // - type is horizontal maximise, or | ||
1504 | // - type is full and we are not maximised horz but already vertically | ||
1505 | if (type != WindowState::MAX_HORZ && | ||
1506 | (type != WindowState::MAX_FULL || maximized != WindowState::MAX_VERT)) | ||
1507 | new_max ^= WindowState::MAX_VERT; | ||
1508 | |||
1509 | // maximize horizontally? | ||
1510 | if (type != WindowState::MAX_VERT && | ||
1511 | (type != WindowState::MAX_FULL || maximized != WindowState::MAX_HORZ)) | ||
1512 | new_max ^= WindowState::MAX_HORZ; | ||
1513 | |||
1514 | setMaximizedState(new_max); | 1493 | setMaximizedState(new_max); |
1515 | } | 1494 | } |
1516 | 1495 | ||
1517 | void FluxboxWindow::setMaximizedState(int type) { | 1496 | void FluxboxWindow::setMaximizedState(int type) { |
1518 | 1497 | ||
1519 | if (!m_initialized || type == maximized) { | 1498 | if (!m_initialized || type == m_state.maximized) { |
1520 | // this will interfere with window placement, so we delay it | 1499 | // this will interfere with window placement, so we delay it |
1521 | maximized = type; | 1500 | m_state.maximized = type; |
1522 | return; | 1501 | return; |
1523 | } | 1502 | } |
1524 | 1503 | ||
1525 | if (isResizing()) | 1504 | if (isResizing()) |
1526 | stopResizing(); | 1505 | stopResizing(); |
1527 | 1506 | ||
1528 | maximized = type; | 1507 | m_state.maximized = type; |
1529 | frame().setMaximized(type); | 1508 | frame().applyState(); |
1530 | 1509 | ||
1531 | // notify when struts change, so we can resize accordingly | 1510 | // notify when struts change, so we can resize accordingly |
1532 | if (maximized) | 1511 | if (m_state.maximized) |
1533 | screen().workspaceAreaSig().attach(this); | 1512 | screen().workspaceAreaSig().attach(this); |
1534 | else | 1513 | else |
1535 | screen().workspaceAreaSig().detach(this); | 1514 | screen().workspaceAreaSig().detach(this); |
@@ -1590,27 +1569,27 @@ void FluxboxWindow::shade() { | |||
1590 | if (!decorations.titlebar) | 1569 | if (!decorations.titlebar) |
1591 | return; | 1570 | return; |
1592 | 1571 | ||
1593 | // we're toggling, so if they're equal now, we need to change it | 1572 | m_state.shaded = !m_state.shaded; |
1594 | if (m_initialized && m_frame.isShaded() == shaded) | 1573 | if (!m_initialized) |
1595 | frame().shade(); | 1574 | return; |
1596 | 1575 | ||
1597 | shaded = !shaded; | 1576 | frame().applyState(); |
1598 | stateSig().notify(); | 1577 | stateSig().notify(); |
1599 | // TODO: this should set IconicState, but then we can't focus the window | 1578 | // TODO: this should set IconicState, but then we can't focus the window |
1600 | } | 1579 | } |
1601 | 1580 | ||
1602 | void FluxboxWindow::shadeOn() { | 1581 | void FluxboxWindow::shadeOn() { |
1603 | if (!shaded) | 1582 | if (!m_state.shaded) |
1604 | shade(); | 1583 | shade(); |
1605 | } | 1584 | } |
1606 | 1585 | ||
1607 | void FluxboxWindow::shadeOff() { | 1586 | void FluxboxWindow::shadeOff() { |
1608 | if (shaded) | 1587 | if (m_state.shaded) |
1609 | shade(); | 1588 | shade(); |
1610 | } | 1589 | } |
1611 | 1590 | ||
1612 | void FluxboxWindow::setShaded(bool val) { | 1591 | void FluxboxWindow::setShaded(bool val) { |
1613 | if (val != shaded) | 1592 | if (val != m_state.shaded) |
1614 | shade(); | 1593 | shade(); |
1615 | } | 1594 | } |
1616 | 1595 | ||
@@ -1789,10 +1768,10 @@ void FluxboxWindow::setFocusFlag(bool focus) { | |||
1789 | 1768 | ||
1790 | // if we're fullscreen and another window gains focus on the same head, | 1769 | // if we're fullscreen and another window gains focus on the same head, |
1791 | // then we need to let the user see it | 1770 | // then we need to let the user see it |
1792 | if (fullscreen && !focus) | 1771 | if (m_state.fullscreen && !focus) |
1793 | screen().focusedWindowSig().attach(this); | 1772 | screen().focusedWindowSig().attach(this); |
1794 | 1773 | ||
1795 | if (fullscreen && focus) { | 1774 | if (m_state.fullscreen && focus) { |
1796 | moveToLayer(::Layer::ABOVE_DOCK); | 1775 | moveToLayer(::Layer::ABOVE_DOCK); |
1797 | screen().focusedWindowSig().detach(this); | 1776 | screen().focusedWindowSig().detach(this); |
1798 | } | 1777 | } |
@@ -3149,8 +3128,10 @@ void FluxboxWindow::startResizing(int x, int y, ReferenceCorner dir) { | |||
3149 | m_resize_corner = dir; | 3128 | m_resize_corner = dir; |
3150 | 3129 | ||
3151 | resizing = true; | 3130 | resizing = true; |
3152 | maximized = WindowState::MAX_NONE; | 3131 | m_state.maximized = WindowState::MAX_NONE; |
3153 | frame().setMaximized(maximized); | 3132 | m_state.saveGeometry(frame().x(), frame().y(), |
3133 | frame().width(), frame().height()); | ||
3134 | frame().applyState(); | ||
3154 | 3135 | ||
3155 | const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme()->upperLeftAngleCursor() : | 3136 | const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme()->upperLeftAngleCursor() : |
3156 | (m_resize_corner == RIGHTTOP) ? frame().theme()->upperRightAngleCursor() : | 3137 | (m_resize_corner == RIGHTTOP) ? frame().theme()->upperRightAngleCursor() : |
@@ -3814,11 +3795,12 @@ void FluxboxWindow::setOnHead(int head) { | |||
3814 | } | 3795 | } |
3815 | 3796 | ||
3816 | void FluxboxWindow::placeWindow(int head) { | 3797 | void FluxboxWindow::placeWindow(int head) { |
3817 | int place_x, place_y; | 3798 | int new_x, new_y; |
3818 | // we ignore the return value, | 3799 | // we ignore the return value, |
3819 | // the screen placement strategy is guaranteed to succeed. | 3800 | // the screen placement strategy is guaranteed to succeed. |
3820 | screen().placementStrategy().placeWindow(*this, head, place_x, place_y); | 3801 | screen().placementStrategy().placeWindow(*this, head, new_x, new_y); |
3821 | move(place_x, place_y); | 3802 | m_state.saveGeometry(new_x, new_y, frame().width(), frame().height(), true); |
3803 | move(new_x, new_y); | ||
3822 | } | 3804 | } |
3823 | 3805 | ||
3824 | void FluxboxWindow::setWindowType(Focusable::WindowType type) { | 3806 | void FluxboxWindow::setWindowType(Focusable::WindowType type) { |