internal/ui: force to put the window in the initial monitor

To make things simple, let's not put the window outside the initial
monitor.

Updates #1351
Closes #1575
This commit is contained in:
Hajime Hoshi 2022-03-30 01:55:02 +09:00
parent b2e0a7b267
commit feb70963c6

View File

@ -883,6 +883,19 @@ func (u *userInterfaceImpl) init() error {
// setWindowSize refers the current monitor's device scale.
// TODO: currentMonitor is very hard to use correctly. Refactor this.
wx, wy := u.getInitWindowPositionInDIP()
// Force to put the window in the initial monitor (#1575).
if wx < 0 {
wx = 0
}
if wy < 0 {
wy = 0
}
if max := u.initFullscreenWidthInDIP - ww; wx >= max {
wx = max
}
if max := u.initFullscreenHeightInDIP - wh; wy >= max {
wy = max
}
u.setWindowPositionInDIP(wx, wy, u.initMonitor)
u.setWindowSizeInDIP(ww, wh, u.isFullscreen())