mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +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.
|
// deviceScaleFactor must be called from the main thread.
|
||||||
func (u *UserInterface) deviceScaleFactor() float64 {
|
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
|
m := u.initMonitor
|
||||||
if u.window != nil {
|
if u.window != nil {
|
||||||
m = currentMonitor(u.window)
|
m = currentMonitor(u.window)
|
||||||
|
@ -25,8 +25,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type window struct {
|
type window struct {
|
||||||
ui *UserInterface
|
ui *UserInterface
|
||||||
setPositionCalled bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsDecorated() 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
|
// setPosition must be called from the main thread
|
||||||
func (w *window) setPosition(x, y int) {
|
func (w *window) setPosition(x, y int) {
|
||||||
defer func() {
|
|
||||||
w.setPositionCalled = true
|
|
||||||
}()
|
|
||||||
|
|
||||||
mx, my := currentMonitor(w.ui.window).GetPos()
|
mx, my := currentMonitor(w.ui.window).GetPos()
|
||||||
xf := w.ui.toGLFWPixel(float64(x))
|
xf := w.ui.toGLFWPixel(float64(x))
|
||||||
yf := w.ui.toGLFWPixel(float64(y))
|
yf := w.ui.toGLFWPixel(float64(y))
|
||||||
|
Loading…
Reference in New Issue
Block a user