gui: TestPanelJoinsFullScreenSpaces checks key status only where the session gives it (#2450)
The test was wrong, not the panel. It required the quick panel to be key
after Focus, but on this Mac (macOS 26.2 25C56, no input for ~30 min,
frontmost app kitty) macOS makes no non-activating panel key for an app
that isn't active when nothing the user did is behind it. That held at
e5d4c4929, the test's own commit, as well as on main, so there is no
regression to bisect. A control panel shows it: a plain NSPanel, titled +
NonactivatingPanel (canBecomeKeyWindow YES), ordered front and made key
the same way in the same child, isn't key either.
Now the test always checks that the panel can be made key
(canBecomeKeyWindow, which a borderless window has only through Wails'
panel class). It checks that the panel is key only when the session makes
the control panel key, and otherwise prints that it skipped that check.
Its other checks are unchanged: it joins full-screen Spaces, doesn't
activate, keeps the frontmost app, and hides.
Broken by hand, both ways:
- canBeKey returning 0 fails with "the panel can't be made key, so it never
takes the keyboard".
- sessionKeysPanels returning 1 (which says the session gives key status)
fails with "the panel shown doesn't take the keyboard", the old red.
Not tried: a real click on the menu bar icon with someone at the Mac.
That click is input, so a session at the Mac should run the key check
fully rather than skip it.
Run:
- go test ./internal/gui -run TestPanelJoinsFullScreenSpaces: ok, with
the skip line printed.
- gofmt -l: clean.
- go vet -tags nogui ./... with GOOS=darwin, linux and windows: ok.
- go vet ./internal/gui (cgo): ok.
Full suite: set -o pipefail; go test -timeout 45m ./... (sandbox HOME, macOS 26.2, load ~150 from other suites): 66 ok, 18 no test files, 0 FAIL; gateway 2712s, agent 2553s, gui 419s.
This commit is contained in:
@@ -71,8 +71,19 @@ func init() {
|
||||
if application.InvokeSyncWithResult(appFrontmost) {
|
||||
fail("%s: showing the panel brought magpie to the front, which takes the user to the Space of its other windows", how)
|
||||
}
|
||||
if !application.InvokeSyncWithResult(func() bool { return canBeKey(w) }) {
|
||||
fail("%s: the panel can't be made key, so it never takes the keyboard", how)
|
||||
}
|
||||
// Whether it is key is up to the session too: on a Mac no one was
|
||||
// at, macOS 26.2 made no non-activating panel of an app that isn't
|
||||
// active key, a plain titled one either (#2450). A click on the
|
||||
// icon is input, which this test can't make, so where a plain one
|
||||
// isn't made key the check can't tell.
|
||||
if !application.InvokeSyncWithResult(w.IsFocused) {
|
||||
fail("%s: the panel shown doesn't take the keyboard", how)
|
||||
if application.InvokeSyncWithResult(sessionKeysPanels) {
|
||||
fail("%s: the panel shown doesn't take the keyboard", how)
|
||||
}
|
||||
fmt.Printf("panel space: %s: not checked that it takes the keyboard: this session makes no non-activating panel key\n", how)
|
||||
}
|
||||
if !application.InvokeSyncWithResult(func() bool { return joinsFullScreenSpaces(w) }) {
|
||||
fail("%s: showing the panel took it off full-screen Spaces", how)
|
||||
|
||||
@@ -30,6 +30,29 @@ static int nonActivating(void *win) {
|
||||
return [w isKindOfClass:[NSPanel class]] && (w.styleMask & NSWindowStyleMaskNonactivatingPanel) != 0;
|
||||
}
|
||||
|
||||
// Can be made key: a borderless window can't unless its class says so,
|
||||
// as Wails' panel class does.
|
||||
static int canBeKey(void *win) {
|
||||
return ((NSWindow *)win).canBecomeKeyWindow;
|
||||
}
|
||||
|
||||
// Whether this session lets an app that isn't active make a
|
||||
// non-activating panel key from code: a plain titled one is shown and
|
||||
// made key as the quick panel is. With no click or key press behind it,
|
||||
// macOS 26.2 left even that one not key on a Mac no one was at (#2450).
|
||||
static int sessionKeysPanels(void) {
|
||||
NSPanel *p = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 40, 40)
|
||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskNonactivatingPanel
|
||||
backing:NSBackingStoreBuffered defer:NO];
|
||||
p.releasedWhenClosed = NO;
|
||||
[p orderFrontRegardless];
|
||||
[p makeKeyWindow];
|
||||
int key = p.isKeyWindow;
|
||||
[p orderOut:nil];
|
||||
[p release];
|
||||
return key;
|
||||
}
|
||||
|
||||
// Frontmost: the app whose menu bar shows, and whose Space the Mac goes
|
||||
// to. A non-activating panel made key leaves another app frontmost.
|
||||
static int appFrontmost(void) {
|
||||
@@ -98,6 +121,19 @@ func joinsFullScreenSpaces(w *application.WebviewWindow) bool {
|
||||
return p != nil && C.joinsFullScreenSpaces(p) != 0
|
||||
}
|
||||
|
||||
// canBeKey says whether w can be made key, take the keyboard; on the
|
||||
// main thread.
|
||||
func canBeKey(w *application.WebviewWindow) bool {
|
||||
p := w.NativeWindow()
|
||||
return p != nil && C.canBeKey(p) != 0
|
||||
}
|
||||
|
||||
// sessionKeysPanels says whether this session makes a non-activating
|
||||
// panel key when an app that isn't active asks with no input behind it,
|
||||
// which decides whether a test can see the quick panel take the keyboard
|
||||
// (#2450); on the main thread.
|
||||
func sessionKeysPanels() bool { return C.sessionKeysPanels() != 0 }
|
||||
|
||||
// nonActivating says whether w shows and takes the keyboard without
|
||||
// activating magpie, as the quick panel does (#2141); on the main thread.
|
||||
func nonActivating(w *application.WebviewWindow) bool {
|
||||
|
||||
Reference in New Issue
Block a user