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
This commit is contained in:
Hajime Hoshi 2023-09-23 17:56:16 +09:00
parent d736a8cff7
commit b3058b68a0
2 changed files with 3 additions and 8 deletions

View File

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

View File

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