diff options
Diffstat (limited to 'internal/display')
| -rw-r--r-- | internal/display/activate.go | 8 | ||||
| -rw-r--r-- | internal/display/activate_darwin.go | 24 | ||||
| -rw-r--r-- | internal/display/display.go | 3 |
3 files changed, 35 insertions, 0 deletions
diff --git a/internal/display/activate.go b/internal/display/activate.go new file mode 100644 index 0000000..b9040d7 --- /dev/null +++ b/internal/display/activate.go @@ -0,0 +1,8 @@ +// +build !darwin + +package display + +// activateWindow is a no-op on non-macOS platforms +func activateWindow() { + // Nothing needed on Linux/other platforms +} diff --git a/internal/display/activate_darwin.go b/internal/display/activate_darwin.go new file mode 100644 index 0000000..54c6b94 --- /dev/null +++ b/internal/display/activate_darwin.go @@ -0,0 +1,24 @@ +// +build darwin + +package display + +import ( + "os" + "os/exec" + "time" +) + +// activateWindow brings the SDL window to the foreground on macOS +func activateWindow() { + // Give SDL a moment to create the window + go func() { + time.Sleep(500 * time.Millisecond) + // Get the executable path + execPath, err := os.Executable() + if err != nil { + return + } + // Use open -a to bring the window to foreground + exec.Command("open", "-a", execPath).Run() + }() +} diff --git a/internal/display/display.go b/internal/display/display.go index 231b8c6..10a0b04 100644 --- a/internal/display/display.go +++ b/internal/display/display.go @@ -87,6 +87,9 @@ func Run(ctx context.Context, cfg *config.Config, src stats.Source) error { defer renderer.Destroy() window.SetTitle(title) + // On macOS, bring the window to the foreground + activateWindow() + state := newRunState(cfg, int32(width), int32(height)) ticker := time.NewTicker(time.Duration(constants.IntervalSDL * float64(time.Second))) defer ticker.Stop() |
