aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-08-29 20:15:20 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2016-08-30 20:02:59 (GMT)
commit6c4d1123c07f8fe265bbb38920b0ae3d90879d56 (patch)
treee109d396f6ca678cc0d9c3673615326e2850f4bb
parenta5b5be5e09ef4488d7dcebf2091e94b8e4d6e727 (diff)
downloadfluxbox-6c4d1123c07f8fe265bbb38920b0ae3d90879d56.zip
fluxbox-6c4d1123c07f8fe265bbb38920b0ae3d90879d56.tar.bz2
Relative aligmment when changing window head
So far, altering the head would potentially move the window out of the workspace area (by moving a far right/bottom window from a HUUUUUGE to a small screen) This preserves edge alignments (w/ topleft preference), otherwise moves the window to it's relative topleft position on the new head (ie. if it was 10% left and 3% top into the screen, it will still be)
-rw-r--r--src/Window.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 56c78c7..7855f68 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -3926,8 +3926,21 @@ void FluxboxWindow::setOnHead(int head) {
3926 if (head > 0 && head <= screen().numHeads()) { 3926 if (head > 0 && head <= screen().numHeads()) {
3927 int cur = screen().getHead(fbWindow()); 3927 int cur = screen().getHead(fbWindow());
3928 bool placed = m_placed; 3928 bool placed = m_placed;
3929 move(screen().getHeadX(head) + frame().x() - screen().getHeadX(cur), 3929 int x = frame().x(), y = frame().y();
3930 screen().getHeadY(head) + frame().y() - screen().getHeadY(cur)); 3930 const int w = frame().width(), h = frame().height(), bw = frame().window().borderWidth();
3931 const int sx = screen().getHeadX(cur), sw = screen().getHeadWidth(cur),
3932 sy = screen().getHeadY(cur), sh = screen().getHeadHeight(cur);
3933 int d = sx + sw - (x + bw + w);
3934 if (std::abs(sx - x) > bw && std::abs(d) <= bw) // right aligned
3935 x = screen().getHeadX(head) + screen().getHeadWidth(head) - (w + bw + d);
3936 else // calc top-left relative position
3937 x = screen().getHeadWidth(head) * (x - sx) / sw + screen().getHeadX(head);
3938 d = sy + sh - (y + bw + h);
3939 if (std::abs(sy - y) > bw && std::abs(d) <= bw) // bottom aligned
3940 y = screen().getHeadY(head) + screen().getHeadHeight(head) - (h + bw + d);
3941 else // calc top-left relative position
3942 y = screen().getHeadHeight(head) * (y - sy) / sh + screen().getHeadY(head);
3943 move(x, y);
3931 m_placed = placed; 3944 m_placed = placed;
3932 } 3945 }
3933 3946