diff --git a/bindings/csharp/src/CNativeAPI/generated/ScreenCapturer.cs b/bindings/csharp/src/CNativeAPI/generated/ScreenCapturer.cs index c8abdfe6..622a63bf 100644 --- a/bindings/csharp/src/CNativeAPI/generated/ScreenCapturer.cs +++ b/bindings/csharp/src/CNativeAPI/generated/ScreenCapturer.cs @@ -20,6 +20,7 @@ public struct native_capture_source_selection_options_t public struct native_screen_capture_options_t { public byte include_cursor; + public byte exclude_own_windows; public byte crop_enabled; public native_rectangle_t crop; } diff --git a/bindings/csharp/src/CNativeAPI/generated/Window.cs b/bindings/csharp/src/CNativeAPI/generated/Window.cs index 17bf0e83..b4c016f0 100644 --- a/bindings/csharp/src/CNativeAPI/generated/Window.cs +++ b/bindings/csharp/src/CNativeAPI/generated/Window.cs @@ -318,6 +318,10 @@ public static partial class Interop [return: MarshalAs(UnmanagedType.I1)] public static extern bool native_window_set_input_shape(ulong self, ulong shape); + [DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool native_window_set_level(ulong self, int level); + [DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool native_window_set_maximize_button_bounds(ulong self, native_rectangle_t bounds); @@ -376,6 +380,9 @@ public static partial class Interop [DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)] public static extern int native_window_get_dock_side(ulong self); + [DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)] + public static extern int native_window_get_level(ulong self); + [DllImport(Libraries.NativeApi, CallingConvention = CallingConvention.Cdecl)] public static extern int native_window_get_occlusion_state(ulong self); diff --git a/bindings/csharp/src/NativeAPI/ScreenCapturer.cs b/bindings/csharp/src/NativeAPI/ScreenCapturer.cs index f51ff888..18cf6ed4 100644 --- a/bindings/csharp/src/NativeAPI/ScreenCapturer.cs +++ b/bindings/csharp/src/NativeAPI/ScreenCapturer.cs @@ -44,25 +44,28 @@ internal static void ReleaseRaw(ref native_capture_source_selection_options_t ra public struct ScreenCaptureOptions { public bool IncludeCursor; + public bool ExcludeOwnWindows; public bool CropEnabled; public Rectangle Crop; - public ScreenCaptureOptions(bool includeCursor, bool cropEnabled, Rectangle crop) + public ScreenCaptureOptions(bool includeCursor, bool excludeOwnWindows, bool cropEnabled, Rectangle crop) { IncludeCursor = includeCursor; + ExcludeOwnWindows = excludeOwnWindows; CropEnabled = cropEnabled; Crop = crop; } internal static ScreenCaptureOptions FromRaw(in native_screen_capture_options_t raw) { - return new ScreenCaptureOptions(raw.include_cursor != 0, raw.crop_enabled != 0, Rectangle.FromRaw(in raw.crop)); + return new ScreenCaptureOptions(raw.include_cursor != 0, raw.exclude_own_windows != 0, raw.crop_enabled != 0, Rectangle.FromRaw(in raw.crop)); } internal native_screen_capture_options_t ToRaw() { var raw = new native_screen_capture_options_t(); raw.include_cursor = (byte)(IncludeCursor ? 1 : 0); + raw.exclude_own_windows = (byte)(ExcludeOwnWindows ? 1 : 0); raw.crop_enabled = (byte)(CropEnabled ? 1 : 0); raw.crop = Crop.ToRaw(); return raw; diff --git a/bindings/csharp/src/NativeAPI/Window.cs b/bindings/csharp/src/NativeAPI/Window.cs index c0d42ce9..fc8807d6 100644 --- a/bindings/csharp/src/NativeAPI/Window.cs +++ b/bindings/csharp/src/NativeAPI/Window.cs @@ -30,6 +30,14 @@ public enum WindowCornerPreference RoundSmall = 3, } +public enum WindowLevel +{ + Normal = 0, + Floating = 1, + Status = 2, + ScreenSaver = 3, +} + public enum WindowProperty { Title = 0, @@ -595,6 +603,21 @@ public bool IsAlwaysOnTop } } + public bool SetLevel(WindowLevel level) + { + var rawResult = Interop.native_window_set_level(NativeHandle, (int)level); + return rawResult; + } + + public WindowLevel Level + { + get + { + var rawResult = Interop.native_window_get_level(NativeHandle); + return (WindowLevel)rawResult; + } + } + public void SetAlwaysOnBottom(bool isAlwaysOnBottom) { Interop.native_window_set_always_on_bottom(NativeHandle, isAlwaysOnBottom); diff --git a/bindings/dart/cnativeapi/lib/src/bindings_generated.dart b/bindings/dart/cnativeapi/lib/src/bindings_generated.dart index b0f55a3e..8b1014ac 100644 --- a/bindings/dart/cnativeapi/lib/src/bindings_generated.dart +++ b/bindings/dart/cnativeapi/lib/src/bindings_generated.dart @@ -3611,6 +3611,15 @@ native_window_dock_side_t native_window_get_dock_side( @ffi.Native() external int native_window_get_id(int window); +@ffi.Native( + symbol: 'native_window_get_level', +) +external int _native_window_get_level(int window); + +native_window_level_t native_window_get_level(Dartnative_window_t window) { + return native_window_level_t.fromValue(_native_window_get_level(window)); +} + @ffi.Native() external native_rectangle_t native_window_get_maximize_button_bounds( int window, @@ -4053,6 +4062,18 @@ external bool native_window_set_ignore_mouse_events( @ffi.Native() external bool native_window_set_input_shape(int window, int shape); +@ffi.Native( + symbol: 'native_window_set_level', +) +external bool _native_window_set_level(int window, int level); + +bool native_window_set_level( + Dartnative_window_t window, + native_window_level_t level, +) { + return _native_window_set_level(window, level.value); +} + @ffi.Native() external void native_window_set_maximizable(int window, bool is_maximizable); @@ -6400,6 +6421,9 @@ final class native_screen_capture_options_t extends ffi.Struct { @ffi.Bool() external bool include_cursor; + @ffi.Bool() + external bool exclude_own_windows; + @ffi.Bool() external bool crop_enabled; @@ -7569,6 +7593,24 @@ enum native_window_event_type_t { typedef native_window_id_t = ffi.UnsignedInt; typedef Dartnative_window_id_t = int; +enum native_window_level_t { + NATIVE_WINDOW_LEVEL_NORMAL(0), + NATIVE_WINDOW_LEVEL_FLOATING(1), + NATIVE_WINDOW_LEVEL_STATUS(2), + NATIVE_WINDOW_LEVEL_SCREEN_SAVER(3); + + final int value; + const native_window_level_t(this.value); + + static native_window_level_t fromValue(int value) => switch (value) { + 0 => NATIVE_WINDOW_LEVEL_NORMAL, + 1 => NATIVE_WINDOW_LEVEL_FLOATING, + 2 => NATIVE_WINDOW_LEVEL_STATUS, + 3 => NATIVE_WINDOW_LEVEL_SCREEN_SAVER, + _ => throw ArgumentError('Unknown value for native_window_level_t: $value'), + }; +} + /// Owning list of Window handles. final class native_window_list_t extends ffi.Struct { external ffi.Pointer windows; diff --git a/bindings/dart/nativeapi/lib/src/screen_capturer.dart b/bindings/dart/nativeapi/lib/src/screen_capturer.dart index f7ce1a44..1524c2d3 100644 --- a/bindings/dart/nativeapi/lib/src/screen_capturer.dart +++ b/bindings/dart/nativeapi/lib/src/screen_capturer.dart @@ -71,11 +71,13 @@ class CaptureSourceSelectionOptions { class ScreenCaptureOptions { const ScreenCaptureOptions({ required this.includeCursor, + required this.excludeOwnWindows, required this.cropEnabled, required this.crop, }); final bool includeCursor; + final bool excludeOwnWindows; final bool cropEnabled; final Rectangle crop; @@ -84,20 +86,23 @@ class ScreenCaptureOptions { identical(this, other) || (other is ScreenCaptureOptions && other.includeCursor == includeCursor && + other.excludeOwnWindows == excludeOwnWindows && other.cropEnabled == cropEnabled && other.crop == crop); @override - int get hashCode => Object.hash(includeCursor, cropEnabled, crop); + int get hashCode => + Object.hash(includeCursor, excludeOwnWindows, cropEnabled, crop); @override String toString() => - 'ScreenCaptureOptions(includeCursor: $includeCursor, cropEnabled: $cropEnabled, crop: $crop)'; + 'ScreenCaptureOptions(includeCursor: $includeCursor, excludeOwnWindows: $excludeOwnWindows, cropEnabled: $cropEnabled, crop: $crop)'; factory ScreenCaptureOptions.fromNative( c.native_screen_capture_options_t raw, ) => ScreenCaptureOptions( includeCursor: raw.include_cursor, + excludeOwnWindows: raw.exclude_own_windows, cropEnabled: raw.crop_enabled, crop: Rectangle.fromNative(raw.crop), ); @@ -106,6 +111,7 @@ class ScreenCaptureOptions { ffi.Pointer allocNative() { final pointer = pkg_ffi.calloc(); pointer.ref.include_cursor = includeCursor; + pointer.ref.exclude_own_windows = excludeOwnWindows; pointer.ref.crop_enabled = cropEnabled; final cropPointer = crop.allocNative(); pointer.ref.crop = cropPointer.ref; diff --git a/bindings/dart/nativeapi/lib/src/web/screen_capturer.dart b/bindings/dart/nativeapi/lib/src/web/screen_capturer.dart index 98be96ab..ca11ddbc 100644 --- a/bindings/dart/nativeapi/lib/src/web/screen_capturer.dart +++ b/bindings/dart/nativeapi/lib/src/web/screen_capturer.dart @@ -39,11 +39,13 @@ class CaptureSourceSelectionOptions { class ScreenCaptureOptions { const ScreenCaptureOptions({ required this.includeCursor, + required this.excludeOwnWindows, required this.cropEnabled, required this.crop, }); final bool includeCursor; + final bool excludeOwnWindows; final bool cropEnabled; final Rectangle crop; @@ -52,15 +54,17 @@ class ScreenCaptureOptions { identical(this, other) || (other is ScreenCaptureOptions && other.includeCursor == includeCursor && + other.excludeOwnWindows == excludeOwnWindows && other.cropEnabled == cropEnabled && other.crop == crop); @override - int get hashCode => Object.hash(includeCursor, cropEnabled, crop); + int get hashCode => + Object.hash(includeCursor, excludeOwnWindows, cropEnabled, crop); @override String toString() => - 'ScreenCaptureOptions(includeCursor: $includeCursor, cropEnabled: $cropEnabled, crop: $crop)'; + 'ScreenCaptureOptions(includeCursor: $includeCursor, excludeOwnWindows: $excludeOwnWindows, cropEnabled: $cropEnabled, crop: $crop)'; } class ScreenCapturer { diff --git a/bindings/dart/nativeapi/lib/src/web/window.dart b/bindings/dart/nativeapi/lib/src/web/window.dart index c08dd6ad..becfc325 100644 --- a/bindings/dart/nativeapi/lib/src/web/window.dart +++ b/bindings/dart/nativeapi/lib/src/web/window.dart @@ -67,6 +67,24 @@ enum WindowCornerPreference { }; } +enum WindowLevel { + normal(0), + floating(1), + status(2), + screenSaver(3); + + const WindowLevel(this.value); + final int value; + + static WindowLevel fromValue(int value) => switch (value) { + 0 => WindowLevel.normal, + 1 => WindowLevel.floating, + 2 => WindowLevel.status, + 3 => WindowLevel.screenSaver, + _ => WindowLevel.normal, + }; +} + enum WindowProperty { title(0), resizable(1), @@ -446,6 +464,10 @@ class Window { bool get isAlwaysOnTop => unsupported(); + bool setLevel(WindowLevel level) => unsupported(); + + WindowLevel get level => unsupported(); + set isAlwaysOnBottom(bool value) => unsupported(); bool get isAlwaysOnBottom => unsupported(); diff --git a/bindings/dart/nativeapi/lib/src/window.dart b/bindings/dart/nativeapi/lib/src/window.dart index 5184bed4..f7f15508 100644 --- a/bindings/dart/nativeapi/lib/src/window.dart +++ b/bindings/dart/nativeapi/lib/src/window.dart @@ -82,6 +82,26 @@ enum WindowCornerPreference { c.native_window_corner_preference_t.fromValue(value); } +enum WindowLevel { + normal(0), + floating(1), + status(2), + screenSaver(3); + + const WindowLevel(this.value); + final int value; + + static WindowLevel fromValue(int value) => switch (value) { + 0 => WindowLevel.normal, + 1 => WindowLevel.floating, + 2 => WindowLevel.status, + 3 => WindowLevel.screenSaver, + _ => WindowLevel.normal, + }; + + c.native_window_level_t get raw => c.native_window_level_t.fromValue(value); +} + enum WindowProperty { title(0), resizable(1), @@ -774,6 +794,15 @@ class Window implements ffi.Finalizable { return c.native_window_is_always_on_top(nativeHandle); } + bool setLevel(WindowLevel level) { + return c.native_window_set_level(nativeHandle, level.raw); + } + + WindowLevel get level { + final raw = c.native_window_get_level(nativeHandle); + return WindowLevel.fromValue(raw.value); + } + set isAlwaysOnBottom(bool value) { c.native_window_set_always_on_bottom(nativeHandle, value); } diff --git a/bindings/go/nativeapi.gen.go b/bindings/go/nativeapi.gen.go index 2d5511a8..8a1ec0cf 100644 --- a/bindings/go/nativeapi.gen.go +++ b/bindings/go/nativeapi.gen.go @@ -2421,26 +2421,29 @@ func toCCaptureSourceSelectionOptions(value CaptureSourceSelectionOptions) (C.na // ScreenCaptureOptions holds the native ScreenCaptureOptions value. type ScreenCaptureOptions struct { - IncludeCursor bool - CropEnabled bool - Crop Rectangle + IncludeCursor bool + ExcludeOwnWindows bool + CropEnabled bool + Crop Rectangle } func fromCScreenCaptureOptions(raw C.native_screen_capture_options_t) ScreenCaptureOptions { return ScreenCaptureOptions{ - IncludeCursor: bool(raw.include_cursor), - CropEnabled: bool(raw.crop_enabled), - Crop: fromCRectangle(raw.crop), + IncludeCursor: bool(raw.include_cursor), + ExcludeOwnWindows: bool(raw.exclude_own_windows), + CropEnabled: bool(raw.crop_enabled), + Crop: fromCRectangle(raw.crop), } } func toCScreenCaptureOptions(value ScreenCaptureOptions) (C.native_screen_capture_options_t, func()) { var raw C.native_screen_capture_options_t var cleanup []func() raw.include_cursor = C.bool(value.IncludeCursor) + raw.exclude_own_windows = C.bool(value.ExcludeOwnWindows) raw.crop_enabled = C.bool(value.CropEnabled) - cField2, cField2Cleanup := toCRectangle(value.Crop) - cleanup = append(cleanup, func() { cField2Cleanup() }) - raw.crop = cField2 + cField3, cField3Cleanup := toCRectangle(value.Crop) + cleanup = append(cleanup, func() { cField3Cleanup() }) + raw.crop = cField3 return raw, func() { for i := len(cleanup) - 1; i >= 0; i-- { cleanup[i]() @@ -4336,6 +4339,16 @@ const ( WindowCornerPreferenceRoundSmall WindowCornerPreference = 3 ) +// WindowLevel represents native WindowLevel values. +type WindowLevel int32 + +const ( + WindowLevelNormal WindowLevel = 0 + WindowLevelFloating WindowLevel = 1 + WindowLevelStatus WindowLevel = 2 + WindowLevelScreenSaver WindowLevel = 3 +) + // WindowProperty represents native WindowProperty values. type WindowProperty int32 @@ -4890,6 +4903,22 @@ func (w *Window) IsAlwaysOnTop() bool { return bool(result) } +// SetLevel invokes the native SetLevel operation. +// Failure wraps ErrOperationFailed; the native ABI provides no detailed cause. +func (w *Window) SetLevel(level WindowLevel) error { + result := C.native_window_set_level(C.native_window_t(w.nativeHandleValue()), C.native_window_level_t(level)) + if !bool(result) { + return nativeError("Window.SetLevel") + } + return nil +} + +// Level invokes the native GetLevel operation. +func (w *Window) Level() WindowLevel { + result := C.native_window_get_level(C.native_window_t(w.nativeHandleValue())) + return WindowLevel(result) +} + // SetAlwaysOnBottom invokes the native SetAlwaysOnBottom operation. func (w *Window) SetAlwaysOnBottom(isAlwaysOnBottom bool) { C.native_window_set_always_on_bottom(C.native_window_t(w.nativeHandleValue()), C.bool(isAlwaysOnBottom)) diff --git a/bindings/js/lib/screen_capturer.ts b/bindings/js/lib/screen_capturer.ts index f16d3900..fc628d3f 100644 --- a/bindings/js/lib/screen_capturer.ts +++ b/bindings/js/lib/screen_capturer.ts @@ -15,6 +15,7 @@ export interface CaptureSourceSelectionOptions { export interface ScreenCaptureOptions { includeCursor: boolean; + excludeOwnWindows: boolean; cropEnabled: boolean; crop: Rectangle; } diff --git a/bindings/js/lib/window.ts b/bindings/js/lib/window.ts index aeba3d00..27751913 100644 --- a/bindings/js/lib/window.ts +++ b/bindings/js/lib/window.ts @@ -35,6 +35,14 @@ export const WindowCornerPreference = { } as const; export type WindowCornerPreference = (typeof WindowCornerPreference)[keyof typeof WindowCornerPreference]; +export const WindowLevel = { + Normal: 0, + Floating: 1, + Status: 2, + ScreenSaver: 3, +} as const; +export type WindowLevel = (typeof WindowLevel)[keyof typeof WindowLevel]; + export const WindowProperty = { Title: 0, Resizable: 1, @@ -362,6 +370,14 @@ export class Window extends NativeObject { return native.native_window_is_always_on_top(this.nativeHandle); } + setLevel(level: WindowLevel): boolean { + return native.native_window_set_level(this.nativeHandle, level); + } + + get level(): WindowLevel { + return native.native_window_get_level(this.nativeHandle); + } + setAlwaysOnBottom(isAlwaysOnBottom: boolean): void { native.native_window_set_always_on_bottom(this.nativeHandle, isAlwaysOnBottom); } diff --git a/bindings/js/src/generated/types.h b/bindings/js/src/generated/types.h index f5a01371..c7916c18 100644 --- a/bindings/js/src/generated/types.h +++ b/bindings/js/src/generated/types.h @@ -553,6 +553,7 @@ inline bool FromJs(napi_env env, napi_value value, native_capture_source_selecti inline Value ToValue(const native_screen_capture_options_t& value) { Value result = Value::Object(); result.Set("includeCursor", Value::Bool(value.include_cursor)); + result.Set("excludeOwnWindows", Value::Bool(value.exclude_own_windows)); result.Set("cropEnabled", Value::Bool(value.crop_enabled)); result.Set("crop", ToValue(value.crop)); return result; @@ -571,6 +572,14 @@ inline bool FromJs(napi_env env, napi_value value, native_screen_capture_options return false; } } + if (!GetField(env, value, "excludeOwnWindows", &field)) { + return false; + } + if (field != nullptr) { + if (!GetBool(env, field, &out->exclude_own_windows)) { + return false; + } + } if (!GetField(env, value, "cropEnabled", &field)) { return false; } diff --git a/bindings/js/src/generated/window.cc b/bindings/js/src/generated/window.cc index b94c1255..17b18031 100644 --- a/bindings/js/src/generated/window.cc +++ b/bindings/js/src/generated/window.cc @@ -1047,6 +1047,40 @@ napi_value Js_native_window_is_always_on_top(napi_env env, napi_callback_info in return Value::Bool(result).ToJs(env); } +napi_value Js_native_window_set_level(napi_env env, napi_callback_info info) { + Args args(env, info); + if (!args.ok()) { + return nullptr; + } + Arena arena; + (void)arena; + uint64_t self = 0; + if (!GetHandle(env, args[0], &self)) { + return nullptr; + } + native_window_level_t p0 = {}; + if (!GetNumber(env, args[1], &p0)) { + return nullptr; + } + auto result = OnMainThread([&] { return native_window_set_level(self, p0); }); + return Value::Bool(result).ToJs(env); +} + +napi_value Js_native_window_get_level(napi_env env, napi_callback_info info) { + Args args(env, info); + if (!args.ok()) { + return nullptr; + } + Arena arena; + (void)arena; + uint64_t self = 0; + if (!GetHandle(env, args[0], &self)) { + return nullptr; + } + auto result = OnMainThread([&] { return native_window_get_level(self); }); + return Value::Number(static_cast(result)).ToJs(env); +} + napi_value Js_native_window_set_always_on_bottom(napi_env env, napi_callback_info info) { Args args(env, info); if (!args.ok()) { @@ -2266,6 +2300,8 @@ void RegisterWindow(napi_env env, napi_value exports) { Export(env, exports, "native_window_is_window_control_buttons_visible", Js_native_window_is_window_control_buttons_visible); Export(env, exports, "native_window_set_always_on_top", Js_native_window_set_always_on_top); Export(env, exports, "native_window_is_always_on_top", Js_native_window_is_always_on_top); + Export(env, exports, "native_window_set_level", Js_native_window_set_level); + Export(env, exports, "native_window_get_level", Js_native_window_get_level); Export(env, exports, "native_window_set_always_on_bottom", Js_native_window_set_always_on_bottom); Export(env, exports, "native_window_is_always_on_bottom", Js_native_window_is_always_on_bottom); Export(env, exports, "native_window_set_parent_window", Js_native_window_set_parent_window); diff --git a/bindings/js/test/screen_capture.test.ts b/bindings/js/test/screen_capture.test.ts index 8b5ccf79..4baa0681 100644 --- a/bindings/js/test/screen_capture.test.ts +++ b/bindings/js/test/screen_capture.test.ts @@ -13,7 +13,7 @@ test("nested recording options cross the ABI without creating an output", () => try { assert.equal(recorder.state, ScreenRecordingState.Idle); assert.equal(recorder.start(null, "relative.mp4", { - capture: { includeCursor: false, cropEnabled: true, crop: { x: 1, y: 2, width: 32, height: 48 } }, + capture: { includeCursor: false, excludeOwnWindows: false, cropEnabled: true, crop: { x: 1, y: 2, width: 32, height: 48 } }, frameRate: 30, videoBitrate: 1_000_000, }), false); diff --git a/bindings/python/nativeapi/__init__.py b/bindings/python/nativeapi/__init__.py index b0290cbd..df1749ad 100644 --- a/bindings/python/nativeapi/__init__.py +++ b/bindings/python/nativeapi/__init__.py @@ -235,6 +235,7 @@ WindowExitedFullScreenEvent, WindowFocusedEvent, WindowId, + WindowLevel, WindowMaximizedEvent, WindowMinimizedEvent, WindowMovedEvent, @@ -444,6 +445,7 @@ "WindowExitedFullScreenEvent", "WindowFocusedEvent", "WindowId", + "WindowLevel", "WindowManager", "WindowMaximizedEvent", "WindowMinimizedEvent", diff --git a/bindings/python/nativeapi/_capi.py b/bindings/python/nativeapi/_capi.py index 846b721a..363edbfb 100644 --- a/bindings/python/nativeapi/_capi.py +++ b/bindings/python/nativeapi/_capi.py @@ -580,6 +580,7 @@ class native_window_list_t(Structure): ] native_screen_capture_options_t._fields_ = [ ("include_cursor", c_bool), + ("exclude_own_windows", c_bool), ("crop_enabled", c_bool), ("crop", native_rectangle_t), ] @@ -3490,6 +3491,8 @@ class native_window_list_t(Structure): c_uint64, ], ) +native_window_set_level = function("native_window_set_level", c_bool, [c_uint64, c_int]) +native_window_get_level = function("native_window_get_level", c_int, [c_uint64]) native_window_set_always_on_bottom = function( "native_window_set_always_on_bottom", None, diff --git a/bindings/python/nativeapi/screen_capturer.py b/bindings/python/nativeapi/screen_capturer.py index ec04c18f..a6b5b2ca 100644 --- a/bindings/python/nativeapi/screen_capturer.py +++ b/bindings/python/nativeapi/screen_capturer.py @@ -43,6 +43,7 @@ def _to_c(self) -> _C.native_capture_source_selection_options_t: @dataclass class ScreenCaptureOptions: include_cursor: bool = False + exclude_own_windows: bool = False crop_enabled: bool = False crop: _geometry.Rectangle = field(default_factory=lambda: _geometry.Rectangle()) @@ -50,6 +51,7 @@ class ScreenCaptureOptions: def _from_c(cls, raw: _C.native_screen_capture_options_t) -> ScreenCaptureOptions: return cls( bool(raw.include_cursor), + bool(raw.exclude_own_windows), bool(raw.crop_enabled), _geometry.Rectangle._from_c(raw.crop), ) @@ -57,6 +59,7 @@ def _from_c(cls, raw: _C.native_screen_capture_options_t) -> ScreenCaptureOption def _to_c(self) -> _C.native_screen_capture_options_t: raw = _C.native_screen_capture_options_t() raw.include_cursor = self.include_cursor + raw.exclude_own_windows = self.exclude_own_windows raw.crop_enabled = self.crop_enabled raw.crop = self.crop._to_c() return raw diff --git a/bindings/python/nativeapi/window.py b/bindings/python/nativeapi/window.py index a593fe5b..8c0dcbd1 100644 --- a/bindings/python/nativeapi/window.py +++ b/bindings/python/nativeapi/window.py @@ -41,6 +41,13 @@ class WindowCornerPreference(enum.IntEnum): ROUND_SMALL = 3 +class WindowLevel(enum.IntEnum): + NORMAL = 0 + FLOATING = 1 + STATUS = 2 + SCREEN_SAVER = 3 + + class WindowProperty(enum.IntEnum): TITLE = 0 RESIZABLE = 1 @@ -512,6 +519,15 @@ def is_always_on_top(self) -> bool: raw = _C.native_window_is_always_on_top(self._handle) return raw + def set_level(self, level: WindowLevel) -> bool: + raw = _C.native_window_set_level(self._handle, int(level)) + return raw + + @property + def level(self) -> WindowLevel: + raw = _C.native_window_get_level(self._handle) + return _rt.to_enum(WindowLevel, raw) + def set_always_on_bottom(self, is_always_on_bottom: bool) -> None: _C.native_window_set_always_on_bottom(self._handle, is_always_on_bottom) diff --git a/bindings/python/tests/test_screen_capture.py b/bindings/python/tests/test_screen_capture.py index 6b13ca9b..dfe3426b 100644 --- a/bindings/python/tests/test_screen_capture.py +++ b/bindings/python/tests/test_screen_capture.py @@ -21,7 +21,7 @@ def test_static_entry_and_invalid_direct_types(): def test_nested_options_rejection_keeps_idle_recorder(): - capture = ScreenCaptureOptions(False, True, Rectangle(1, 2, 32, 48)) + capture = ScreenCaptureOptions(False, False, True, Rectangle(1, 2, 32, 48)) options = ScreenRecordingOptions(capture, 30.0, 1_000_000) # Exercises the actual nested ctypes value conversion independently of a # desktop/permission; a relative destination is rejected before any capture. diff --git a/bindings/rust/cnativeapi/src/bindings.rs b/bindings/rust/cnativeapi/src/bindings.rs index 13acc8d3..bdb15d26 100644 --- a/bindings/rust/cnativeapi/src/bindings.rs +++ b/bindings/rust/cnativeapi/src/bindings.rs @@ -1427,6 +1427,11 @@ pub const NATIVE_WINDOW_CORNER_PREFERENCE_DO_NOT_ROUND: native_window_corner_pre pub const NATIVE_WINDOW_CORNER_PREFERENCE_ROUND: native_window_corner_preference_t = 2; pub const NATIVE_WINDOW_CORNER_PREFERENCE_ROUND_SMALL: native_window_corner_preference_t = 3; pub type native_window_corner_preference_t = ::std::os::raw::c_uint; +pub const NATIVE_WINDOW_LEVEL_NORMAL: native_window_level_t = 0; +pub const NATIVE_WINDOW_LEVEL_FLOATING: native_window_level_t = 1; +pub const NATIVE_WINDOW_LEVEL_STATUS: native_window_level_t = 2; +pub const NATIVE_WINDOW_LEVEL_SCREEN_SAVER: native_window_level_t = 3; +pub type native_window_level_t = ::std::os::raw::c_uint; pub const NATIVE_WINDOW_PROPERTY_TITLE: native_window_property_t = 0; pub const NATIVE_WINDOW_PROPERTY_RESIZABLE: native_window_property_t = 1; pub const NATIVE_WINDOW_PROPERTY_MOVABLE: native_window_property_t = 2; @@ -1818,6 +1823,12 @@ unsafe extern "C" { unsafe extern "C" { pub fn native_window_is_always_on_top(window: native_window_t) -> bool; } +unsafe extern "C" { + pub fn native_window_set_level(window: native_window_t, level: native_window_level_t) -> bool; +} +unsafe extern "C" { + pub fn native_window_get_level(window: native_window_t) -> native_window_level_t; +} unsafe extern "C" { pub fn native_window_set_always_on_bottom(window: native_window_t, is_always_on_bottom: bool); } @@ -4090,6 +4101,7 @@ pub struct native_capture_source_selection_options_t { #[derive(Debug, Default, Copy, Clone)] pub struct native_screen_capture_options_t { pub include_cursor: bool, + pub exclude_own_windows: bool, pub crop_enabled: bool, pub crop: native_rectangle_t, } diff --git a/bindings/rust/nativeapi/src/modules.rs b/bindings/rust/nativeapi/src/modules.rs index edc93168..fd94b494 100644 --- a/bindings/rust/nativeapi/src/modules.rs +++ b/bindings/rust/nativeapi/src/modules.rs @@ -84,7 +84,7 @@ pub use tray_icon::{TrayIconId, ContextMenuTrigger, TrayIconPosition, TrayIconEv pub use tray_manager::{TrayManager}; pub use url_opener::{UrlOpenErrorCode, UrlOpenResult, UrlOpener}; pub use view::{ViewId, ViewLayout, ViewAlignment, TextAlignment, ViewBackend, TextRange, ViewEvent, View, ViewRef, Label, LabelRef, Button, ButtonRef, TextField, TextFieldRef, ImageView, ImageViewRef}; -pub use window::{WindowId, WindowNumber, TitleBarStyle, WindowDockSide, WindowCornerPreference, WindowProperty, WindowOcclusionState, VisualEffect, ResizeEdge, WindowEvent, Window, WindowRef}; +pub use window::{WindowId, WindowNumber, TitleBarStyle, WindowDockSide, WindowCornerPreference, WindowLevel, WindowProperty, WindowOcclusionState, VisualEffect, ResizeEdge, WindowEvent, Window, WindowRef}; pub use window_drag_session::{WindowDragEvent, WindowDragSession, WindowDragSessionRef}; pub use window_manager::{WindowManager}; pub use window_shadow::{WindowShadow, WindowShadowRef}; diff --git a/bindings/rust/nativeapi/src/screen_capturer.rs b/bindings/rust/nativeapi/src/screen_capturer.rs index 38e53c2b..9634de73 100644 --- a/bindings/rust/nativeapi/src/screen_capturer.rs +++ b/bindings/rust/nativeapi/src/screen_capturer.rs @@ -45,6 +45,7 @@ pub(crate) struct RawOfCaptureSourceSelectionOptions { #[derive(Debug, Clone, PartialEq)] pub struct ScreenCaptureOptions { pub include_cursor: bool, + pub exclude_own_windows: bool, pub crop_enabled: bool, pub crop: Rectangle, } @@ -53,6 +54,7 @@ impl ScreenCaptureOptions { pub(crate) unsafe fn from_raw(raw: &cnativeapi::native_screen_capture_options_t) -> Self { Self { include_cursor: raw.include_cursor, + exclude_own_windows: raw.exclude_own_windows, crop_enabled: raw.crop_enabled, crop: Rectangle::from_raw(&raw.crop), } @@ -61,6 +63,7 @@ impl ScreenCaptureOptions { pub(crate) fn to_raw(&self) -> RawOfScreenCaptureOptions { let mut raw = cnativeapi::native_screen_capture_options_t::default(); raw.include_cursor = self.include_cursor; + raw.exclude_own_windows = self.exclude_own_windows; raw.crop_enabled = self.crop_enabled; let crop_nested = self.crop.to_raw(); raw.crop = crop_nested.raw; diff --git a/bindings/rust/nativeapi/src/window.rs b/bindings/rust/nativeapi/src/window.rs index 45e0ee32..d9646d55 100644 --- a/bindings/rust/nativeapi/src/window.rs +++ b/bindings/rust/nativeapi/src/window.rs @@ -90,6 +90,31 @@ impl WindowCornerPreference { } } +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum WindowLevel { + Normal = 0, + Floating = 1, + Status = 2, + ScreenSaver = 3, +} + +impl WindowLevel { + pub(crate) fn from_raw(raw: cnativeapi::native_window_level_t) -> Self { + match raw { + cnativeapi::NATIVE_WINDOW_LEVEL_NORMAL => Self::Normal, + cnativeapi::NATIVE_WINDOW_LEVEL_FLOATING => Self::Floating, + cnativeapi::NATIVE_WINDOW_LEVEL_STATUS => Self::Status, + cnativeapi::NATIVE_WINDOW_LEVEL_SCREEN_SAVER => Self::ScreenSaver, + _ => Self::Normal, + } + } + + pub(crate) fn to_raw(self) -> cnativeapi::native_window_level_t { + self as cnativeapi::native_window_level_t + } +} + #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum WindowProperty { @@ -690,6 +715,18 @@ impl Window { } } + pub fn set_level(&self, level: WindowLevel) -> bool { + unsafe { + cnativeapi::native_window_set_level(self.handle, level.to_raw()) + } + } + + pub fn level(&self) -> WindowLevel { + unsafe { + WindowLevel::from_raw(cnativeapi::native_window_get_level(self.handle)) + } + } + pub fn set_always_on_bottom(&self, is_always_on_bottom: bool) { unsafe { cnativeapi::native_window_set_always_on_bottom(self.handle, is_always_on_bottom); diff --git a/bindings/rust/nativeapi/tests/screen_capture.rs b/bindings/rust/nativeapi/tests/screen_capture.rs index 7f4914e6..0369ebb2 100644 --- a/bindings/rust/nativeapi/tests/screen_capture.rs +++ b/bindings/rust/nativeapi/tests/screen_capture.rs @@ -16,6 +16,7 @@ fn invalid_request_keeps_recorder_idle() { let options = ScreenRecordingOptions { capture: ScreenCaptureOptions { include_cursor: false, + exclude_own_windows: false, crop_enabled: true, crop: Rectangle { x: 1.0, diff --git a/bindings/swift/Sources/NativeAPI/ScreenCapturer.swift b/bindings/swift/Sources/NativeAPI/ScreenCapturer.swift index f8a16df4..e0502893 100644 --- a/bindings/swift/Sources/NativeAPI/ScreenCapturer.swift +++ b/bindings/swift/Sources/NativeAPI/ScreenCapturer.swift @@ -33,11 +33,13 @@ extension CaptureSourceSelectionOptions { public struct ScreenCaptureOptions { public var includeCursor: Bool + public var excludeOwnWindows: Bool public var cropEnabled: Bool public var crop: Rectangle - public init(includeCursor: Bool, cropEnabled: Bool, crop: Rectangle) { + public init(includeCursor: Bool, excludeOwnWindows: Bool, cropEnabled: Bool, crop: Rectangle) { self.includeCursor = includeCursor + self.excludeOwnWindows = excludeOwnWindows self.cropEnabled = cropEnabled self.crop = crop } @@ -45,12 +47,13 @@ public struct ScreenCaptureOptions { extension ScreenCaptureOptions { init(raw: native_screen_capture_options_t) { - self.init(includeCursor: raw.include_cursor, cropEnabled: raw.crop_enabled, crop: Rectangle(raw: raw.crop)) + self.init(includeCursor: raw.include_cursor, excludeOwnWindows: raw.exclude_own_windows, cropEnabled: raw.crop_enabled, crop: Rectangle(raw: raw.crop)) } func toRaw() -> native_screen_capture_options_t { var raw = native_screen_capture_options_t() raw.include_cursor = self.includeCursor + raw.exclude_own_windows = self.excludeOwnWindows raw.crop_enabled = self.cropEnabled raw.crop = self.crop.toRaw() return raw diff --git a/bindings/swift/Sources/NativeAPI/Window.swift b/bindings/swift/Sources/NativeAPI/Window.swift index c622b4fe..f1f31666 100644 --- a/bindings/swift/Sources/NativeAPI/Window.swift +++ b/bindings/swift/Sources/NativeAPI/Window.swift @@ -66,6 +66,27 @@ public enum WindowCornerPreference: CInt { } } +public enum WindowLevel: CInt { + case normal = 0 + case floating = 1 + case status = 2 + case screenSaver = 3 + + init(raw: native_window_level_t) { + switch raw { + case NATIVE_WINDOW_LEVEL_NORMAL: self = .normal + case NATIVE_WINDOW_LEVEL_FLOATING: self = .floating + case NATIVE_WINDOW_LEVEL_STATUS: self = .status + case NATIVE_WINDOW_LEVEL_SCREEN_SAVER: self = .screenSaver + default: self = .normal + } + } + + var raw: native_window_level_t { + native_window_level_t(rawValue: numericCast(self.rawValue)) + } +} + public enum WindowProperty: CInt { case title = 0 case resizable = 1 @@ -519,6 +540,14 @@ public class Window { return native_window_is_always_on_top(nativeHandle) } + public func setLevel(_ level: WindowLevel) -> Bool { + return native_window_set_level(nativeHandle, level.raw) + } + + public var level: WindowLevel { + return WindowLevel(raw: native_window_get_level(nativeHandle)) + } + public func setAlwaysOnBottom(_ isAlwaysOnBottom: Bool) -> Void { native_window_set_always_on_bottom(nativeHandle, isAlwaysOnBottom) } diff --git a/core b/core index 6cfb84ae..bbdd13bd 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 6cfb84ae3e51163264350e4a9f11e7ddd8f9335d +Subproject commit bbdd13bd971b7b24d60b05c34020e021b196a743 diff --git a/examples/flutter_screen_capture_example/lib/capture_controller.dart b/examples/flutter_screen_capture_example/lib/capture_controller.dart index 030d272d..1516aabb 100644 --- a/examples/flutter_screen_capture_example/lib/capture_controller.dart +++ b/examples/flutter_screen_capture_example/lib/capture_controller.dart @@ -1,15 +1,42 @@ +// ignore_for_file: invalid_use_of_internal_member, implementation_imports + import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:ui' as ui; import 'package:file_selector/file_selector.dart'; -import 'package:flutter/services.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/src/widgets/_window.dart' as fw; import 'package:flutter/widgets.dart'; import 'package:nativeapi/nativeapi.dart' as na; +import 'package:nativeapi_flutter/windowing.dart'; import 'region_selector.dart'; +class _OverlayWindowDelegate with fw.WindowControllerDelegate { + _OverlayWindowDelegate(this.onCloseRequested); + final VoidCallback onCloseRequested; + + @override + void onWindowCloseRequested(fw.WindowController controller) => + onCloseRequested(); +} + +class RegionOverlayEntry { + RegionOverlayEntry({ + required this.displayIndex, + required this.displayBounds, + required this.session, + required this.windowController, + }); + + final int displayIndex; + final na.Rectangle displayBounds; + final RegionSelectionSession session; + final fw.WindowController windowController; +} + class CaptureArtifact { const CaptureArtifact(this.path, {this.duration, this.width, this.height}); final String path; @@ -45,21 +72,12 @@ class CaptureController extends ChangeNotifier { Uint8List? preview; int imageWidth = 0, imageHeight = 0; na.ScreenRecordingState recordingState = na.ScreenRecordingState.idle; - RegionSelectionSession? regionSession; + List regionOverlays = []; (int x, int y, int width, int height)? lastRegionCrop; - ({ - na.Rectangle bounds, - na.TitleBarStyle titleBarStyle, - bool hasShadow, - bool isAlwaysOnTop, - double viewWidth, - double viewHeight, - })? - _savedWindowState; bool get hasSource => _source != null; bool get hasImage => _image != null; - bool get selectingRegion => regionSession != null; + bool get selectingRegion => regionOverlays.isNotEmpty; bool get active => switch (recordingState) { na.ScreenRecordingState.starting || na.ScreenRecordingState.recording || @@ -82,14 +100,14 @@ class CaptureController extends ChangeNotifier { _changed(); } - Future initialize() async { + Future initialize({na.Window? mainWindow}) async { try { final directory = await Directory.systemTemp.createTemp( 'nativeapi-capture-', ); if (_disposed) return; outputDirectory = directory.path; - _window = na.WindowManager.instance.getCurrent(); + _window = mainWindow ?? na.WindowManager.instance.getCurrent(); _window?.contentSize = const na.Size(width: 1120, height: 800); captureSupported = na.ScreenCapturer.isSupported(); recordingSupported = na.ScreenRecorder.isSupported(); @@ -284,19 +302,6 @@ class CaptureController extends ChangeNotifier { } } - /// Debug helper: centers the window on display [index]. - void debugMoveWindowToDisplay(int index) { - if (index < 0 || index >= displays.length || _window == null) return; - final d = _displayBounds(displays[index]); - final b = _window!.bounds; - _window!.bounds = na.Rectangle( - x: d.x + (d.width - b.width) / 2, - y: d.y + (d.height - b.height) / 2, - width: b.width, - height: b.height, - ); - } - na.Rectangle _displayBounds(na.Display display) { final pos = display.position; final sz = display.size; @@ -323,110 +328,32 @@ class CaptureController extends ChangeNotifier { } } } - return displays.firstWhere((d) => d.isPrimary, orElse: () => displays.first); - } - - static const _overlayChannel = MethodChannel( - 'screen_capture_example/overlay', - ); - - ui.Size _currentViewSize() { - final dispatcher = WidgetsBinding.instance.platformDispatcher; - final view = dispatcher.implicitView ?? dispatcher.views.first; - return view.physicalSize / view.devicePixelRatio; - } - - /// Waits until the Flutter view's logical size matches [width] × [height]. - /// Window metrics reach Dart asynchronously after a native resize. - Future _waitForViewSize(double width, double height) async { - final dispatcher = WidgetsBinding.instance.platformDispatcher; - final view = dispatcher.implicitView ?? dispatcher.views.first; - final stopwatch = Stopwatch()..start(); - while (stopwatch.elapsedMilliseconds < 800) { - final size = view.physicalSize / view.devicePixelRatio; - if ((size.width - width).abs() <= 1 && - (size.height - height).abs() <= 1) { - return; - } - await Future.delayed(const Duration(milliseconds: 8)); - } - debugPrint( - '[capture] view size did not reach $width×$height in time: ' - '${view.physicalSize / view.devicePixelRatio}', + return displays.firstWhere( + (d) => d.isPrimary, + orElse: () => displays.first, ); } - Future _restoreWindowFromOverlay({bool disposeSession = true}) async { - final saved = _savedWindowState; - _savedWindowState = null; - final oldSession = regionSession; - regionSession = null; - if (disposeSession) { - oldSession?.dispose(); - } - if (Platform.isMacOS) { - try { - await _overlayChannel.invokeMethod('exitOverlay'); - _changed(); - if (saved != null) { - await _waitForViewSize(saved.viewWidth, saved.viewHeight); - } - await WidgetsBinding.instance.endOfFrame; - await WidgetsBinding.instance.endOfFrame; - await Future.delayed(const Duration(milliseconds: 16)); - await _overlayChannel.invokeMethod('revealWindow'); - } catch (_) { - _window?.show(); - _window?.focus(); + void _closeRegionOverlays({bool disposeSessions = true}) { + final old = regionOverlays; + if (old.isEmpty) return; + regionOverlays = []; + _changed(); + for (final entry in old) { + entry.windowController.destroy(); + if (disposeSessions) { + entry.session.dispose(); } - return; - } - if (saved != null && _window != null) { - _window!.isAlwaysOnTop = saved.isAlwaysOnTop; - _window!.hasShadow = saved.hasShadow; - _window!.titleBarStyle = saved.titleBarStyle; - _window!.bounds = saved.bounds; - _window!.show(); - _window!.focus(); } + _window?.focus(); } - /// Hides the window, captures the full display as a frozen backdrop, and - /// opens a borderless full-display region selection overlay without flashing. - Future startRegionScreenshot({bool includeCursor = false}) async { - if (locked || !captureSupported) return; - final display = _pickDisplayForWindow(); - if (display == null) { - _message('No display available for region screenshot.', failure: true); - return; - } - busy = true; - _message('Preparing region screenshot…'); - - final win = _window; - if (win != null) { - _savedWindowState = ( - bounds: win.bounds, - titleBarStyle: win.titleBarStyle, - hasShadow: win.hasShadow, - isAlwaysOnTop: win.isAlwaysOnTop, - viewWidth: _currentViewSize().width, - viewHeight: _currentViewSize().height, - ); - if (Platform.isMacOS) { - // Window::Hide() uses orderOut, which plays AppKit's fade-and-shrink. - await _overlayChannel.invokeMethod('hideForCapture'); - } else { - win.hide(); - } - } - + Future _captureDisplaySession( + na.Display display, { + required bool includeCursor, + }) async { na.CaptureSource? tempSource; try { - // Brief pause so the compositor removes our window before capturing. - await Future.delayed(const Duration(milliseconds: 80)); - if (_disposed) return; - tempSource = na.CaptureSource.fromDisplay(display); if (tempSource == null) { throw StateError('Cannot create capture source for display.'); @@ -436,16 +363,13 @@ class CaptureController extends ChangeNotifier { tempSource, na.ScreenCaptureOptions( includeCursor: includeCursor, + excludeOwnWindows: true, cropEnabled: false, crop: const na.Rectangle(x: 0, y: 0, width: 0, height: 0), ), (success, image) => result.complete((success, image)), ); final (success, fullImage) = await result.future; - if (_disposed) { - fullImage?.dispose(); - return; - } if (!success || fullImage == null) { fullImage?.dispose(); throw StateError( @@ -470,91 +394,140 @@ class CaptureController extends ChangeNotifier { fullImage.dispose(); } - // Pre-decode the PNG into a GPU-ready ui.Image before revealing the - // overlay so the very first visible frame already has pixels (no flash). final codec = await ui.instantiateImageCodec(fullBytes); final frame = await codec.getNextFrame(); codec.dispose(); - if (_disposed) { - frame.image.dispose(); - return; - } - - regionSession = RegionSelectionSession( + return RegionSelectionSession( fullUiImage: frame.image, physicalWidth: physW, physicalHeight: physH, ); + } finally { + tempSource?.dispose(); + } + } + + /// Captures every display (excluding this app's own windows) and opens a + /// dedicated borderless, screen-saver-level overlay window on each display + /// using Flutter multi-window + nativeapi alone. The main window stays put. + Future startRegionScreenshot({bool includeCursor = false}) async { + if (locked || !captureSupported) return; + displays = na.DisplayManager.instance.getAll(); + if (displays.isEmpty) { + _message('No display available for region screenshot.', failure: true); + return; + } + busy = true; + _message('Preparing region screenshot…'); + + final activeDisplay = _pickDisplayForWindow(); + final created = []; + try { + for (var i = 0; i < displays.length; i++) { + final display = displays[i]; + final session = await _captureDisplaySession( + display, + includeCursor: includeCursor, + ); + if (_disposed) { + session.dispose(); + return; + } + final bounds = _displayBounds(display); + final controller = fw.WindowController( + size: Size(bounds.width, bounds.height), + title: 'Region Overlay ${i + 1}', + delegate: _OverlayWindowDelegate(cancelRegionSelection), + ); + final overlayWin = controller.nativeWindow; + if (overlayWin != null) { + overlayWin.opacity = 0.0; + overlayWin.setFrameless(true); + overlayWin.hasShadow = false; + overlayWin.setLevel(na.WindowLevel.screenSaver); + overlayWin.isVisibleOnAllWorkspaces = true; + overlayWin.setVisibleOnFullScreen(true); + overlayWin.isVisibleInTaskbar = false; + overlayWin.bounds = bounds; + } + created.add( + RegionOverlayEntry( + displayIndex: i, + displayBounds: bounds, + session: session, + windowController: controller, + ), + ); + } + + regionOverlays = created; busy = false; - final bounds = _displayBounds(display); - - if (Platform.isMacOS) { - // Resize off-screen at alpha 0 and wait until the Flutter view really - // reports the full-display size. Only then build the overlay and let - // it render, so no frame at the old window size is ever revealed. - await _overlayChannel.invokeMethod('prepareOverlay', { - 'x': bounds.x, - 'y': bounds.y, - 'width': bounds.width, - 'height': bounds.height, - }); - await _waitForViewSize(bounds.width, bounds.height); - if (_disposed || regionSession == null) return; - _changed(); - await WidgetsBinding.instance.endOfFrame; - await WidgetsBinding.instance.endOfFrame; - // One more vsync so the raster thread has presented the frame. - await Future.delayed(const Duration(milliseconds: 16)); - if (_disposed || regionSession == null) return; - await _overlayChannel.invokeMethod('revealOverlay'); - } else { - _changed(); - await WidgetsBinding.instance.endOfFrame; - if (_disposed || regionSession == null) return; - if (win != null) { - win.titleBarStyle = na.TitleBarStyle.hidden; - win.hasShadow = false; - win.isAlwaysOnTop = true; - win.bounds = bounds; - win.show(); - win.focus(); + _changed(); + + // Let Flutter render the pre-decoded frozen frames in every overlay + // window before making them visible. + await WidgetsBinding.instance.endOfFrame; + await WidgetsBinding.instance.endOfFrame; + await Future.delayed(const Duration(milliseconds: 16)); + if (_disposed || regionOverlays.isEmpty) return; + + RegionOverlayEntry? focusEntry; + for (final entry in regionOverlays) { + final overlayWin = entry.windowController.nativeWindow; + if (overlayWin != null) { + overlayWin.opacity = 1.0; + overlayWin.showInactive(); + } + if (activeDisplay != null && + displays[entry.displayIndex].id == activeDisplay.id) { + focusEntry = entry; } } + (focusEntry ?? regionOverlays.first).windowController.nativeWindow + ?.focus(); } catch (e) { - await _restoreWindowFromOverlay(); + for (final entry in created) { + entry.windowController.destroy(); + entry.session.dispose(); + } + regionOverlays = []; busy = false; _message('Region screenshot failed: $e', failure: true); - } finally { - tempSource?.dispose(); } } void cancelRegionSelection() { - if (regionSession == null) return; - unawaited( - _restoreWindowFromOverlay().then((_) { - _message('Region screenshot cancelled.'); - }), - ); + if (regionOverlays.isEmpty) return; + _closeRegionOverlays(); + _message('Region screenshot cancelled.'); } Future completeRegionSelection( + RegionOverlayEntry entry, ui.Rect normalizedRect, RegionAction action, ) async { - final session = regionSession; - if (session == null) return; + if (regionOverlays.isEmpty) return; + final session = entry.session; busy = true; - await _restoreWindowFromOverlay(disposeSession: false); + // Close all overlays immediately; dispose other displays' sessions, keep + // the chosen display's session alive until cropping finishes below. + final others = regionOverlays.where((e) => !identical(e, entry)).toList(); + _closeRegionOverlays(disposeSessions: false); + for (final other in others) { + other.session.dispose(); + } _changed(); try { - final x = (normalizedRect.left * session.physicalWidth) - .round() - .clamp(0, session.physicalWidth - 1); - final y = (normalizedRect.top * session.physicalHeight) - .round() - .clamp(0, session.physicalHeight - 1); + final x = (normalizedRect.left * session.physicalWidth).round().clamp( + 0, + session.physicalWidth - 1, + ); + final y = (normalizedRect.top * session.physicalHeight).round().clamp( + 0, + session.physicalHeight - 1, + ); final right = (normalizedRect.right * session.physicalWidth) .round() .clamp(x + 1, session.physicalWidth); @@ -774,7 +747,7 @@ class CaptureController extends ChangeNotifier { na.Application.instance.removeListener(_quitListener!); } _image?.dispose(); - regionSession?.dispose(); + _closeRegionOverlays(); _source?.dispose(); for (final display in displays) { display.dispose(); diff --git a/examples/flutter_screen_capture_example/lib/main.dart b/examples/flutter_screen_capture_example/lib/main.dart index 5a3b4960..c65af64d 100644 --- a/examples/flutter_screen_capture_example/lib/main.dart +++ b/examples/flutter_screen_capture_example/lib/main.dart @@ -1,28 +1,128 @@ +// ignore_for_file: invalid_use_of_internal_member, implementation_imports + import 'dart:async'; -import 'dart:io'; +import 'dart:ui' show AppExitType; import 'package:dazzui_host/dazzui_host.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter/src/foundation/_features.dart' show isWindowingEnabled; +import 'package:flutter/src/widgets/_window.dart' as fw; import 'package:nativeapi/nativeapi.dart' as na; +import 'package:nativeapi_flutter/windowing.dart'; import 'capture_controller.dart'; import 'region_selector.dart'; -void main() => runApp(const CaptureApp()); +void main() { + // Turn on Flutter's experimental multi-window API before binding startup so + // region screenshots can spawn one overlay window per display. + isWindowingEnabled = true; + WidgetsFlutterBinding.ensureInitialized(); + runWidget(const CaptureApp()); +} + +class _MainWindowDelegate with fw.WindowControllerDelegate { + _MainWindowDelegate(this.onCloseRequested); + final VoidCallback onCloseRequested; + + @override + void onWindowCloseRequested(fw.WindowController controller) => + onCloseRequested(); +} -class CaptureApp extends StatelessWidget { +class CaptureApp extends StatefulWidget { const CaptureApp({super.key, this.controller}); final CaptureController? controller; @override - Widget build(BuildContext context) => Host( - title: 'Screen Capture', - home: CapturePage(controller: controller), + State createState() => _CaptureAppState(); +} + +class _CaptureAppState extends State { + late final CaptureController _capture; + late final bool _ownsController; + late final fw.WindowController _mainController; + + @override + void initState() { + super.initState(); + _ownsController = widget.controller == null; + _capture = widget.controller ?? CaptureController(); + _mainController = fw.WindowController( + size: const Size(1120, 800), + title: 'Screen Capture', + delegate: _MainWindowDelegate(_handleMainClose), + ); + } + + void _handleMainClose() { + if (_capture.busy || _capture.active) { + _capture.reportInvalidOptions( + 'Finish the current action, or stop / discard the recording before closing.', + ); + return; + } + _capture.cancelRegionSelection(); + _mainController.destroy(); + unawaited(ServicesBinding.instance.exitApplication(AppExitType.required)); + } + + @override + void dispose() { + if (_ownsController) { + _capture.dispose(); + } + super.dispose(); + } + + @override + Widget build(BuildContext context) => ListenableBuilder( + listenable: _capture, + builder: (context, _) => ViewCollection( + views: [ + fw.Window( + controller: _mainController, + child: Host( + title: 'Screen Capture', + home: CapturePage( + controller: _capture, + mainWindow: _mainController.nativeWindow, + ownsController: false, + ), + ), + ), + for (final entry in _capture.regionOverlays) + fw.Window( + key: ValueKey(entry.windowController), + controller: entry.windowController, + child: Directionality( + textDirection: TextDirection.ltr, + child: RegionSelectionOverlay( + session: entry.session, + onCancel: _capture.cancelRegionSelection, + onConfirm: (rect, action) { + unawaited( + _capture.completeRegionSelection(entry, rect, action), + ); + }, + ), + ), + ), + ], + ), ); } class CapturePage extends StatefulWidget { - const CapturePage({super.key, this.controller}); + const CapturePage({ + super.key, + this.controller, + this.mainWindow, + this.ownsController = true, + }); final CaptureController? controller; + final na.Window? mainWindow; + final bool ownsController; @override State createState() => _CapturePageState(); } @@ -39,32 +139,39 @@ class _CapturePageState extends State { double frameRate = 30; int bitrate = 0; + (int, int, int, int)? _syncedCrop; + + void _syncCropFields() { + final crop = capture.lastRegionCrop; + if (crop != null && crop != _syncedCrop) { + _syncedCrop = crop; + cropFields[0].text = '${crop.$1}'; + cropFields[1].text = '${crop.$2}'; + cropFields[2].text = '${crop.$3}'; + cropFields[3].text = '${crop.$4}'; + } + } + @override void initState() { super.initState(); capture = widget.controller ?? CaptureController(); - WidgetsBinding.instance.addPostFrameCallback((_) async { + capture.addListener(_syncCropFields); + WidgetsBinding.instance.addPostFrameCallback((_) { if (!mounted) return; - await capture.initialize(); - // Debug hook for recording the overlay transition without input. - if (Platform.environment['CAPTURE_AUTO_REGION'] == '1') { - final index = - int.tryParse(Platform.environment['CAPTURE_AUTO_DISPLAY'] ?? ''); - if (index != null) capture.debugMoveWindowToDisplay(index); - await Future.delayed(const Duration(milliseconds: 1500)); - await capture.startRegionScreenshot(); - await Future.delayed(const Duration(milliseconds: 1500)); - capture.cancelRegionSelection(); - } + unawaited(capture.initialize(mainWindow: widget.mainWindow)); }); } @override void dispose() { + capture.removeListener(_syncCropFields); for (final field in cropFields) { field.dispose(); } - capture.dispose(); + if (widget.ownsController) { + capture.dispose(); + } super.dispose(); } @@ -85,6 +192,7 @@ class _CapturePageState extends State { } return na.ScreenCaptureOptions( includeCursor: includeCursor, + excludeOwnWindows: false, cropEnabled: cropEnabled, crop: na.Rectangle( x: (values[0] ?? 0).toDouble(), @@ -145,26 +253,6 @@ class _CapturePageState extends State { Widget build(BuildContext context) => ListenableBuilder( listenable: capture, builder: (context, _) { - final session = capture.regionSession; - if (session != null) { - return RegionSelectionOverlay( - session: session, - onCancel: capture.cancelRegionSelection, - onConfirm: (rect, action) { - unawaited( - capture.completeRegionSelection(rect, action).then((_) { - final crop = capture.lastRegionCrop; - if (crop != null && mounted) { - cropFields[0].text = '${crop.$1}'; - cropFields[1].text = '${crop.$2}'; - cropFields[2].text = '${crop.$3}'; - cropFields[3].text = '${crop.$4}'; - } - }), - ); - }, - ); - } final vars = context.vars; return Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -524,10 +612,7 @@ class _CapturePageState extends State { style: context.vars.mono, ), const SizedBox(width: 10), - action( - 'Copy', - !capture.locked ? capture.copyScreenshot : null, - ), + action('Copy', !capture.locked ? capture.copyScreenshot : null), ], ], ), diff --git a/examples/flutter_screen_capture_example/lib/region_selector.dart b/examples/flutter_screen_capture_example/lib/region_selector.dart index bc554468..3a94eff6 100644 --- a/examples/flutter_screen_capture_example/lib/region_selector.dart +++ b/examples/flutter_screen_capture_example/lib/region_selector.dart @@ -139,7 +139,10 @@ class _RegionSelectionOverlayState extends State { setState(() { _cursor = pos; if (_dragMode == _DragMode.create) { - _selection = _clampRect(Rect.fromPoints(_dragAnchor, pos), _viewportSize); + _selection = _clampRect( + Rect.fromPoints(_dragAnchor, pos), + _viewportSize, + ); } else if (_dragMode == _DragMode.move) { final delta = pos - _dragAnchor; var dx = delta.dx; diff --git a/examples/flutter_screen_capture_example/macos/Runner/AppDelegate.swift b/examples/flutter_screen_capture_example/macos/Runner/AppDelegate.swift index b3c17614..3c533206 100644 --- a/examples/flutter_screen_capture_example/macos/Runner/AppDelegate.swift +++ b/examples/flutter_screen_capture_example/macos/Runner/AppDelegate.swift @@ -3,6 +3,8 @@ import FlutterMacOS @main class AppDelegate: FlutterAppDelegate { + var engine: FlutterEngine? + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } @@ -10,4 +12,11 @@ class AppDelegate: FlutterAppDelegate { override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { return true } + + override func applicationDidFinishLaunching(_ notification: Notification) { + let flutterEngine = FlutterEngine(name: "project", project: nil) + RegisterGeneratedPlugins(registry: flutterEngine) + flutterEngine.run(withEntrypoint: nil) + engine = flutterEngine + } } diff --git a/examples/flutter_screen_capture_example/macos/Runner/Base.lproj/MainMenu.xib b/examples/flutter_screen_capture_example/macos/Runner/Base.lproj/MainMenu.xib index 80e867a4..65f92008 100644 --- a/examples/flutter_screen_capture_example/macos/Runner/Base.lproj/MainMenu.xib +++ b/examples/flutter_screen_capture_example/macos/Runner/Base.lproj/MainMenu.xib @@ -16,7 +16,6 @@ - @@ -330,14 +329,5 @@ - - - - - - - - - diff --git a/examples/flutter_screen_capture_example/macos/Runner/MainFlutterWindow.swift b/examples/flutter_screen_capture_example/macos/Runner/MainFlutterWindow.swift index 7312cf55..3cc05eb2 100644 --- a/examples/flutter_screen_capture_example/macos/Runner/MainFlutterWindow.swift +++ b/examples/flutter_screen_capture_example/macos/Runner/MainFlutterWindow.swift @@ -2,21 +2,6 @@ import Cocoa import FlutterMacOS class MainFlutterWindow: NSWindow { - private var isRegionOverlay = false - private var savedLevel: NSWindow.Level = .normal - private var savedCollectionBehavior: NSWindow.CollectionBehavior = [] - private var savedStyleMask: NSWindow.StyleMask = [] - private var savedHasShadow = true - private var savedFrame: NSRect = .zero - private var savedAnimationBehavior: NSWindow.AnimationBehavior = .default - - override var canBecomeKey: Bool { true } - override var canBecomeMain: Bool { true } - - override func constrainFrameRect(_ frameRect: NSRect, to screen: NSScreen?) -> NSRect { - return isRegionOverlay ? frameRect : super.constrainFrameRect(frameRect, to: screen) - } - override func awakeFromNib() { let flutterViewController = FlutterViewController() let windowFrame = self.frame @@ -25,133 +10,6 @@ class MainFlutterWindow: NSWindow { RegisterGeneratedPlugins(registry: flutterViewController) - let channel = FlutterMethodChannel( - name: "screen_capture_example/overlay", - binaryMessenger: flutterViewController.engine.binaryMessenger - ) - channel.setMethodCallHandler { [weak self] call, result in - guard let self else { - result(nil) - return - } - switch call.method { - case "prepareOverlay": - guard let args = call.arguments as? [String: Double], - let x = args["x"], - let y = args["y"], - let width = args["width"], - let height = args["height"] else { - result(FlutterError(code: "INVALID_ARGS", message: "Missing bounds", details: nil)) - return - } - self.prepareRegionOverlay(x: x, y: y, width: width, height: height) - result(nil) - case "revealOverlay": - self.revealRegionOverlay() - result(nil) - case "exitOverlay": - self.exitRegionOverlay() - result(nil) - case "hideForCapture": - self.hideForCapture() - result(nil) - case "revealWindow": - self.revealWindow() - result(nil) - default: - result(FlutterMethodNotImplemented) - } - } - super.awakeFromNib() } - - private var animationSaved = false - - private func saveAnimationBehavior() { - if animationSaved { return } - savedAnimationBehavior = self.animationBehavior - animationSaved = true - } - - /// Hides the window instantly. A plain orderOut on a document window plays - /// AppKit's fade-and-shrink animation, which is visible before the overlay. - private func hideForCapture() { - saveAnimationBehavior() - self.animationBehavior = .none - CATransaction.begin() - CATransaction.setDisableActions(true) - self.alphaValue = 0.0 - self.orderOut(nil) - CATransaction.commit() - } - - private func prepareRegionOverlay(x: Double, y: Double, width: Double, height: Double) { - if !isRegionOverlay { - savedLevel = self.level - savedCollectionBehavior = self.collectionBehavior - savedStyleMask = self.styleMask - savedHasShadow = self.hasShadow - savedFrame = self.frame - saveAnimationBehavior() - } - isRegionOverlay = true - - // Convert top-left screen coordinates (origin at primary display top-left) - // to AppKit bottom-left coordinates. - let primaryHeight = Double( - NSScreen.screens.first?.frame.height ?? self.screen?.frame.height ?? CGFloat(height) - ) - let targetFrame = NSRect(x: x, y: primaryHeight - y - height, width: width, height: height) - - // Disable macOS's native window scale/fade animation and keep alpha at 0 - // until Flutter finishes rendering at the full-screen size. - self.animationBehavior = .none - self.alphaValue = 0.0 - self.styleMask = [.borderless] - self.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.screenSaverWindow))) - self.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary, .stationary] - self.hasShadow = false - // Order in (still invisible) before resizing so the Flutter view's resize - // synchronizer produces a frame at the new size. - self.orderFrontRegardless() - self.setFrame(targetFrame, display: true, animate: false) - self.contentView?.layoutSubtreeIfNeeded() - } - - private func revealRegionOverlay() { - guard isRegionOverlay else { return } - CATransaction.begin() - CATransaction.setDisableActions(true) - self.alphaValue = 1.0 - self.makeKeyAndOrderFront(nil) - NSApp.activate(ignoringOtherApps: true) - CATransaction.commit() - } - - private func exitRegionOverlay() { - guard isRegionOverlay else { return } - isRegionOverlay = false - // Stay invisible while shrinking back; Dart reveals with "revealWindow" - // once the view has rendered at the restored size. - self.alphaValue = 0.0 - self.level = savedLevel - self.collectionBehavior = savedCollectionBehavior - self.styleMask = savedStyleMask - self.hasShadow = savedHasShadow - self.setFrame(savedFrame, display: true, animate: false) - self.contentView?.layoutSubtreeIfNeeded() - } - - private func revealWindow() { - CATransaction.begin() - CATransaction.setDisableActions(true) - self.alphaValue = 1.0 - self.makeKeyAndOrderFront(nil) - CATransaction.commit() - if animationSaved { - self.animationBehavior = savedAnimationBehavior - animationSaved = false - } - } } diff --git a/examples/flutter_screen_capture_example/windows/runner/main.cpp b/examples/flutter_screen_capture_example/windows/runner/main.cpp index ba6ab093..26fc2e98 100644 --- a/examples/flutter_screen_capture_example/windows/runner/main.cpp +++ b/examples/flutter_screen_capture_example/windows/runner/main.cpp @@ -1,36 +1,27 @@ #include -#include +#include +#include #include -#include "flutter_window.h" +#include + #include "utils.h" int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, - _In_ wchar_t *command_line, _In_ int show_command) { - // Attach to console when present (e.g., 'flutter run') or create a - // new console when running with a debugger. + _In_ wchar_t* command_line, _In_ int show_command) { if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { CreateAndAttachConsole(); } - // Initialize COM, so that it is available for use in the library and/or - // plugins. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); flutter::DartProject project(L"data"); - - std::vector command_line_arguments = - GetCommandLineArguments(); - + auto command_line_arguments = GetCommandLineArguments(); project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); - FlutterWindow window(project); - Win32Window::Point origin(10, 10); - Win32Window::Size size(1280, 720); - if (!window.Create(L"screen_capture_example", origin, size)) { - return EXIT_FAILURE; - } - window.SetQuitOnClose(true); + auto engine = std::make_shared(project); + RegisterPlugins(engine.get()); + engine->Run(); ::MSG msg; while (::GetMessage(&msg, nullptr, 0, 0)) { diff --git a/website/content/api/index.json b/website/content/api/index.json index 9e66c1f2..74c297c5 100644 --- a/website/content/api/index.json +++ b/website/content/api/index.json @@ -1315,6 +1315,21 @@ "swift" ] }, + { + "key": "WindowLevel", + "kind": "enum", + "summary": "Stacking level of a top-level window relative to system chrome.", + "languages": [ + "cpp", + "csharp", + "dart", + "go", + "js", + "python", + "rust", + "swift" + ] + }, { "key": "WindowProperty", "kind": "enum", diff --git a/website/content/api/screen_capturer.json b/website/content/api/screen_capturer.json index 70bcf47c..7ac38b4f 100644 --- a/website/content/api/screen_capturer.json +++ b/website/content/api/screen_capturer.json @@ -536,6 +536,47 @@ } } }, + { + "key": "ScreenCaptureOptions::exclude_own_windows", + "kind": "field", + "doc": { + "summary": "Exclude this application's own windows from display captures when supported." + }, + "signatures": { + "cpp": { + "name": "exclude_own_windows", + "signature": "bool exclude_own_windows" + }, + "csharp": { + "name": "ExcludeOwnWindows", + "signature": "public bool ExcludeOwnWindows;" + }, + "dart": { + "name": "excludeOwnWindows", + "signature": "final bool excludeOwnWindows" + }, + "go": { + "name": "ExcludeOwnWindows", + "signature": "ExcludeOwnWindows bool" + }, + "js": { + "name": "excludeOwnWindows", + "signature": "excludeOwnWindows: boolean" + }, + "python": { + "name": "exclude_own_windows", + "signature": "exclude_own_windows: bool = False" + }, + "rust": { + "name": "exclude_own_windows", + "signature": "pub exclude_own_windows: bool" + }, + "swift": { + "name": "excludeOwnWindows", + "signature": "var excludeOwnWindows: Bool" + } + } + }, { "key": "ScreenCaptureOptions::crop_enabled", "kind": "field", diff --git a/website/content/api/window.json b/website/content/api/window.json index 34318162..1b5e12da 100644 --- a/website/content/api/window.json +++ b/website/content/api/window.json @@ -3057,6 +3057,109 @@ } } }, + { + "key": "Window::SetLevel", + "kind": "method", + "doc": { + "summary": "Sets the stacking level of the window relative to system chrome.", + "details": "Higher levels keep the window above the menu bar, Dock, or taskbar. On macOS, levels at or above WindowLevel::Status also allow SetBounds() to span the full display without being constrained below the menu bar. Setting Floating, Status, or ScreenSaver implies always-on-top; setting Normal clears it.", + "params": [ + { + "name": "level", + "text": "The desired stacking level" + } + ], + "returns": "true if the level was applied, false if unsupported or invalid", + "notes": [ + { + "kind": "note", + "text": "Platform availability:\n- macOS: ✅ Fully supported - Maps to NSWindow levels (Normal, Floating, Status, ScreenSaver) and skips AppKit frame clamping at Status and above.\n- Windows: ✅ Supported - Normal uses HWND_NOTOPMOST; Floating, Status and ScreenSaver use HWND_TOPMOST (a borderless topmost window covers the taskbar).\n- Linux: ⚠️ Supported on X11 via _NET_WM_STATE_ABOVE; compositor-dependent on Wayland.\n- Android: ❌ Not applicable - Always returns false\n- iOS: ❌ Not applicable - Always returns false\n- OpenHarmony: ❌ Not applicable - Always returns false" + } + ] + }, + "signatures": { + "cpp": { + "name": "SetLevel", + "signature": "bool SetLevel(WindowLevel level)" + }, + "csharp": { + "name": "SetLevel", + "signature": "public bool SetLevel(WindowLevel level)" + }, + "dart": { + "name": "setLevel", + "signature": "bool setLevel(WindowLevel level)" + }, + "go": { + "name": "SetLevel", + "signature": "func (w *Window) SetLevel(level WindowLevel) error" + }, + "js": { + "name": "setLevel", + "signature": "setLevel(level: WindowLevel): boolean" + }, + "python": { + "name": "set_level", + "signature": "def set_level(self, level: WindowLevel) -> bool:" + }, + "rust": { + "name": "set_level", + "signature": "pub fn set_level(&self, level: WindowLevel) -> bool" + }, + "swift": { + "name": "setLevel", + "signature": "func setLevel(_ level: WindowLevel) -> Bool" + } + } + }, + { + "key": "Window::GetLevel", + "kind": "method", + "doc": { + "summary": "Gets the current stacking level of the window.", + "returns": "The current WindowLevel, or WindowLevel::Normal when unavailable.", + "notes": [ + { + "kind": "see", + "text": "SetLevel() for platform availability." + } + ] + }, + "signatures": { + "cpp": { + "name": "GetLevel", + "signature": "WindowLevel GetLevel() const" + }, + "csharp": { + "name": "Level", + "signature": "public WindowLevel Level" + }, + "dart": { + "name": "level", + "signature": "WindowLevel get level" + }, + "go": { + "name": "Level", + "signature": "func (w *Window) Level() WindowLevel" + }, + "js": { + "name": "level", + "signature": "get level(): WindowLevel" + }, + "python": { + "name": "level", + "signature": "@property\ndef level(self) -> WindowLevel:" + }, + "rust": { + "name": "level", + "signature": "pub fn level(&self) -> WindowLevel" + }, + "swift": { + "name": "level", + "signature": "var level: WindowLevel" + } + } + }, { "key": "Window::SetAlwaysOnBottom", "kind": "method", @@ -6913,6 +7016,219 @@ } ] }, + { + "key": "WindowLevel", + "kind": "enum", + "doc": { + "summary": "Stacking level of a top-level window relative to system chrome.", + "notes": [ + { + "kind": "see", + "text": "Window::SetLevel() for platform availability." + } + ] + }, + "signatures": { + "cpp": { + "name": "WindowLevel", + "signature": "enum class WindowLevel" + }, + "csharp": { + "name": "WindowLevel", + "signature": "public enum WindowLevel" + }, + "dart": { + "name": "WindowLevel", + "signature": "enum WindowLevel" + }, + "go": { + "name": "WindowLevel", + "signature": "type WindowLevel int32" + }, + "js": { + "name": "WindowLevel", + "signature": "export const WindowLevel =\nexport type WindowLevel = (typeof WindowLevel)[keyof typeof WindowLevel]" + }, + "python": { + "name": "WindowLevel", + "signature": "class WindowLevel(enum.IntEnum):" + }, + "rust": { + "name": "WindowLevel", + "signature": "pub enum WindowLevel" + }, + "swift": { + "name": "WindowLevel", + "signature": "enum WindowLevel: CInt" + } + }, + "members": [ + { + "key": "WindowLevel::Normal", + "kind": "variant", + "doc": { + "summary": "Normal application window stacking order." + }, + "signatures": { + "cpp": { + "name": "Normal", + "signature": "Normal = 0" + }, + "csharp": { + "name": "WindowLevel.Normal", + "signature": "Normal = 0" + }, + "dart": { + "name": "WindowLevel.normal", + "signature": "normal(0)" + }, + "go": { + "name": "WindowLevelNormal", + "signature": "const WindowLevelNormal WindowLevel = 0" + }, + "js": { + "name": "WindowLevel.Normal", + "signature": "Normal: 0" + }, + "python": { + "name": "NORMAL", + "signature": "NORMAL = 0" + }, + "rust": { + "name": "WindowLevel::Normal", + "signature": "Normal = 0" + }, + "swift": { + "name": "normal", + "signature": "case normal = 0" + } + } + }, + { + "key": "WindowLevel::Floating", + "kind": "variant", + "doc": { + "summary": "Above normal windows; equivalent to SetAlwaysOnTop(true)." + }, + "signatures": { + "cpp": { + "name": "Floating", + "signature": "Floating = 1" + }, + "csharp": { + "name": "WindowLevel.Floating", + "signature": "Floating = 1" + }, + "dart": { + "name": "WindowLevel.floating", + "signature": "floating(1)" + }, + "go": { + "name": "WindowLevelFloating", + "signature": "const WindowLevelFloating WindowLevel = 1" + }, + "js": { + "name": "WindowLevel.Floating", + "signature": "Floating: 1" + }, + "python": { + "name": "FLOATING", + "signature": "FLOATING = 1" + }, + "rust": { + "name": "WindowLevel::Floating", + "signature": "Floating = 1" + }, + "swift": { + "name": "floating", + "signature": "case floating = 1" + } + } + }, + { + "key": "WindowLevel::Status", + "kind": "variant", + "doc": { + "summary": "Above the menu bar / taskbar, e.g. status overlays." + }, + "signatures": { + "cpp": { + "name": "Status", + "signature": "Status = 2" + }, + "csharp": { + "name": "WindowLevel.Status", + "signature": "Status = 2" + }, + "dart": { + "name": "WindowLevel.status", + "signature": "status(2)" + }, + "go": { + "name": "WindowLevelStatus", + "signature": "const WindowLevelStatus WindowLevel = 2" + }, + "js": { + "name": "WindowLevel.Status", + "signature": "Status: 2" + }, + "python": { + "name": "STATUS", + "signature": "STATUS = 2" + }, + "rust": { + "name": "WindowLevel::Status", + "signature": "Status = 2" + }, + "swift": { + "name": "status", + "signature": "case status = 2" + } + } + }, + { + "key": "WindowLevel::ScreenSaver", + "kind": "variant", + "doc": { + "summary": "Above everything normally visible, including the Dock." + }, + "signatures": { + "cpp": { + "name": "ScreenSaver", + "signature": "ScreenSaver = 3" + }, + "csharp": { + "name": "WindowLevel.ScreenSaver", + "signature": "ScreenSaver = 3" + }, + "dart": { + "name": "WindowLevel.screenSaver", + "signature": "screenSaver(3)" + }, + "go": { + "name": "WindowLevelScreenSaver", + "signature": "const WindowLevelScreenSaver WindowLevel = 3" + }, + "js": { + "name": "WindowLevel.ScreenSaver", + "signature": "ScreenSaver: 3" + }, + "python": { + "name": "SCREEN_SAVER", + "signature": "SCREEN_SAVER = 3" + }, + "rust": { + "name": "WindowLevel::ScreenSaver", + "signature": "ScreenSaver = 3" + }, + "swift": { + "name": "screenSaver", + "signature": "case screenSaver = 3" + } + } + } + ] + }, { "key": "WindowProperty", "kind": "enum",