aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 725d4b5..507a58f 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -2115,17 +2115,20 @@ int BScreen::getHead(const FbTk::FbWindow &win) const {
2115 int cx = win.x() + static_cast<int>(win.width() / 2); 2115 int cx = win.x() + static_cast<int>(win.width() / 2);
2116 int cy = win.y() + static_cast<int>(win.height() / 2); 2116 int cy = win.y() + static_cast<int>(win.height() / 2);
2117 2117
2118 long dist = -1; 2118 head = getHead(cx, cy);
2119 2119 if ( head == 0 ) {
2120 int i; 2120 // if the center of the window is not on any head then select
2121 for (i = 0; i < m_xinerama_num_heads; ++i) { 2121 // the head which center is nearest to the window center
2122 2122 long dist = -1;
2123 XineramaHeadInfo& hi = m_xinerama_headinfo[i]; 2123 int i;
2124 int d = calcSquareDistance(cx, cy, hi.x() + (hi.width() / 2), hi.y() + (hi.height() / 2)); 2124 for (i = 0; i < m_xinerama_num_heads; ++i) {
2125 2125 XineramaHeadInfo& hi = m_xinerama_headinfo[i];
2126 if (dist == -1 || d < dist) { // found a closer head 2126 int d = calcSquareDistance(cx, cy,
2127 head = i + 1; 2127 hi.x() + (hi.width() / 2), hi.y() + (hi.height() / 2));
2128 dist = d; 2128 if (dist == -1 || d < dist) { // found a closer head
2129 head = i + 1;
2130 dist = d;
2131 }
2129 } 2132 }
2130 } 2133 }
2131 } 2134 }