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

View File

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