Revert "uidriver/glfw: Bug fix: Do not use the window position for monitors"

Revert "uidriver/glfw: Bug fix: compile error on Linux"

This reverts commit 0a5126f776.
This reverts commit 3e244d7a7c.

Reason: GetMonitor is available only on fullscreen mode
This commit is contained in:
Hajime Hoshi 2020-03-28 23:54:55 +09:00
parent e628350d4e
commit 8480f888dd
2 changed files with 4 additions and 4 deletions

View File

@ -180,9 +180,9 @@ func cacheMonitors() {
// returns false if monitor is not found. // returns false if monitor is not found.
// //
// getCachedMonitor must be called on the main thread. // getCachedMonitor must be called on the main thread.
func getCachedMonitor(glfwMonitor *glfw.Monitor) (*cachedMonitor, bool) { func getCachedMonitor(wx, wy int) (*cachedMonitor, bool) {
for _, m := range monitors { for _, m := range monitors {
if m.m == glfwMonitor { if m.x <= wx && wx < m.x+m.vm.Width && m.y <= wy && wy < m.y+m.vm.Height {
return m, true return m, true
} }
} }
@ -537,7 +537,7 @@ 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 {
// Avoid calling monitor.GetPos if we have the monitor position cached already. // Avoid calling monitor.GetPos if we have the monitor position cached already.
if cm, ok := getCachedMonitor(u.window.GetMonitor()); ok { if cm, ok := getCachedMonitor(u.window.GetPos()); ok {
return devicescale.GetAt(cm.x, cm.y) return devicescale.GetAt(cm.x, cm.y)
} }
// TODO: When is this reached? // TODO: When is this reached?

View File

@ -34,7 +34,7 @@ func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {
func (u *UserInterface) currentMonitorFromPosition() *glfw.Monitor { func (u *UserInterface) currentMonitorFromPosition() *glfw.Monitor {
// TODO: Return more appropriate display. // TODO: Return more appropriate display.
if cm, ok := getCachedMonitor(u.window.GetMonitor()); ok { if cm, ok := getCachedMonitor(u.window.GetPos()); ok {
return cm.m return cm.m
} }
return glfw.GetPrimaryMonitor() return glfw.GetPrimaryMonitor()