mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
opt: ui & cursor
- opt: win7 frameless - opt: disable cursor output & macos free cache - opt: main window, set location before show/hide
This commit is contained in:
parent
da88d5c0b8
commit
8a4f8e202d
@ -6,7 +6,7 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -42,6 +42,8 @@ var isWeb = false;
|
||||
var isWebDesktop = false;
|
||||
var version = "";
|
||||
int androidVersion = 0;
|
||||
/// only avaliable for Windows target
|
||||
int windowsBuildNumber = 0;
|
||||
DesktopType? desktopType;
|
||||
|
||||
/// * debug or test only, DO NOT enable in release build
|
||||
@ -1410,3 +1412,25 @@ Timer periodic_immediate(Duration duration, Future<void> Function() callback) {
|
||||
await callback();
|
||||
});
|
||||
}
|
||||
/// return a human readable windows version
|
||||
WindowsTarget getWindowsTarget(int buildNumber) {
|
||||
if (!Platform.isWindows) {
|
||||
return WindowsTarget.naw;
|
||||
}
|
||||
if (buildNumber >= 22000) {
|
||||
return WindowsTarget.w11;
|
||||
} else if (buildNumber >= 10240) {
|
||||
return WindowsTarget.w10;
|
||||
} else if (buildNumber >= 9600) {
|
||||
return WindowsTarget.w8_1;
|
||||
} else if (buildNumber >= 9200) {
|
||||
return WindowsTarget.w8;
|
||||
} else if (buildNumber >= 7601) {
|
||||
return WindowsTarget.w7;
|
||||
} else if (buildNumber >= 6002) {
|
||||
return WindowsTarget.vista;
|
||||
} else {
|
||||
// minimum support
|
||||
return WindowsTarget.xp;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
|
||||
const double kDesktopRemoteTabBarHeight = 28.0;
|
||||
|
||||
/// [kAppTypeMain] used by 'Desktop Main Page' , 'Mobile (Client and Server)' , 'Desktop CM Page', "Install Page"
|
||||
@ -324,3 +326,20 @@ const Map<int, String> physicalKeyMap = <int, String>{
|
||||
0x000c019e: 'LOCK_SCREEN',
|
||||
0x000c0208: 'VK_PRINT',
|
||||
};
|
||||
|
||||
/// The windows targets in the publish time order.
|
||||
enum WindowsTarget {
|
||||
naw, // not a windows target
|
||||
xp,
|
||||
vista,
|
||||
w7,
|
||||
w8,
|
||||
w8_1,
|
||||
w10,
|
||||
w11
|
||||
}
|
||||
|
||||
/// A convenient method to transform a build number to the corresponding windows version.
|
||||
extension WindowsTargetExt on int {
|
||||
WindowsTarget get windowsVersion => getWindowsTarget(this);
|
||||
}
|
||||
|
@ -496,16 +496,6 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
// initTray();
|
||||
trayManager.addListener(this);
|
||||
rustDeskWinManager.registerActiveWindowListener(onActiveWindowChanged);
|
||||
// main window may be hidden because of the initial uni link or arguments.
|
||||
// note that we must wrap this active window registration in future because
|
||||
// we must ensure the execution is after `windowManager.hide/show()`.
|
||||
Future.delayed(Duration.zero, () {
|
||||
windowManager.isVisible().then((visibility) {
|
||||
if (visibility) {
|
||||
rustDeskWinManager.registerActiveWindow(kWindowMainId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
debugPrint(
|
||||
|
@ -118,17 +118,20 @@ void runMainApp(bool startService) async {
|
||||
gFFI.serverModel.startService();
|
||||
}
|
||||
runApp(App());
|
||||
// restore the location of the main window before window hide or show
|
||||
await restoreWindowPosition(WindowType.Main);
|
||||
// check the startup argument, if we successfully handle the argument, we keep the main window hidden.
|
||||
if (checkArguments()) {
|
||||
windowManager.hide();
|
||||
} else {
|
||||
windowManager.show();
|
||||
windowManager.focus();
|
||||
// move registration of active main window here to prevent async visible check.
|
||||
rustDeskWinManager.registerActiveWindow(kWindowMainId);
|
||||
}
|
||||
// set window option
|
||||
WindowOptions windowOptions = getHiddenTitleBarWindowOptions();
|
||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
restoreWindowPosition(WindowType.Main);
|
||||
windowManager.setOpacity(1);
|
||||
});
|
||||
}
|
||||
@ -173,6 +176,11 @@ void runMultiWindow(
|
||||
widget,
|
||||
MyTheme.currentThemeMode(),
|
||||
);
|
||||
// we do not hide titlebar on win7 because of the frame overflow.
|
||||
if (Platform.isWindows &&
|
||||
const [WindowsTarget.w7].contains(windowsBuildNumber.windowsVersion)) {
|
||||
WindowController.fromWindowId(windowId!).showTitleBar(true);
|
||||
}
|
||||
switch (appType) {
|
||||
case kAppTypeDesktopRemote:
|
||||
await restoreWindowPosition(WindowType.RemoteDesktop,
|
||||
@ -273,12 +281,18 @@ void runInstallPage() async {
|
||||
}
|
||||
|
||||
WindowOptions getHiddenTitleBarWindowOptions({Size? size}) {
|
||||
var defaultTitleBarStyle = TitleBarStyle.hidden;
|
||||
// we do not hide titlebar on win7 because of the frame overflow.
|
||||
if (Platform.isWindows &&
|
||||
const [WindowsTarget.w7].contains(windowsBuildNumber.windowsVersion)) {
|
||||
defaultTitleBarStyle = TitleBarStyle.normal;
|
||||
}
|
||||
return WindowOptions(
|
||||
size: size,
|
||||
center: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
skipTaskbar: false,
|
||||
titleBarStyle: TitleBarStyle.hidden,
|
||||
titleBarStyle: defaultTitleBarStyle,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,7 @@ class PlatformFFI {
|
||||
WindowsDeviceInfo winInfo = await deviceInfo.windowsInfo;
|
||||
name = winInfo.computerName;
|
||||
id = winInfo.computerName;
|
||||
windowsBuildNumber = winInfo.buildNumber;
|
||||
} catch (e) {
|
||||
debugPrint("$e");
|
||||
name = "unknown";
|
||||
|
@ -202,9 +202,8 @@ class RustDeskMultiWindowManager {
|
||||
// ignore
|
||||
} else {
|
||||
_activeWindows.add(windowId);
|
||||
_notifyActiveWindow();
|
||||
}
|
||||
|
||||
_notifyActiveWindow();
|
||||
}
|
||||
|
||||
/// Remove active window which has [`windowId`]
|
||||
@ -218,8 +217,8 @@ class RustDeskMultiWindowManager {
|
||||
// ignore
|
||||
} else {
|
||||
_activeWindows.remove(windowId);
|
||||
_notifyActiveWindow();
|
||||
}
|
||||
_notifyActiveWindow();
|
||||
}
|
||||
|
||||
void registerActiveWindowListener(VoidCallback callback) {
|
||||
|
@ -36,7 +36,7 @@ dependencies:
|
||||
provider: ^6.0.3
|
||||
tuple: ^2.0.0
|
||||
wakelock: ^0.6.2
|
||||
device_info_plus: ^4.1.2
|
||||
device_info_plus: ^8.0.0
|
||||
#firebase_analytics: ^9.1.5
|
||||
package_info_plus: ^1.4.2
|
||||
url_launcher: ^6.0.9
|
||||
@ -72,7 +72,7 @@ dependencies:
|
||||
flutter_custom_cursor:
|
||||
git:
|
||||
url: https://github.com/Kingtous/rustdesk_flutter_custom_cursor
|
||||
ref: bfb19c84a8244771488bc05cc5f9c9b5e0324cfd
|
||||
ref: 74b1b314142b6775c1243067a3503ac568ebc74b
|
||||
window_size:
|
||||
git:
|
||||
url: https://github.com/google/flutter-desktop-embedding.git
|
||||
|
Loading…
Reference in New Issue
Block a user