With Dock on "Hide", magpie runs as an Accessory app. A full-screen window's title bar comes down only with the menu bar, and an Accessory app has none, so the full-screen main window had no close, minimize or full-screen button, and only Esc left full screen. magpie now joins the Dock as a window starts entering full screen, from a native NSWindowWillEnterFullScreenNotification observer: Wails hands that event to Go later, and switching once the window is full screen doesn't bring the title bar back. dock counts a full-screen main window (inDock), so reopening the app or changing the Dock setting during full screen keeps magpie in the Dock, and WindowDidExitFullScreen applies the setting again. TestFullscreenKeepsDock checks inDock; it doesn't compile on main. On macOS 27.0.1 with Dock on "Hide", main stays out of the Dock in full screen with no title bar; this branch joins the Dock with the title bar and its buttons, and leaves it after the green button, View > Toggle Full Screen or Esc. Fixes #763
79 lines
2.7 KiB
Go
79 lines
2.7 KiB
Go
//go:build !nogui
|
|
|
|
package gui
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// StringKe on Discord: magpie restarted for an update while another app was
|
|
// full screen, and from then on its window opened only on that app's Space.
|
|
// The window moves to the Space the user is on when shown, and can still go
|
|
// full screen; it doesn't join every Space.
|
|
func TestMainWindowFollowsActiveSpace(t *testing.T) {
|
|
m := mainMacWindow()
|
|
b := m.CollectionBehavior
|
|
if b&application.MacWindowCollectionBehaviorMoveToActiveSpace == 0 {
|
|
t.Errorf("main window collection behaviour %d does not move to the active Space", b)
|
|
}
|
|
if b&application.MacWindowCollectionBehaviorFullScreenPrimary == 0 {
|
|
t.Errorf("main window collection behaviour %d can no longer go full screen", b)
|
|
}
|
|
if b&(application.MacWindowCollectionBehaviorCanJoinAllSpaces|application.MacWindowCollectionBehaviorFullScreenAuxiliary) != 0 {
|
|
t.Errorf("main window collection behaviour %d joins all Spaces or full-screen ones", b)
|
|
}
|
|
if m.TitleBar != application.MacTitleBarHiddenInset {
|
|
t.Errorf("main window title bar changed: %+v", m.TitleBar)
|
|
}
|
|
}
|
|
|
|
// StringKe on Discord: a full-screen window closed left a black Space
|
|
// behind. On the Mac it leaves full screen before it is hidden.
|
|
func TestCloseStepLeavesFullscreen(t *testing.T) {
|
|
cases := []struct {
|
|
goos string
|
|
fullscreen bool
|
|
want closeAction
|
|
}{
|
|
{"darwin", true, closeLeaveFullscreen},
|
|
{"darwin", false, closeHide},
|
|
{"windows", true, closeHide},
|
|
{"linux", true, closeHide},
|
|
{"linux", false, closeHide},
|
|
}
|
|
for _, c := range cases {
|
|
if got := closeStep(c.goos, c.fullscreen); got != c.want {
|
|
t.Errorf("closeStep(%s, fullscreen=%v) = %v, want %v", c.goos, c.fullscreen, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// lainbo on v0.1.819 (#763): with the Dock set to hidden, a full-screen window
|
|
// had no close, minimise or full-screen buttons, and only Esc took it out of
|
|
// full screen. A full-screen window keeps magpie in the Dock, whatever the setting.
|
|
func TestFullscreenKeepsDock(t *testing.T) {
|
|
hidden, window, shown := settings.Settings{}, settings.Settings{DockWindow: true}, settings.Settings{Dock: true}
|
|
cases := []struct {
|
|
s settings.Settings
|
|
shown, fullscreen bool
|
|
want bool
|
|
}{
|
|
{hidden, true, true, true},
|
|
{hidden, true, false, false},
|
|
{hidden, false, false, false},
|
|
{window, true, true, true},
|
|
{window, true, false, true},
|
|
{window, false, false, false},
|
|
{shown, false, false, true},
|
|
}
|
|
for _, c := range cases {
|
|
if got := inDock(c.s, c.shown, c.fullscreen); got != c.want {
|
|
t.Errorf("inDock(%+v, shown=%v, fullscreen=%v) = %v, want %v", c.s, c.shown, c.fullscreen, got, c.want)
|
|
}
|
|
}
|
|
}
|