Skip to content

Commit

Permalink
#1284: better distance calculations: don't use the corners if the win…
Browse files Browse the repository at this point in the history
…dow if the window is within one of the dimensions (x or y), better debug logging too

git-svn-id: https://xpra.org/svn/Xpra/trunk@13670 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 12, 2016
1 parent 42b3837 commit c0d8ff3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,23 @@ def calculate_OR_offset(self, wx, wy, ww, wh):
geomlog("screen %s lacks monitors information: %s", screen0)
return None
distances = {}
geometries = []
for i, monitor in enumerate(monitors):
plug_name, x, y, w, h = monitor[:5]
if wx>=x and wx+ww<=x+w and wy+wh<=y+h:
geomlog("window fits in monitor %i: %s", i, plug_name)
return None
xdists = (wx-x, wx+ww-x, wx-(x+w), wx+ww-(x+w))
ydists = (wy-y, wy+wh-y, wy-(y+h), wy+wh-(y+h))
if wx>=x and wx+ww<x+w:
xdists = [0]
if wy>=y and wy+wh<y+h:
ydists = [0]
distance = min((abs(v) for v in xdists))+min((abs(v) for v in ydists))
geometries.append((x,y,w,h))
distances[distance] = i
#so it doesn't fit... choose the closest monitor and make it fit
geomlog("OR window distances: %s", distances)
geomlog("OR window distances (%s) to (%s): %s", (wx, wy, ww, wh), geometries, distances)
closest = min(distances.keys())
i = distances[closest]
monitor = monitors[i]
Expand Down

0 comments on commit c0d8ff3

Please sign in to comment.