aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc135
1 files changed, 82 insertions, 53 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 133ccd2..767aff5 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -267,6 +267,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
267 m_old_width(1), m_old_height(1), 267 m_old_width(1), m_old_height(1),
268 m_last_button_x(0), m_last_button_y(0), 268 m_last_button_x(0), m_last_button_y(0),
269 m_frame(client.screen(), tm, client.screen().imageControl(), layer, 0, 0, 100, 100), 269 m_frame(client.screen(), tm, client.screen().imageControl(), layer, 0, 0, 100, 100),
270 m_placed(false),
270 m_layernum(layer.getLayerNum()), 271 m_layernum(layer.getLayerNum()),
271 m_old_layernum(0), 272 m_old_layernum(0),
272 m_parent(client.screen().rootWindow()), 273 m_parent(client.screen().rootWindow()),
@@ -354,10 +355,6 @@ FluxboxWindow::~FluxboxWindow() {
354 355
355void FluxboxWindow::init() { 356void FluxboxWindow::init() {
356 m_attaching_tab = 0; 357 m_attaching_tab = 0;
357 // magic to detect if moved by hints
358 // don't use 0, since setting maximized or fullscreen on the window will set
359 // this to 0
360 m_old_pos_x = m_screen.width();
361 358
362 assert(m_client); 359 assert(m_client);
363 m_client->setFluxboxWindow(this); 360 m_client->setFluxboxWindow(this);
@@ -469,10 +466,8 @@ void FluxboxWindow::init() {
469 if (m_workspace_number >= screen().numberOfWorkspaces()) 466 if (m_workspace_number >= screen().numberOfWorkspaces())
470 m_workspace_number = screen().currentWorkspaceID(); 467 m_workspace_number = screen().currentWorkspaceID();
471 468
472 bool place_window = (m_old_pos_x == static_cast<signed>(m_screen.width()));
473
474 if (fluxbox.isStartup()) 469 if (fluxbox.isStartup())
475 place_window = false; 470 m_placed = true;
476 else if (m_client->isTransient() || 471 else if (m_client->isTransient() ||
477 m_client->normal_hint_flags & (PPosition|USPosition)) { 472 m_client->normal_hint_flags & (PPosition|USPosition)) {
478 473
@@ -483,7 +478,7 @@ void FluxboxWindow::init() {
483 real_y >= 0 && 478 real_y >= 0 &&
484 real_x <= (signed) screen().width() && 479 real_x <= (signed) screen().width() &&
485 real_y <= (signed) screen().height()) 480 real_y <= (signed) screen().height())
486 place_window = false; 481 m_placed = true;
487 482
488 } 483 }
489/* 484/*
@@ -514,18 +509,10 @@ void FluxboxWindow::init() {
514 m_client->applySizeHints(real_width, real_height); 509 m_client->applySizeHints(real_width, real_height);
515 real_height += frame().titlebarHeight() + frame().handleHeight(); 510 real_height += frame().titlebarHeight() + frame().handleHeight();
516 511
517 if (!place_window) 512 if (m_placed)
518 moveResize(frame().x(), frame().y(), real_width, real_height); 513 moveResize(frame().x(), frame().y(), real_width, real_height);
519 514
520 screen().getWorkspace(m_workspace_number)->addWindow(*this, place_window); 515 screen().getWorkspace(m_workspace_number)->addWindow(*this, !m_placed);
521
522 if (maximized && functions.maximize) { // start maximized
523 // This will set it to the appropriate style of maximisation
524 int req_maximized = maximized;
525 // NOTE: don't manually change maximized ANYWHERE else, it isn't safe
526 maximized = MAX_NONE; // it is not maximized now
527 maximize(req_maximized);
528 }
529 516
530 setFocusFlag(false); // update graphics before mapping 517 setFocusFlag(false); // update graphics before mapping
531 518
@@ -550,6 +537,19 @@ void FluxboxWindow::init() {
550 m_focused = false; 537 m_focused = false;
551 } 538 }
552 539
540 // maximization won't work if we think the window is fullscreen
541 bool tmp_fullscreen = fullscreen;
542 fullscreen = false;
543 if (maximized) {
544 int tmp = maximized;
545 maximized = MAX_NONE;
546 setMaximizedState(tmp);
547 }
548
549 if (tmp_fullscreen)
550 setFullscreen(true);
551
552
553 struct timeval now; 553 struct timeval now;
554 gettimeofday(&now, NULL); 554 gettimeofday(&now, NULL);
555 m_creation_time = now.tv_sec; 555 m_creation_time = now.tv_sec;
@@ -1185,14 +1185,10 @@ void FluxboxWindow::move(int x, int y) {
1185} 1185}
1186 1186
1187void FluxboxWindow::resize(unsigned int width, unsigned int height) { 1187void FluxboxWindow::resize(unsigned int width, unsigned int height) {
1188 int old_x = m_old_pos_x; 1188 // don't set window as placed, since we're only resizing
1189 1189 bool placed = m_placed;
1190 moveResize(frame().x(), frame().y(), width, height); 1190 moveResize(frame().x(), frame().y(), width, height);
1191 1191 m_placed = placed;
1192 // magic to detect if moved during initialisation
1193 // we restore the old state, because we were a resize, not a moveResize!
1194 if (!m_initialized)
1195 m_old_pos_x = old_x;
1196} 1192}
1197 1193
1198// send_event is just an override 1194// send_event is just an override
@@ -1200,10 +1196,7 @@ void FluxboxWindow::moveResize(int new_x, int new_y,
1200 unsigned int new_width, unsigned int new_height, 1196 unsigned int new_width, unsigned int new_height,
1201 bool send_event) { 1197 bool send_event) {
1202 1198
1203 // magic to detect if moved during initialisation 1199 m_placed = true;
1204 if (!m_initialized)
1205 m_old_pos_x = 1;
1206
1207 send_event = send_event || frame().x() != new_x || frame().y() != new_y; 1200 send_event = send_event || frame().x() != new_x || frame().y() != new_y;
1208 1201
1209 if ((new_width != frame().width() || new_height != frame().height()) && 1202 if ((new_width != frame().width() || new_height != frame().height()) &&
@@ -1236,9 +1229,7 @@ void FluxboxWindow::moveResize(int new_x, int new_y,
1236void FluxboxWindow::moveResizeForClient(int new_x, int new_y, 1229void FluxboxWindow::moveResizeForClient(int new_x, int new_y,
1237 unsigned int new_width, unsigned int new_height, int gravity, unsigned int client_bw) { 1230 unsigned int new_width, unsigned int new_height, int gravity, unsigned int client_bw) {
1238 1231
1239 // magic to detect if moved during initialisation 1232 m_placed = true;
1240 if (!m_initialized)
1241 m_old_pos_x = 1;
1242 frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw); 1233 frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw);
1243 setFocusFlag(m_focused); 1234 setFocusFlag(m_focused);
1244 shaded = false; 1235 shaded = false;
@@ -1517,13 +1508,16 @@ void FluxboxWindow::deiconify(bool reassoc, bool do_raise) {
1517*/ 1508*/
1518void FluxboxWindow::setFullscreen(bool flag) { 1509void FluxboxWindow::setFullscreen(bool flag) {
1519 1510
1511 if (!m_initialized) {
1512 // this will interfere with window placement, so we delay it
1513 fullscreen = flag;
1514 return;
1515 }
1516
1520 const int head = screen().getHead(fbWindow()); 1517 const int head = screen().getHead(fbWindow());
1521 1518
1522 if (flag && !isFullscreen()) { 1519 if (flag && !isFullscreen()) {
1523 1520
1524 if (isIconic())
1525 deiconify();
1526
1527 if (isShaded()) 1521 if (isShaded())
1528 shade(); 1522 shade();
1529 1523
@@ -1533,10 +1527,12 @@ void FluxboxWindow::setFullscreen(bool flag) {
1533 m_old_decoration_mask = decorationMask(); 1527 m_old_decoration_mask = decorationMask();
1534 1528
1535 m_old_layernum = layerNum(); 1529 m_old_layernum = layerNum();
1536 m_old_pos_x = frame().x(); 1530 if (!maximized) {
1537 m_old_pos_y = frame().y(); 1531 m_old_pos_x = frame().x();
1538 m_old_width = frame().width(); 1532 m_old_pos_y = frame().y();
1539 m_old_height = frame().height(); 1533 m_old_width = frame().width();
1534 m_old_height = frame().height();
1535 }
1540 1536
1541 // clear decorations 1537 // clear decorations
1542 setDecorationMask(0); 1538 setDecorationMask(0);
@@ -1586,7 +1582,12 @@ void FluxboxWindow::setFullscreen(bool flag) {
1586 1582
1587 m_old_layernum = ::Layer::NORMAL; 1583 m_old_layernum = ::Layer::NORMAL;
1588 1584
1589 stateSig().notify(); 1585 if (maximized) {
1586 int tmp = maximized;
1587 maximized = MAX_NONE;
1588 setMaximizedState(tmp);
1589 } else
1590 stateSig().notify();
1590 } 1591 }
1591} 1592}
1592 1593
@@ -1599,8 +1600,32 @@ void FluxboxWindow::maximize(int type) {
1599 if (isFullscreen() || type == MAX_NONE) 1600 if (isFullscreen() || type == MAX_NONE)
1600 return; 1601 return;
1601 1602
1602 if (isIconic()) 1603 int new_max = maximized;
1603 deiconify(); 1604
1605 // toggle maximize vertically?
1606 // when _don't_ we want to toggle?
1607 // - type is horizontal maximise, or
1608 // - type is full and we are not maximised horz but already vertically
1609 if (type != MAX_HORZ && !(type == MAX_FULL && maximized == MAX_VERT))
1610 new_max ^= MAX_VERT;
1611
1612 // maximize horizontally?
1613 if (type != MAX_VERT && !(type == MAX_FULL && maximized == MAX_HORZ))
1614 new_max ^= MAX_HORZ;
1615
1616 setMaximizedState(new_max);
1617}
1618
1619void FluxboxWindow::setMaximizedState(int type) {
1620
1621 if (!m_initialized) {
1622 // this will interfere with the window getting placed, so we delay it
1623 maximized = type;
1624 return;
1625 }
1626
1627 if (isFullscreen() || type == maximized)
1628 return;
1604 1629
1605 if (isShaded()) 1630 if (isShaded())
1606 shade(); 1631 shade();
@@ -1614,8 +1639,6 @@ void FluxboxWindow::maximize(int type) {
1614 new_w = frame().width(), 1639 new_w = frame().width(),
1615 new_h = frame().height(); 1640 new_h = frame().height();
1616 1641
1617 int orig_max = maximized;
1618
1619 // These evaluate whether we need to TOGGLE the value for that field 1642 // These evaluate whether we need to TOGGLE the value for that field
1620 // Why? If maximize is only set to zero outside this, 1643 // Why? If maximize is only set to zero outside this,
1621 // and we only EVER toggle them, then: 1644 // and we only EVER toggle them, then:
@@ -1626,12 +1649,9 @@ void FluxboxWindow::maximize(int type) {
1626 // we still won't lose the state in that case. 1649 // we still won't lose the state in that case.
1627 1650
1628 // toggle maximize vertically? 1651 // toggle maximize vertically?
1629 // when _don't_ we want to toggle? 1652 if ((maximized ^ type) & MAX_VERT) {
1630 // - type is horizontal maximise, or
1631 // - type is full and we are not maximised horz but already vertically
1632 if (type != MAX_HORZ && !(type == MAX_FULL && orig_max == MAX_VERT)) {
1633 // already maximized in that direction? 1653 // already maximized in that direction?
1634 if (orig_max & MAX_VERT) { 1654 if (maximized & MAX_VERT) {
1635 new_y = m_old_pos_y; 1655 new_y = m_old_pos_y;
1636 new_h = m_old_height; 1656 new_h = m_old_height;
1637 } else { 1657 } else {
@@ -1647,10 +1667,10 @@ void FluxboxWindow::maximize(int type) {
1647 maximized ^= MAX_VERT; 1667 maximized ^= MAX_VERT;
1648 } 1668 }
1649 1669
1650 // maximize horizontally? 1670 // toggle maximize horizontally?
1651 if (type != MAX_VERT && !(type == MAX_FULL && orig_max == MAX_HORZ)) { 1671 if ((maximized ^ type) & MAX_HORZ) {
1652 // already maximized in that direction? 1672 // already maximized in that direction?
1653 if (orig_max & MAX_HORZ) { 1673 if (maximized & MAX_HORZ) {
1654 new_x = m_old_pos_x; 1674 new_x = m_old_pos_x;
1655 new_w = m_old_width; 1675 new_w = m_old_width;
1656 } else { 1676 } else {
@@ -1711,7 +1731,6 @@ void FluxboxWindow::maximizeFull() {
1711 maximize(MAX_FULL); 1731 maximize(MAX_FULL);
1712} 1732}
1713 1733
1714
1715void FluxboxWindow::setWorkspace(int n) { 1734void FluxboxWindow::setWorkspace(int n) {
1716 unsigned int old_wkspc = m_workspace_number; 1735 unsigned int old_wkspc = m_workspace_number;
1717 1736
@@ -4080,3 +4099,13 @@ int FluxboxWindow::getDecoMaskFromString(const string &str_label) {
4080 mask = strtol(str_label.c_str(), NULL, 0); 4099 mask = strtol(str_label.c_str(), NULL, 0);
4081 return mask; 4100 return mask;
4082} 4101}
4102
4103void FluxboxWindow::setOnHead(int head) {
4104 if (head > 0 && head <= screen().numHeads()) {
4105 int cur = screen().getHead(fbWindow());
4106 bool placed = m_placed;
4107 move(screen().getHeadX(head) + frame().x() - screen().getHeadX(cur),
4108 screen().getHeadY(head) + frame().y() - screen().getHeadY(cur));
4109 m_placed = placed;
4110 }
4111}