Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/csharp/src/CNativeAPI/generated/ScreenCapturer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions bindings/csharp/src/CNativeAPI/generated/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 5 additions & 2 deletions bindings/csharp/src/NativeAPI/ScreenCapturer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions bindings/csharp/src/NativeAPI/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 42 additions & 0 deletions bindings/dart/cnativeapi/lib/src/bindings_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3611,6 +3611,15 @@ native_window_dock_side_t native_window_get_dock_side(
@ffi.Native<native_window_id_t Function(native_window_t)>()
external int native_window_get_id(int window);

@ffi.Native<ffi.UnsignedInt Function(native_window_t)>(
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<native_rectangle_t Function(native_window_t)>()
external native_rectangle_t native_window_get_maximize_button_bounds(
int window,
Expand Down Expand Up @@ -4053,6 +4062,18 @@ external bool native_window_set_ignore_mouse_events(
@ffi.Native<ffi.Bool Function(native_window_t, native_window_shape_t)>()
external bool native_window_set_input_shape(int window, int shape);

@ffi.Native<ffi.Bool Function(native_window_t, ffi.UnsignedInt)>(
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<ffi.Void Function(native_window_t, ffi.Bool)>()
external void native_window_set_maximizable(int window, bool is_maximizable);

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<native_window_t> windows;
Expand Down
10 changes: 8 additions & 2 deletions bindings/dart/nativeapi/lib/src/screen_capturer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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),
);
Expand All @@ -106,6 +111,7 @@ class ScreenCaptureOptions {
ffi.Pointer<c.native_screen_capture_options_t> allocNative() {
final pointer = pkg_ffi.calloc<c.native_screen_capture_options_t>();
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;
Expand Down
8 changes: 6 additions & 2 deletions bindings/dart/nativeapi/lib/src/web/screen_capturer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions bindings/dart/nativeapi/lib/src/web/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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();
Expand Down
29 changes: 29 additions & 0 deletions bindings/dart/nativeapi/lib/src/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
}
Expand Down
Loading
Loading