mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
ui: Avoid glfw.GetCurrentContext for threading issues
This commit is contained in:
parent
b5344bc994
commit
e971f6d41c
@ -240,7 +240,7 @@ func ScreenSizeInFullscreen() (int, int) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
v = currentMonitor().GetVideoMode()
|
v = currentUI.currentMonitor().GetVideoMode()
|
||||||
}
|
}
|
||||||
return v.Width, v.Height
|
return v.Width, v.Height
|
||||||
}
|
}
|
||||||
@ -501,7 +501,7 @@ func DeviceScaleFactor() float64 {
|
|||||||
f := 0.0
|
f := 0.0
|
||||||
u := currentUI
|
u := currentUI
|
||||||
if !u.isRunning() {
|
if !u.isRunning() {
|
||||||
return devicescale.GetAt(currentMonitor().GetPos())
|
return devicescale.GetAt(u.currentMonitor().GetPos())
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = u.runOnMainThread(func() error {
|
_ = u.runOnMainThread(func() error {
|
||||||
@ -813,5 +813,5 @@ func (u *userInterface) currentMonitor() *glfw.Monitor {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
// Get the monitor which the current window belongs to. This requires OS API.
|
// Get the monitor which the current window belongs to. This requires OS API.
|
||||||
return currentMonitor()
|
return u.currentMonitorImpl()
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func adjustWindowPosition(x, y int) (int, int) {
|
|||||||
return x, y
|
return x, y
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentMonitor() *glfw.Monitor {
|
func (u *userInterface) currentMonitorImpl() *glfw.Monitor {
|
||||||
x := C.int(0)
|
x := C.int(0)
|
||||||
y := C.int(0)
|
y := C.int(0)
|
||||||
C.currentMonitorPos(&x, &y)
|
C.currentMonitorPos(&x, &y)
|
||||||
|
@ -33,9 +33,9 @@ func adjustWindowPosition(x, y int) (int, int) {
|
|||||||
return x, y
|
return x, y
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentMonitor() *glfw.Monitor {
|
func (u *userInterface) currentMonitorImpl() *glfw.Monitor {
|
||||||
// TODO: Return more appropriate display.
|
// TODO: Return more appropriate display.
|
||||||
w := glfw.GetCurrentContext()
|
w := u.window
|
||||||
wx, wy := w.GetPos()
|
wx, wy := w.GetPos()
|
||||||
for _, m := range glfw.GetMonitors() {
|
for _, m := range glfw.GetMonitors() {
|
||||||
mx, my := m.GetPos()
|
mx, my := m.GetPos()
|
||||||
|
@ -121,7 +121,7 @@ func adjustWindowPosition(x, y int) (int, int) {
|
|||||||
return x, y
|
return x, y
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentMonitor() *glfw.Monitor {
|
func (u *userInterface) currentMonitorImpl() *glfw.Monitor {
|
||||||
w, err := getActiveWindow()
|
w, err := getActiveWindow()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user