Skip to content
Open
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
9 changes: 7 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ void main() async {
await windowManager.ensureInitialized();
bool isLowResolution = await Utils.isLowResolution();
WindowOptions windowOptions = WindowOptions(
size: isLowResolution ? const Size(840, 600) : const Size(1280, 860),
center: true,
skipTaskbar: false,
minimumSize: const Size(320, 270),
center: Platform.isWindows ? true : false,
size: Platform.isWindows
? isLowResolution
? const Size(840, 600)
: null
: null,
// macOS always hide title bar regardless of showWindowButton setting
titleBarStyle: (Platform.isMacOS || !showWindowButton)
? TitleBarStyle.hidden
Expand Down
10 changes: 7 additions & 3 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla
class Utils {
static final Random random = Random();

static Size? _previousWindowSize;

static bool? _isDocumentStartScriptSupported;

/// 检查 Android WebView 是否支持 DOCUMENT_START_SCRIPT 特性
Expand Down Expand Up @@ -495,16 +497,18 @@ class Utils {

// 进入桌面设备小窗模式
static Future<void> enterDesktopPIPWindow() async {
_previousWindowSize = await windowManager.getSize();
await windowManager.setAlwaysOnTop(true);
await windowManager.setAspectRatio(16 / 9);
await windowManager.setSize(const Size(480, 270));
}

// 退出桌面设备小窗模式
static Future<void> exitDesktopPIPWindow() async {
bool isLowResolution = await Utils.isLowResolution();
await windowManager.setAlwaysOnTop(false);
await windowManager.setSize(
isLowResolution ? const Size(800, 600) : const Size(1280, 860));
await windowManager.setSize(_previousWindowSize!);
_previousWindowSize = null;
await windowManager.setAspectRatio(0);
await windowManager.center();
}

Expand Down
2 changes: 1 addition & 1 deletion macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class AppDelegate: FlutterAppDelegate {
}

@objc func openWithAVPlayer () {
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1280, height: 860),
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1280, height: 720),
styleMask: [.titled, .closable, .resizable],
backing: .buffered, defer: false)
window.center()
Expand Down
Loading