Skip to content

Commit 437f5b5

Browse files
committed
Fix invalid calculation of rect center point
1 parent 2fa5bd4 commit 437f5b5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,10 @@ def set_pos(self, rect: Rect, placement: Optional[Placement] = None):
458458
# check if Window will fit on the Display it's being moved to. If not, adjust the rect to fit
459459
# use center point because top left might be out of bounds due to drop shadow and offset, which may
460460
# lead to `MONITOR_DEFAULTTONEAREST` picking the wrong display
461-
target_display_rect = self.get_closest_display_rect((rect[2] - rect[0], rect[3] - rect[1]))
461+
target_display_rect = self.get_closest_display_rect((
462+
rect[0] + (size_from_rect(rect)[0] // 2),
463+
rect[1] + (size_from_rect(rect)[1] // 2)
464+
))
462465
rect = self.rebound(rect, to_rect=target_display_rect, offset=offset)
463466

464467
resizable = self.is_resizable()

0 commit comments

Comments
 (0)