gui: on the Mac the quick panel opens over a full-screen app without taking the user to magpie's desktop (#2141, witt-bit)
b2d558db9 put the panel on every Space, full-screen ones too, but witt-bit
still saw a click on the menu bar icon over full-screen Chrome land on the
non-full-screen desktop on v0.1.1246. The panel was an ordinary NSWindow,
and togglePanel's Focus() activated magpie (activateIgnoringOtherApps).
Activating an app makes the Mac switch to a Space with that app's windows,
the desktop the main window is on, so the user was taken off the
full-screen Space however the panel itself was set.
The panel is now a non-activating NSPanel (Wails' MacWindowClassPanel with
NonActivating), as a menu bar extra's panel is: Show/Focus order it front
and make it key without activating magpie, so the full-screen app stays
frontmost and the Space stays where it is. It still takes the keyboard.
Lightweight mode makes it again from the same options.
Tests: TestPanelJoinsFullScreenSpaces now also checks, on a real AppKit
panel made at start and made again, that it is a non-activating panel,
that showing and focusing it (the icon's path) leaves magpie not
frontmost, and that it is key. With the old options it fails ("showing the
panel brought magpie to the front, which takes the user to the Space of its
other windows"), with the panel-class check turned off to reach that line.
TestPanelOnEverySpaceOnMac checks the options.
Not tried: a real full-screen Space. A test can't make one, and switching
Spaces on the shared Mac would take over its screen, so the reporter's
click over full-screen Chrome is for them to confirm. Paste into the
panel's fields while another app is frontmost wasn't tried by hand either.
Full suite: SUITE_LINE
This commit is contained in:
@@ -678,6 +678,14 @@ func panelOptions(goos, theme string) application.WebviewWindowOptions {
|
||||
// out of sight, until the user swiped back (#2141).
|
||||
CollectionBehavior: application.MacWindowCollectionBehaviorCanJoinAllSpaces |
|
||||
application.MacWindowCollectionBehaviorFullScreenAuxiliary,
|
||||
// and shown without activating magpie, as a menu bar extra's
|
||||
// panel is: an ordinary window's Focus activated the app, and
|
||||
// the Mac then took the user to the Space of magpie's other
|
||||
// windows (the desktop the main window is on), off the
|
||||
// full-screen app's, panel and all (#2141, witt-bit, on
|
||||
// v0.1.1246). A non-activating panel still takes the keyboard.
|
||||
WindowClass: application.MacWindowClassPanel,
|
||||
PanelPreferences: application.MacPanelPreferences{NonActivating: true},
|
||||
},
|
||||
Windows: application.WindowsWindow{HiddenOnTaskbar: true},
|
||||
}
|
||||
|
||||
@@ -61,4 +61,10 @@ func TestPanelOnEverySpaceOnMac(t *testing.T) {
|
||||
if b&(application.MacWindowCollectionBehaviorMoveToActiveSpace|application.MacWindowCollectionBehaviorFullScreenPrimary) != 0 {
|
||||
t.Errorf("panel collection behaviour %d moves to the active Space or goes full screen itself", b)
|
||||
}
|
||||
// shown without activating magpie: activated, the Mac took the user to
|
||||
// the Space of magpie's other windows, off the full-screen app's
|
||||
mac := panelOptions("darwin", "").Mac
|
||||
if mac.WindowClass != application.MacWindowClassPanel || !mac.PanelPreferences.NonActivating {
|
||||
t.Errorf("the panel is window class %d, non-activating %v; want a non-activating panel", mac.WindowClass, mac.PanelPreferences.NonActivating)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ import (
|
||||
// test can't make a full-screen Space, so it checks what decides it on the
|
||||
// real window: the panel, made at start and made again after lightweight
|
||||
// mode let it go, is on every Space and over a full-screen app's, and is
|
||||
// shown and hidden with that set.
|
||||
// shown and hidden with that set, without activating magpie (activated,
|
||||
// the Mac took the user to the Space of magpie's other windows).
|
||||
func TestPanelJoinsFullScreenSpaces(t *testing.T) {
|
||||
out, err := runAppKit(t, 30*time.Second, []string{"MAGPIE_TEST_PANEL_SPACE=1"})
|
||||
if err != nil || !strings.Contains(string(out), "panel space: ok") {
|
||||
@@ -57,8 +58,22 @@ func init() {
|
||||
if !application.InvokeSyncWithResult(func() bool { return joinsFullScreenSpaces(w) }) {
|
||||
fail("%s: the panel isn't on every Space and over full-screen ones", how)
|
||||
}
|
||||
if !application.InvokeSyncWithResult(func() bool { return nonActivating(w) }) {
|
||||
fail("%s: the panel isn't a non-activating panel", how)
|
||||
}
|
||||
if application.InvokeSyncWithResult(appFrontmost) {
|
||||
fail("%s: magpie is frontmost before the icon is clicked; the test can't tell", how)
|
||||
}
|
||||
application.InvokeSync(func() { w.Show().Focus() }) // the icon clicked
|
||||
waitFor(how+": the panel shows", func() bool { return application.InvokeSyncWithResult(func() bool { return windowOpen(w) }) })
|
||||
// activation is asked for and comes a moment later: give it time
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
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(w.IsFocused) {
|
||||
fail("%s: the panel shown doesn't take the keyboard", how)
|
||||
}
|
||||
if !application.InvokeSyncWithResult(func() bool { return joinsFullScreenSpaces(w) }) {
|
||||
fail("%s: showing the panel took it off full-screen Spaces", how)
|
||||
}
|
||||
|
||||
@@ -23,6 +23,19 @@ static int joinsFullScreenSpaces(void *win) {
|
||||
return (b & NSWindowCollectionBehaviorCanJoinAllSpaces) != 0 && (b & NSWindowCollectionBehaviorFullScreenAuxiliary) != 0;
|
||||
}
|
||||
|
||||
// A non-activating panel: shown and focused, it leaves the app that is
|
||||
// active so, and the Space the user is on with it.
|
||||
static int nonActivating(void *win) {
|
||||
NSWindow *w = (NSWindow *)win;
|
||||
return [w isKindOfClass:[NSPanel class]] && (w.styleMask & NSWindowStyleMaskNonactivatingPanel) != 0;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
return [NSWorkspace sharedWorkspace].frontmostApplication.processIdentifier == NSProcessInfo.processInfo.processIdentifier;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
@@ -85,6 +98,17 @@ func joinsFullScreenSpaces(w *application.WebviewWindow) bool {
|
||||
return p != nil && C.joinsFullScreenSpaces(p) != 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 {
|
||||
p := w.NativeWindow()
|
||||
return p != nil && C.nonActivating(p) != 0
|
||||
}
|
||||
|
||||
// appFrontmost says whether magpie is the frontmost app, the one whose
|
||||
// menu bar shows; on the main thread.
|
||||
func appFrontmost() bool { return C.appFrontmost() != 0 }
|
||||
|
||||
// windowOpen says whether w is open: shown, on any Space, and not
|
||||
// minimised; on the main thread.
|
||||
func windowOpen(w *application.WebviewWindow) bool {
|
||||
|
||||
Reference in New Issue
Block a user