internal/ui: refactoring: remove redundant Monitor members

This commit is contained in:
Hajime Hoshi 2023-09-24 01:54:14 +09:00
parent 121d6005cd
commit f72b8a4ced
2 changed files with 13 additions and 18 deletions

View File

@ -28,13 +28,11 @@ import (
type Monitor struct { type Monitor struct {
m *glfw.Monitor m *glfw.Monitor
vm *glfw.VidMode vm *glfw.VidMode
// Pos of monitor in virtual coords
x int
y int
width int
height int
id int id int
name string name string
x int
y int
} }
// Name returns the monitor's name. // Name returns the monitor's name.
@ -91,16 +89,13 @@ func (m *monitors) update() {
newMonitors := make([]*Monitor, 0, len(glfwMonitors)) newMonitors := make([]*Monitor, 0, len(glfwMonitors))
for i, m := range glfwMonitors { for i, m := range glfwMonitors {
x, y := m.GetPos() x, y := m.GetPos()
vm := m.GetVideoMode()
newMonitors = append(newMonitors, &Monitor{ newMonitors = append(newMonitors, &Monitor{
m: m, m: m,
vm: m.GetVideoMode(), vm: m.GetVideoMode(),
id: i,
name: m.GetName(),
x: x, x: x,
y: y, y: y,
width: vm.Width,
height: vm.Height,
name: m.GetName(),
id: i,
}) })
} }

View File

@ -307,8 +307,8 @@ func (u *userInterfaceImpl) setWindowMonitor(monitor *Monitor) {
w := u.dipToGLFWPixel(float64(ww), monitor.m) w := u.dipToGLFWPixel(float64(ww), monitor.m)
h := u.dipToGLFWPixel(float64(wh), monitor.m) h := u.dipToGLFWPixel(float64(wh), monitor.m)
x, y := monitor.x, monitor.y x, y := monitor.x, monitor.y
mw := u.dipFromGLFWMonitorPixel(float64(monitor.width), monitor.m) mw := u.dipFromGLFWMonitorPixel(float64(monitor.vm.Width), monitor.m)
mh := u.dipFromGLFWMonitorPixel(float64(monitor.height), monitor.m) mh := u.dipFromGLFWMonitorPixel(float64(monitor.vm.Height), monitor.m)
mw = u.dipToGLFWPixel(mw, monitor.m) mw = u.dipToGLFWPixel(mw, monitor.m)
mh = u.dipToGLFWPixel(mh, monitor.m) mh = u.dipToGLFWPixel(mh, monitor.m)
px, py := InitialWindowPosition(int(mw), int(mh), int(w), int(h)) px, py := InitialWindowPosition(int(mw), int(mh), int(w), int(h))