From b3058b68a0cf9f410c515bc10fb4b334055ea911 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 23 Sep 2023 17:56:16 +0900 Subject: [PATCH] ebiten: change the unit of (*Monitor).Bounds Monitors can have different device scale factors, and in this case, it doesn't make sense to use device-independent pixels as unit for monitor positions and sizes. Updates #2778 --- internal/ui/monitor_glfw.go | 8 +------- monitor.go | 3 ++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/ui/monitor_glfw.go b/internal/ui/monitor_glfw.go index c2edabe03..9c80a95e0 100644 --- a/internal/ui/monitor_glfw.go +++ b/internal/ui/monitor_glfw.go @@ -40,13 +40,7 @@ type Monitor struct { // Bounds returns the monitor's bounds. func (m *Monitor) Bounds() image.Rectangle { - ui := Get() - return image.Rect( - int(ui.dipFromGLFWMonitorPixel(float64(m.x), m.m)), - int(ui.dipFromGLFWMonitorPixel(float64(m.y), m.m)), - int(ui.dipFromGLFWMonitorPixel(float64(m.x+m.width), m.m)), - int(ui.dipFromGLFWMonitorPixel(float64(m.x+m.height), m.m)), - ) + return image.Rect(m.x, m.y, m.x+m.width, m.y+m.height) } // Name returns the monitor's name. diff --git a/monitor.go b/monitor.go index 35c6bd03c..49e6bf247 100644 --- a/monitor.go +++ b/monitor.go @@ -23,7 +23,8 @@ import ( // MonitorType represents a monitor available to the system. type MonitorType ui.Monitor -// Bounds returns the position and size of the monitor in device-independent pixels. +// Bounds returns the position and size of the monitor in pixels. +// Be careful that the unit is not device-independent pixels. func (m *MonitorType) Bounds() image.Rectangle { return (*ui.Monitor)(m).Bounds() }