Repository navigation
Description
Problem
A full-display overlay (region screenshot, color picker, presentation HUD) has to cover the menu bar and the Dock on macOS, and the taskbar on Windows. Window can't do that today:
SetAlwaysOnTop(true)maps toNSFloatingWindowLevelon macOS, which is below the menu bar and the Dock. Nothing in the public API raises a window higher.SetBounds()with a rectangle covering the whole display (including the menu-bar strip) is not honoured for this kind of window: AppKit's-[NSWindow constrainFrameRect:toScreen:]moves the frame below the menu bar.
The Flutter screen-capture example (examples/flutter_screen_capture_example, PR #75) works around both in MainFlutterWindow.swift: it sets NSWindow.level to CGWindowLevelForKey(kCGScreenSaverWindowLevelKey) and overrides constrainFrameRect(_:to:) to return the requested frame unchanged.
Proposal
A window level setting. The names follow Electron's BrowserWindow.setAlwaysOnTop(flag, level) (see specs/api-style.md §1.7). It is a separate setter rather than an overload (§1.6):
enum class WindowLevel {
/** Normal stacking. */
Normal,
/** Above normal windows; same as SetAlwaysOnTop(true). */
Floating,
/** Above the menu bar / taskbar, e.g. status overlays. */
Status,
/** Above everything the user normally sees, including the Dock. */
ScreenSaver,
};
bool Window::SetLevel(WindowLevel level);
WindowLevel Window::GetLevel() const;Open questions for the design pass:
- How
SetLevelinteracts withSetAlwaysOnTop/SetAlwaysOnBottomand with the fullscreen coordinator, which already saves and restoresNSFloatingWindowLevel. - Whether
SetBounds()should skip AppKit's frame constraint when the level isStatusor higher, so a whole-display rectangle is honoured.
Per-platform mapping:
- macOS:
NSWindow.level(NSStatusWindowLevel,kCGScreenSaverWindowLevel), plus the frame constraint change above. - Windows:
HWND_TOPMOST; a borderless topmost window covering the monitor already sits over the taskbar. - Linux:
_NET_WM_STATE_ABOVEon X11; on Wayland this is compositor-dependent (⚠️ ). - Mobile / OpenHarmony / WASM: return
false.
Acceptance
With only Dart calls (setLevel(WindowLevel.screenSaver), bounds = <display bounds>), a window covers the whole display, menu bar and Dock included, on macOS, with no edits to the app's MainFlutterWindow.swift.
Activity