From 8480f888dd2370b1301ca0513a498ac99944c152 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 28 Mar 2020 23:54:55 +0900 Subject: [PATCH] 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 0a5126f7766e22ba2fba528fd0c419d664990d6c. This reverts commit 3e244d7a7c3365d10a26c9cc8df4cdb2347dba4e. Reason: GetMonitor is available only on fullscreen mode --- internal/uidriver/glfw/ui.go | 6 +++--- internal/uidriver/glfw/ui_unix.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index db3cacba6..60ec754d8 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -180,9 +180,9 @@ func cacheMonitors() { // returns false if monitor is not found. // // 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 { - 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 } } @@ -537,7 +537,7 @@ func (u *UserInterface) DeviceScaleFactor() float64 { // deviceScaleFactor must be called from the main thread. func (u *UserInterface) deviceScaleFactor() float64 { // 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) } // TODO: When is this reached? diff --git a/internal/uidriver/glfw/ui_unix.go b/internal/uidriver/glfw/ui_unix.go index 56b2dbccb..1859f551e 100644 --- a/internal/uidriver/glfw/ui_unix.go +++ b/internal/uidriver/glfw/ui_unix.go @@ -34,7 +34,7 @@ func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) { func (u *UserInterface) currentMonitorFromPosition() *glfw.Monitor { // 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 glfw.GetPrimaryMonitor()