examples/windowsize: add a new flag -runnableonunfocused

This commit is contained in:
Hajime Hoshi 2023-04-01 03:13:47 +09:00
parent db7c99fde8
commit 3564a44638

View File

@ -36,19 +36,20 @@ import (
) )
var ( var (
flagFullscreen = flag.Bool("fullscreen", false, "fullscreen") flagFullscreen = flag.Bool("fullscreen", false, "fullscreen")
flagResizable = flag.Bool("resizable", false, "make the window resizable") flagResizable = flag.Bool("resizable", false, "make the window resizable")
flagWindowPosition = flag.String("windowposition", "", "window position (e.g., 100,200)") flagWindowPosition = flag.String("windowposition", "", "window position (e.g., 100,200)")
flagTransparent = flag.Bool("transparent", false, "screen transparent") flagTransparent = flag.Bool("transparent", false, "screen transparent")
flagAutoAdjusting = flag.Bool("autoadjusting", false, "make the game screen auto-adjusting") flagAutoAdjusting = flag.Bool("autoadjusting", false, "make the game screen auto-adjusting")
flagFloating = flag.Bool("floating", false, "make the window floating") flagFloating = flag.Bool("floating", false, "make the window floating")
flagMaximize = flag.Bool("maximize", false, "maximize the window") flagMaximize = flag.Bool("maximize", false, "maximize the window")
flagVsync = flag.Bool("vsync", true, "enable vsync") flagVsync = flag.Bool("vsync", true, "enable vsync")
flagAutoRestore = flag.Bool("autorestore", false, "restore the window automatically") flagAutoRestore = flag.Bool("autorestore", false, "restore the window automatically")
flagInitFocused = flag.Bool("initfocused", true, "whether the window is focused on start") flagInitFocused = flag.Bool("initfocused", true, "whether the window is focused on start")
flagMinWindowSize = flag.String("minwindowsize", "", "minimum window size (e.g., 100x200)") flagMinWindowSize = flag.String("minwindowsize", "", "minimum window size (e.g., 100x200)")
flagMaxWindowSize = flag.String("maxwindowsize", "", "maximium window size (e.g., 1920x1080)") flagMaxWindowSize = flag.String("maxwindowsize", "", "maximium window size (e.g., 1920x1080)")
flagGraphicsLibrary = flag.String("graphicslibrary", "", "graphics library (e.g. opengl)") flagGraphicsLibrary = flag.String("graphicslibrary", "", "graphics library (e.g. opengl)")
flagRunnableOnUnfocused = flag.Bool("runnableonunfocused", true, "whether the app is runnable even on unfocused")
) )
func init() { func init() {
@ -429,9 +430,8 @@ func main() {
if *flagAutoAdjusting { if *flagAutoAdjusting {
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled) ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
} }
if !*flagRunnableOnUnfocused {
if !*flagInitFocused { ebiten.SetRunnableOnUnfocused(false)
ebiten.SetRunnableOnUnfocused(true)
} }
minw, minh, maxw, maxh := -1, -1, -1, -1 minw, minh, maxw, maxh := -1, -1, -1, -1