all repos — fluxbox @ d6bc8d753e85ece940f5ec932fb71ba44b3d297b

custom fork of the fluxbox windowmanager

bugfix: moving (the center of) a maximized window out of a xinerama head could result in maximizing it over all heads

the old way of deciding which head to (re)maximize the current window
was to just test if the center of the window is INSIDE which head.

now we calculate the closest head which fixes the problem
Mathias Gumz akira at fluxbox dot org
commit

d6bc8d753e85ece940f5ec932fb71ba44b3d297b

parent

9b98102c84ccebbb803249ea0291d7d60481bfa3

1 files changed, 33 insertions(+), 4 deletions(-)

jump to
M src/Screen.ccsrc/Screen.cc

@@ -175,6 +175,10 @@ return -1;

} +int calcSquareDistance(int x1, int y1, int x2, int y2) { + return (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1); +} + class TabPlacementMenuItem: public FbTk::RadioMenuItem { public: TabPlacementMenuItem(FbTk::FbString & label, BScreen &screen,

@@ -2022,11 +2026,36 @@ #endif // XINERAMA

return 0; } + int BScreen::getHead(const FbTk::FbWindow &win) const { - if (hasXinerama()) - return getHead(win.x() + win.width()/2, win.y() + win.height()/2); - else - return 0; + + int head = 0; // whole screen + +#if XINERAMA + if (hasXinerama()) { + + // cast needed to prevent win.x() become "unsigned int" which is bad + // since it might become negative + int cx = win.x() + static_cast<int>(win.width() / 2); + int cy = win.y() + static_cast<int>(win.height() / 2); + + long dist = -1; + + int i; + for (i = 0; i < m_xinerama_num_heads; ++i) { + + XineramaHeadInfo& hi = m_xinerama_headinfo[i]; + int d = calcSquareDistance(cx, cy, hi.x + (hi.width / 2), hi.y + (hi.height / 2)); + + if (dist == -1 || d < dist) { // found a closer head + head = i + 1; + dist = d; + } + } + } +#endif + + return head; }