With Chrome full screen and Settings > Click the tray icon set to the quick panel, a click on the menu bar icon flashed the icon and showed the panel on the non-full-screen desktop instead, out of sight until the user swiped back (witt-bit, macOS 27.0.1, v0.1.1230). The panel's window had no collection behaviour of its own, so Wails gave it FullScreenPrimary alone: an ordinary window, kept on the Space it was first ordered in on, and not allowed on a full-screen app's Space. It now has CanJoinAllSpaces | FullScreenAuxiliary, as a menu bar extra's panel (and Wails' own notch window) does, so it is on every Space, full-screen ones too. It never moves to the active Space as well (AppKit refuses that pair), and nothing calls setMovesToActiveSpace on it (showHere is the main window's only). The panel lightweight mode makes again takes the same options. Tests: - TestPanelOnEverySpaceOnMac (panel_options_test.go) checks the options. - TestPanelJoinsFullScreenSpaces (AppKit, runAppKit) makes the real panel through panelWin, at start and again after lightweight mode let it go, shows and hides it, and reads NSWindow.collectionBehavior (joinsFullScreenSpaces). - Without the change both fail: "panel collection behaviour 0 is not on every Space and over full-screen ones" and "made at start: the panel isn't on every Space and over full-screen ones". Run: gofmt -l (clean); go vet ./internal/gui/ (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet; go build, GOOS=linux go build -tags nogui, GOOS=windows go build; go test ./internal/gui/ under a sandbox HOME with pinned caches. In the package run, at load average ~300-420 from other sessions, two tests unrelated to the panel failed: TestMainWindowCorners (40s deadline killed; fails the same on clean origin/mainc4c3cafa2, filed as #1936) and TestSetAnswersWhileDevinAndProvidersHang (filed as #1375; passed on cleanc4c3cafa2right after). Panel, dock and Space tests pass. Not tried: a real full-screen Space. A test can't make one, and doing it by hand would take over the owner's screen; the reporter is asked to confirm on the next release.
112 lines
4.0 KiB
Go
112 lines
4.0 KiB
Go
//go:build !nogui
|
|
|
|
package gui
|
|
|
|
/*
|
|
#cgo CFLAGS: -x objective-c
|
|
#cgo LDFLAGS: -framework Cocoa
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
static void setMovesToActiveSpace(void *win, int on) {
|
|
NSWindow *w = (NSWindow *)win;
|
|
if (on) w.collectionBehavior |= NSWindowCollectionBehaviorMoveToActiveSpace;
|
|
else w.collectionBehavior &= ~NSWindowCollectionBehaviorMoveToActiveSpace;
|
|
}
|
|
|
|
static int movesToActiveSpace(void *win) {
|
|
return (((NSWindow *)win).collectionBehavior & NSWindowCollectionBehaviorMoveToActiveSpace) != 0;
|
|
}
|
|
|
|
// On every Space and over a full-screen app's.
|
|
static int joinsFullScreenSpaces(void *win) {
|
|
NSWindowCollectionBehavior b = ((NSWindow *)win).collectionBehavior;
|
|
return (b & NSWindowCollectionBehaviorCanJoinAllSpaces) != 0 && (b & NSWindowCollectionBehaviorFullScreenAuxiliary) != 0;
|
|
}
|
|
|
|
// Ordered in and not in the Dock: on a Space of its own, or covered, it is
|
|
// still open, where Wails' IsVisible (its occlusion state) says it isn't.
|
|
static int windowOpen(void *win) {
|
|
NSWindow *w = (NSWindow *)win;
|
|
return w.isVisible && !w.isMiniaturized;
|
|
}
|
|
|
|
// The windows that were open as magpie was hidden (Command-H, Hide
|
|
// Others): hiding orders every window out, and Command-Tab back orders
|
|
// these in again. Weak, so a window let go isn't kept.
|
|
static NSHashTable *openWhenHidden;
|
|
|
|
static void watchHide(void) {
|
|
if (openWhenHidden != nil) return;
|
|
openWhenHidden = [[NSHashTable weakObjectsHashTable] retain];
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillHideNotification object:nil queue:nil usingBlock:^(NSNotification *n) {
|
|
[openWhenHidden removeAllObjects];
|
|
for (NSWindow *w in NSApp.windows) {
|
|
if (w.isVisible) [openWhenHidden addObject:w];
|
|
}
|
|
}];
|
|
}
|
|
|
|
// Up: ordered in on any Space, covered by other windows or not, or
|
|
// minimised, or open as magpie was hidden. Only a window magpie closed
|
|
// itself is down. The occlusion state, Wails' IsVisible, says a window
|
|
// covered by another app's is not visible.
|
|
static int windowUp(void *win) {
|
|
NSWindow *w = (NSWindow *)win;
|
|
return w.isVisible || w.isMiniaturized || (NSApp.isHidden && [openWhenHidden containsObject:w]);
|
|
}
|
|
|
|
static void activateApp(void) {
|
|
[NSApp activateIgnoringOtherApps:YES];
|
|
}
|
|
*/
|
|
import "C"
|
|
|
|
import "github.com/wailsapp/wails/v3/pkg/application"
|
|
|
|
// setMovesToActiveSpace says whether w, ordered front or its app activated,
|
|
// is moved to the Space the user is on, rather than taking the user to its
|
|
// own; on the main thread.
|
|
func setMovesToActiveSpace(w *application.WebviewWindow, on bool) {
|
|
if p := w.NativeWindow(); p != nil {
|
|
C.setMovesToActiveSpace(p, C.int(boolInt(on)))
|
|
}
|
|
}
|
|
|
|
// movesToActiveSpace says whether it is; on the main thread.
|
|
func movesToActiveSpace(w *application.WebviewWindow) bool {
|
|
p := w.NativeWindow()
|
|
return p != nil && C.movesToActiveSpace(p) != 0
|
|
}
|
|
|
|
// joinsFullScreenSpaces says whether w is on every Space, a full-screen
|
|
// app's too, as the quick panel is (#2141); on the main thread.
|
|
func joinsFullScreenSpaces(w *application.WebviewWindow) bool {
|
|
p := w.NativeWindow()
|
|
return p != nil && C.joinsFullScreenSpaces(p) != 0
|
|
}
|
|
|
|
// windowOpen says whether w is open: shown, on any Space, and not
|
|
// minimised; on the main thread.
|
|
func windowOpen(w *application.WebviewWindow) bool {
|
|
p := w.NativeWindow()
|
|
return p != nil && C.windowOpen(p) != 0
|
|
}
|
|
|
|
// windowUp says whether w is up, as the user sees it: open on any Space,
|
|
// covered or not, minimised, or open as magpie was hidden; on the main thread.
|
|
// Lightweight mode lets go only of a window that isn't, and the Dock and a
|
|
// restart keep the window that is (#1381).
|
|
func windowUp(w *application.WebviewWindow) bool {
|
|
p := w.NativeWindow()
|
|
return p != nil && C.windowUp(p) != 0
|
|
}
|
|
|
|
// watchHide keeps which windows were open as magpie was hidden, for
|
|
// windowUp; called once, before the app runs.
|
|
func watchHide() { C.watchHide() }
|
|
|
|
// activateApp brings magpie to the front as the Mac does for a click on its
|
|
// Dock icon: to the Space its window is on, as the user's Mission Control
|
|
// settings say; on the main thread.
|
|
func activateApp() { C.activateApp() }
|