split Window.SetMonitor into two sub-functions
@@ -260,26 +260,7 @@ func (w *Window) Hide() {
})
}
-// SetMonitor sets a window fullscreen on a given monitor. If the monitor is nil, the window
-// will be resored to windowed instead.
-//
-// Note, that there is nothing about the resolution of the fullscreen window. The window is
-// automatically set to the monitor's resolution. If you want a different resolution, you need
-// to set it manually with SetSize method.
-func (w *Window) SetMonitor(monitor *Monitor) {
- if w.Monitor() != monitor {
- if monitor == nil {
- mainthread.Call(func() {
- w.window.SetMonitor(
- nil,
- w.restore.xpos,
- w.restore.ypos,
- w.restore.width,
- w.restore.height,
- 0,
- )
- })
- } else {
+func (w *Window) setFullscreen(monitor *Monitor) {
mainthread.Call(func() {
w.restore.xpos, w.restore.ypos = w.window.GetPos()
w.restore.width, w.restore.height = w.window.GetSize()
@@ -296,6 +277,33 @@ func (w *Window) SetMonitor(monitor *Monitor) {
)
})
}
+
+func (w *Window) setWindowed() {
+ mainthread.Call(func() {
+ w.window.SetMonitor(
+ nil,
+ w.restore.xpos,
+ w.restore.ypos,
+ w.restore.width,
+ w.restore.height,
+ 0,
+ )
+ })
+}
+
+// SetMonitor sets a window fullscreen on a given monitor. If the monitor is nil, the window
+// will be resored to windowed instead.
+//
+// Note, that there is nothing about the resolution of the fullscreen window. The window is
+// automatically set to the monitor's resolution. If you want a different resolution, you need
+// to set it manually with SetSize method.
+func (w *Window) SetMonitor(monitor *Monitor) {
+ if w.Monitor() != monitor {
+ if monitor != nil {
+ w.setFullscreen(monitor)
+ } else {
+ w.setWindowed()
+ }
}
}
