aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-05-01 12:27:45 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-05-01 12:27:45 (GMT)
commitd6bc8d753e85ece940f5ec932fb71ba44b3d297b (patch)
tree4315cf0dfffea74d709a8d10baf69cf31c32b510
parent9b98102c84ccebbb803249ea0291d7d60481bfa3 (diff)
downloadfluxbox_paul-d6bc8d753e85ece940f5ec932fb71ba44b3d297b.zip
fluxbox_paul-d6bc8d753e85ece940f5ec932fb71ba44b3d297b.tar.bz2
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
-rw-r--r--src/Screen.cc37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index e3df8a0..17615fe 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -175,6 +175,10 @@ int anotherWMRunning(Display *display, XErrorEvent *) {
175} 175}
176 176
177 177
178int calcSquareDistance(int x1, int y1, int x2, int y2) {
179 return (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
180}
181
178class TabPlacementMenuItem: public FbTk::RadioMenuItem { 182class TabPlacementMenuItem: public FbTk::RadioMenuItem {
179public: 183public:
180 TabPlacementMenuItem(FbTk::FbString & label, BScreen &screen, 184 TabPlacementMenuItem(FbTk::FbString & label, BScreen &screen,
@@ -2022,11 +2026,36 @@ int BScreen::getHead(int x, int y) const {
2022 return 0; 2026 return 0;
2023} 2027}
2024 2028
2029
2025int BScreen::getHead(const FbTk::FbWindow &win) const { 2030int BScreen::getHead(const FbTk::FbWindow &win) const {
2026 if (hasXinerama()) 2031
2027 return getHead(win.x() + win.width()/2, win.y() + win.height()/2); 2032 int head = 0; // whole screen
2028 else 2033
2029 return 0; 2034#if XINERAMA
2035 if (hasXinerama()) {
2036
2037 // cast needed to prevent win.x() become "unsigned int" which is bad
2038 // since it might become negative
2039 int cx = win.x() + static_cast<int>(win.width() / 2);
2040 int cy = win.y() + static_cast<int>(win.height() / 2);
2041
2042 long dist = -1;
2043
2044 int i;
2045 for (i = 0; i < m_xinerama_num_heads; ++i) {
2046
2047 XineramaHeadInfo& hi = m_xinerama_headinfo[i];
2048 int d = calcSquareDistance(cx, cy, hi.x + (hi.width / 2), hi.y + (hi.height / 2));
2049
2050 if (dist == -1 || d < dist) { // found a closer head
2051 head = i + 1;
2052 dist = d;
2053 }
2054 }
2055 }
2056#endif
2057
2058 return head;
2030} 2059}
2031 2060
2032 2061