Skip to content

Commit 1c679a9

Browse files
committed
Adjust window position when it is outside of screen
1 parent 8bd3b15 commit 1c679a9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ public final class SuggestionWidgetController {
176176
)
177177
widgetWindow.setFrame(anchorFrame, display: false)
178178

179+
let proposedPanelX = anchorFrame.maxX + 8
180+
let putPanelToTheRight = screen.frame.maxX > proposedPanelX + 450
181+
179182
let panelFrame = CGRect(
180-
x: anchorFrame.maxX + 8,
181-
y: anchorFrame.minY - 300 + 30,
183+
x: putPanelToTheRight ? proposedPanelX : anchorFrame.maxX - 450,
184+
y: putPanelToTheRight ? anchorFrame.minY - 300 + 30 : anchorFrame.minY - 300 - 4,
182185
width: 450,
183186
height: 300
184187
)

0 commit comments

Comments
 (0)