mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
internal/uidriver/glfw: Prefer currentMonitor to get the monitor at deviceScaleFactor
This commit is contained in:
parent
e89f53774c
commit
deba352384
@ -644,13 +644,6 @@ func (u *UserInterface) DeviceScaleFactor() float64 {
|
||||
|
||||
// deviceScaleFactor must be called from the main thread.
|
||||
func (u *UserInterface) deviceScaleFactor() float64 {
|
||||
// Before calling SetWindowPosition, the window's position is not reliable.
|
||||
if u.iwindow.setPositionCalled {
|
||||
// Avoid calling monitor.GetPos if we have the monitor position cached already.
|
||||
if cm := getCachedMonitor(u.window.GetPos()); cm != nil {
|
||||
return devicescale.GetAt(cm.x, cm.y)
|
||||
}
|
||||
}
|
||||
m := u.initMonitor
|
||||
if u.window != nil {
|
||||
m = currentMonitor(u.window)
|
||||
|
@ -26,7 +26,6 @@ import (
|
||||
|
||||
type window struct {
|
||||
ui *UserInterface
|
||||
setPositionCalled bool
|
||||
}
|
||||
|
||||
func (w *window) IsDecorated() bool {
|
||||
@ -212,10 +211,6 @@ func (w *window) SetPosition(x, y int) {
|
||||
|
||||
// setPosition must be called from the main thread
|
||||
func (w *window) setPosition(x, y int) {
|
||||
defer func() {
|
||||
w.setPositionCalled = true
|
||||
}()
|
||||
|
||||
mx, my := currentMonitor(w.ui.window).GetPos()
|
||||
xf := w.ui.toGLFWPixel(float64(x))
|
||||
yf := w.ui.toGLFWPixel(float64(y))
|
||||
|
Loading…
Reference in New Issue
Block a user