mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
internal/ui: remove panic in adjustWindowSize
This commit is contained in:
parent
55308e2d75
commit
2ef823ccd2
@ -219,8 +219,8 @@ func dipToGLFWPixel(x float64, scale float64) float64 {
|
||||
return x
|
||||
}
|
||||
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int) {
|
||||
return x, y
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int, error) {
|
||||
return x, y, nil
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -2113,7 +2113,12 @@ func (u *UserInterface) setWindowPositionInDIP(x, y int, monitor *Monitor) error
|
||||
s := monitor.DeviceScaleFactor()
|
||||
xf := dipToGLFWPixel(float64(x), s)
|
||||
yf := dipToGLFWPixel(float64(y), s)
|
||||
if x, y := u.adjustWindowPosition(mx+int(xf), my+int(yf), monitor); f {
|
||||
|
||||
x, y, err = u.adjustWindowPosition(mx+int(xf), my+int(yf), monitor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if f {
|
||||
u.setOrigWindowPos(x, y)
|
||||
} else {
|
||||
if err := u.window.SetPos(x, y); err != nil {
|
||||
|
@ -131,8 +131,8 @@ func dipToGLFWPixel(x float64, deviceScaleFactor float64) float64 {
|
||||
return x * deviceScaleFactor
|
||||
}
|
||||
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int) {
|
||||
return x, y
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int, error) {
|
||||
return x, y, nil
|
||||
}
|
||||
|
||||
func initialMonitorByOS() (*Monitor, error) {
|
||||
|
@ -110,9 +110,9 @@ func dipToGLFWPixel(x float64, deviceScaleFactor float64) float64 {
|
||||
return x * deviceScaleFactor
|
||||
}
|
||||
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int) {
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int, error) {
|
||||
if microsoftgdk.IsXbox() {
|
||||
return x, y
|
||||
return x, y, nil
|
||||
}
|
||||
|
||||
mx := monitor.boundsInGLFWPixels.Min.X
|
||||
@ -124,12 +124,12 @@ func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, i
|
||||
}
|
||||
t, err := _GetSystemMetrics(_SM_CYCAPTION)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return 0, 0, err
|
||||
}
|
||||
if y < my+int(t) {
|
||||
y = my + int(t)
|
||||
}
|
||||
return x, y
|
||||
return x, y, nil
|
||||
}
|
||||
|
||||
func initialMonitorByOS() (*Monitor, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user