aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-04-10 20:40:15 (GMT)
committerMathias Gumz <akira@fluxbox.org>2016-06-26 14:21:02 (GMT)
commit484c33bf25a37952a91123fb728e4b983e70f531 (patch)
treeaca11c7da7e7310990cfc08e292676f1b7b0924a
parent6201286cdfebfb3d4aab42d85cf53b94a3c95c5a (diff)
downloadfluxbox-484c33bf25a37952a91123fb728e4b983e70f531.zip
fluxbox-484c33bf25a37952a91123fb728e4b983e70f531.tar.bz2
prevent clients from positioning out of workspace
Still enough stupid ones around which ask for 0,0 (despite there's a panel ...) or restore a position on a VGA screen which they stored while being on a 4k screen. Otoh, do not forcefully position the window just because the topleft position is outside any head, this can still be desired and isn't a problem. Actually, the corner could be covered by the close button and if *only* it is onscreen the window can hardly by used or seen.
-rw-r--r--src/Window.cc41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 109b522..f800e85 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -457,14 +457,43 @@ void FluxboxWindow::init() {
457 457
458 setWindowType(m_client->getWindowType()); 458 setWindowType(m_client->getWindowType());
459 459
460 bool is_visible = isWindowVisibleOnSomeHeadOrScreen(*this); 460 if (fluxbox.isStartup()) {
461 461 m_placed = true;
462 if (fluxbox.isStartup()) 462 } else if (m_client->normal_hint_flags & (PPosition|USPosition)) {
463 m_placed = true; 463 m_placed = true;
464 else if (m_client->normal_hint_flags & (PPosition|USPosition)) { 464 // sanitize explicit position
465 m_placed = is_visible; 465 int head = screen().getHead(fbWindow());
466 if (head == 0 && screen().hasXinerama())
467 head = screen().getCurrHead();
468 int left = screen().maxLeft(head), top = screen().maxTop(head),
469 btm = screen().maxBottom(head), rght = screen().maxRight(head);
470 const int margin = hasTitlebar() ? 32 : 8;
471 // ensure the window intersects with the workspace x-axis
472 if (int(frame().x() + frame().width()) < left) {
473 left += margin - frame().width();
474 } else if (frame().x() > rght) {
475 left = rght - margin;
476 } else {
477 left = frame().x();
478 }
479 if (hasTitlebar()) {
480 // ensure the titlebar is inside the workspace
481 top = std::max(top, std::min(frame().y(), btm - margin));
482 } else {
483 // ensure "something" is inside the workspace
484 if (int(frame().y() + frame().height()) < top)
485 top += margin - frame().height();
486 else if (frame().y() > btm)
487 top = btm - margin;
488 else
489 top = frame().y();
490 }
491 frame().move(left, top);
466 } else { 492 } else {
467 if (!is_visible) { 493 if (!isWindowVisibleOnSomeHeadOrScreen(*this)) {
494 // this probably should never happen, but if a window
495 // unexplicitly has its topleft corner outside any screen,
496 // move it to the current screen and ensure it's just placed
468 int cur = screen().getHead(fbWindow()); 497 int cur = screen().getHead(fbWindow());
469 move(screen().getHeadX(cur), screen().getHeadY(cur)); 498 move(screen().getHeadX(cur), screen().getHeadY(cur));
470 m_placed = false; // allow placement strategy to fix position 499 m_placed = false; // allow placement strategy to fix position