ソースを参照

Merge pull request #178 from metalim/i177-fullscreen

Fix SetFullScreen(false), add FullScreen to IWindow
Daniel Salvadori 4 年 前
コミット
5bc272204e
2 ファイル変更9 行追加7 行削除
  1. 7 7
      window/glfw.go
  2. 2 0
      window/window.go

+ 7 - 7
window/glfw.go

@@ -371,15 +371,15 @@ func (w *GlfwWindow) Gls() *gls.GLS {
 	return w.gls
 }
 
-// Fullscreen returns whether this windows is currently fullscreen.
-func (w *GlfwWindow) Fullscreen() bool {
+// FullScreen returns whether this windows is currently fullscreen.
+func (w *GlfwWindow) FullScreen() bool {
 
 	return w.fullscreen
 }
 
-// SetFullscreen sets this window as fullscreen on the primary monitor
+// SetFullScreen sets this window as fullscreen on the primary monitor
 // TODO allow for fullscreen with resolutions different than the monitor's
-func (w *GlfwWindow) SetFullscreen(full bool) {
+func (w *GlfwWindow) SetFullScreen(full bool) {
 
 	// If already in the desired state, nothing to do
 	if w.fullscreen == full {
@@ -387,6 +387,9 @@ func (w *GlfwWindow) SetFullscreen(full bool) {
 	}
 	// Set window fullscreen on the primary monitor
 	if full {
+		// Save current position and size of the window
+		w.lastX, w.lastY = w.GetPos()
+		w.lastWidth, w.lastHeight = w.GetSize()
 		// Get size of primary monitor
 		mon := glfw.GetPrimaryMonitor()
 		vmode := mon.GetVideoMode()
@@ -395,9 +398,6 @@ func (w *GlfwWindow) SetFullscreen(full bool) {
 		// Set as fullscreen on the primary monitor
 		w.SetMonitor(mon, 0, 0, width, height, vmode.RefreshRate)
 		w.fullscreen = true
-		// Save current position and size of the window
-		w.lastX, w.lastY = w.GetPos()
-		w.lastWidth, w.lastHeight = w.GetSize()
 	} else {
 		// Restore window to previous position and size
 		w.SetMonitor(nil, w.lastX, w.lastY, w.lastWidth, w.lastHeight, glfw.DontCare)

+ 2 - 0
window/window.go

@@ -40,6 +40,8 @@ type IWindow interface {
 	SetCursor(cursor Cursor)
 	DisposeAllCustomCursors()
 	Destroy()
+	FullScreen() bool
+	SetFullScreen(full bool)
 }
 
 // Key corresponds to a keyboard key.