mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +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
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int) {
|
func (u *UserInterface) adjustWindowPosition(x, y int, monitor *Monitor) (int, int, error) {
|
||||||
return x, y
|
return x, y, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -2113,7 +2113,12 @@ func (u *UserInterface) setWindowPositionInDIP(x, y int, monitor *Monitor) error
|
|||||||
s := monitor.DeviceScaleFactor()
|
s := monitor.DeviceScaleFactor()
|
||||||
xf := dipToGLFWPixel(float64(x), s)
|
xf := dipToGLFWPixel(float64(x), s)
|
||||||
yf := dipToGLFWPixel(float64(y), 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)
|
u.setOrigWindowPos(x, y)
|
||||||
} else {
|
} else {
|
||||||
if err := u.window.SetPos(x, y); err != nil {
|
if err := u.window.SetPos(x, y); err != nil {
|
||||||
|
@ -131,8 +131,8 @@ func dipToGLFWPixel(x float64, deviceScaleFactor float64) float64 {
|
|||||||
return x * deviceScaleFactor
|
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) {
|
||||||
return x, y
|
return x, y, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialMonitorByOS() (*Monitor, error) {
|
func initialMonitorByOS() (*Monitor, error) {
|
||||||
|
@ -110,9 +110,9 @@ func dipToGLFWPixel(x float64, deviceScaleFactor float64) float64 {
|
|||||||
return x * deviceScaleFactor
|
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() {
|
if microsoftgdk.IsXbox() {
|
||||||
return x, y
|
return x, y, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
mx := monitor.boundsInGLFWPixels.Min.X
|
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)
|
t, err := _GetSystemMetrics(_SM_CYCAPTION)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
if y < my+int(t) {
|
if y < my+int(t) {
|
||||||
y = my + int(t)
|
y = my + int(t)
|
||||||
}
|
}
|
||||||
return x, y
|
return x, y, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialMonitorByOS() (*Monitor, error) {
|
func initialMonitorByOS() (*Monitor, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user