internal/uidriver/glfw: Prefer currentMonitor to get the monitor at deviceScaleFactor

This commit is contained in:
Hajime Hoshi 2021-04-17 17:03:46 +09:00
parent e89f53774c
commit deba352384
2 changed files with 1 additions and 13 deletions

View File

@ -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)

View File

@ -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))