mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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
|
||||
})
|
||||
} else {
|
||||
v = currentMonitor().GetVideoMode()
|
||||
v = currentUI.currentMonitor().GetVideoMode()
|
||||
}
|
||||
return v.Width, v.Height
|
||||
}
|
||||
@ -501,7 +501,7 @@ func DeviceScaleFactor() float64 {
|
||||
f := 0.0
|
||||
u := currentUI
|
||||
if !u.isRunning() {
|
||||
return devicescale.GetAt(currentMonitor().GetPos())
|
||||
return devicescale.GetAt(u.currentMonitor().GetPos())
|
||||
}
|
||||
|
||||
_ = u.runOnMainThread(func() error {
|
||||
@ -813,5 +813,5 @@ func (u *userInterface) currentMonitor() *glfw.Monitor {
|
||||
return m
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
||||
func currentMonitor() *glfw.Monitor {
|
||||
func (u *userInterface) currentMonitorImpl() *glfw.Monitor {
|
||||
x := C.int(0)
|
||||
y := C.int(0)
|
||||
C.currentMonitorPos(&x, &y)
|
||||
|
@ -33,9 +33,9 @@ func adjustWindowPosition(x, y int) (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
||||
func currentMonitor() *glfw.Monitor {
|
||||
func (u *userInterface) currentMonitorImpl() *glfw.Monitor {
|
||||
// TODO: Return more appropriate display.
|
||||
w := glfw.GetCurrentContext()
|
||||
w := u.window
|
||||
wx, wy := w.GetPos()
|
||||
for _, m := range glfw.GetMonitors() {
|
||||
mx, my := m.GetPos()
|
||||
|
@ -121,7 +121,7 @@ func adjustWindowPosition(x, y int) (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
||||
func currentMonitor() *glfw.Monitor {
|
||||
func (u *userInterface) currentMonitorImpl() *glfw.Monitor {
|
||||
w, err := getActiveWindow()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Loading…
Reference in New Issue
Block a user