set image center when remote resolution is changed

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-01-10 17:13:40 +08:00
parent c7fd38ed23
commit a3643f53bf
8 changed files with 34 additions and 22 deletions

View File

@ -977,10 +977,10 @@ Future<bool> matchPeer(String searchText, Peer peer) async {
/// Get the image for the current [platform]. /// Get the image for the current [platform].
Widget getPlatformImage(String platform, {double size = 50}) { Widget getPlatformImage(String platform, {double size = 50}) {
platform = platform.toLowerCase(); if (platform == kPeerPlatformMacOS) {
if (platform == 'mac os') {
platform = 'mac'; platform = 'mac';
} else if (platform != 'linux' && platform != 'android') { } else if (platform != kPeerPlatformLinux &&
platform != kPeerPlatformAndroid) {
platform = 'win'; platform = 'win';
} }
return SvgPicture.asset('assets/$platform.svg', height: size, width: size); return SvgPicture.asset('assets/$platform.svg', height: size, width: size);

View File

@ -5,6 +5,11 @@ import 'package:flutter_hbb/common.dart';
const double kDesktopRemoteTabBarHeight = 28.0; const double kDesktopRemoteTabBarHeight = 28.0;
const String kPeerPlatformWindows = "Windows";
const String kPeerPlatformLinux = "Linux";
const String kPeerPlatformMacOS = "Mac OS";
const String kPeerPlatformAndroid = "Android";
/// [kAppTypeMain] used by 'Desktop Main Page' , 'Mobile (Client and Server)' , 'Desktop CM Page', "Install Page" /// [kAppTypeMain] used by 'Desktop Main Page' , 'Mobile (Client and Server)' , 'Desktop CM Page', "Install Page"
const String kAppTypeMain = "main"; const String kAppTypeMain = "main";
const String kAppTypeDesktopRemote = "remote"; const String kAppTypeDesktopRemote = "remote";

View File

@ -308,7 +308,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
dismissOnClicked: true, dismissOnClicked: true,
)); ));
if (pi.platform == 'Linux' || pi.sasEnabled) { if (pi.platform == kPeerPlatformLinux || pi.sasEnabled) {
menu.add(MenuEntryButton<String>( menu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text( childBuilder: (TextStyle? style) => Text(
'${translate("Insert")} Ctrl + Alt + Del', '${translate("Insert")} Ctrl + Alt + Del',

View File

@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_hbb/models/platform_model.dart'; import 'package:flutter_hbb/models/platform_model.dart';
@ -170,14 +171,14 @@ RxString KBLayoutType = ''.obs;
String getLocalPlatformForKBLayoutType(String peerPlatform) { String getLocalPlatformForKBLayoutType(String peerPlatform) {
String localPlatform = ''; String localPlatform = '';
if (peerPlatform != 'Mac OS') { if (peerPlatform != kPeerPlatformMacOS) {
return localPlatform; return localPlatform;
} }
if (Platform.isWindows) { if (Platform.isWindows) {
localPlatform = 'Windows'; localPlatform = kPeerPlatformWindows;
} else if (Platform.isLinux) { } else if (Platform.isLinux) {
localPlatform = 'Linux'; localPlatform = kPeerPlatformLinux;
} }
// to-do: web desktop support ? // to-do: web desktop support ?
return localPlatform; return localPlatform;

View File

@ -589,7 +589,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
} }
displayMenu.add(MenuEntryDivider()); displayMenu.add(MenuEntryDivider());
if (perms['keyboard'] != false) { if (perms['keyboard'] != false) {
if (pi.platform == 'Linux' || pi.sasEnabled) { if (pi.platform == kPeerPlatformLinux || pi.sasEnabled) {
displayMenu.add(MenuEntryButton<String>( displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text( childBuilder: (TextStyle? style) => Text(
'${translate("Insert")} Ctrl + Alt + Del', '${translate("Insert")} Ctrl + Alt + Del',
@ -604,9 +604,9 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
} }
} }
if (perms['restart'] != false && if (perms['restart'] != false &&
(pi.platform == 'Linux' || (pi.platform == kPeerPlatformLinux ||
pi.platform == 'Windows' || pi.platform == kPeerPlatformWindows ||
pi.platform == 'Mac OS')) { pi.platform == kPeerPlatformMacOS)) {
displayMenu.add(MenuEntryButton<String>( displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text( childBuilder: (TextStyle? style) => Text(
translate('Restart Remote Device'), translate('Restart Remote Device'),
@ -633,7 +633,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
dismissOnClicked: true, dismissOnClicked: true,
)); ));
if (pi.platform == 'Windows') { if (pi.platform == kPeerPlatformWindows) {
displayMenu.add(MenuEntryButton<String>( displayMenu.add(MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Obx(() => Text( childBuilder: (TextStyle? style) => Obx(() => Text(
translate( translate(
@ -1157,7 +1157,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
} }
if (Platform.isWindows && if (Platform.isWindows &&
pi.platform == 'Windows' && pi.platform == kPeerPlatformWindows &&
perms['file'] != false) { perms['file'] != false) {
displayMenu.add(_createSwitchMenuEntry( displayMenu.add(_createSwitchMenuEntry(
'Allow file copy and paste', 'enable-file-transfer', padding, true)); 'Allow file copy and paste', 'enable-file-transfer', padding, true));

View File

@ -574,14 +574,14 @@ class _RemotePageState extends State<RemotePage> {
more.add(PopupMenuItem<String>( more.add(PopupMenuItem<String>(
child: Text(translate('Physical Keyboard Input Mode')), child: Text(translate('Physical Keyboard Input Mode')),
value: 'input-mode')); value: 'input-mode'));
if (pi.platform == 'Linux' || pi.sasEnabled) { if (pi.platform == kPeerPlatformLinux || pi.sasEnabled) {
more.add(PopupMenuItem<String>( more.add(PopupMenuItem<String>(
child: Text('${translate('Insert')} Ctrl + Alt + Del'), child: Text('${translate('Insert')} Ctrl + Alt + Del'),
value: 'cad')); value: 'cad'));
} }
more.add(PopupMenuItem<String>( more.add(PopupMenuItem<String>(
child: Text(translate('Insert Lock')), value: 'lock')); child: Text(translate('Insert Lock')), value: 'lock'));
if (pi.platform == 'Windows' && if (pi.platform == kPeerPlatformWindows &&
await bind.sessionGetToggleOption(id: id, arg: 'privacy-mode') != await bind.sessionGetToggleOption(id: id, arg: 'privacy-mode') !=
true) { true) {
more.add(PopupMenuItem<String>( more.add(PopupMenuItem<String>(
@ -591,9 +591,9 @@ class _RemotePageState extends State<RemotePage> {
} }
} }
if (perms["restart"] != false && if (perms["restart"] != false &&
(pi.platform == "Linux" || (pi.platform == kPeerPlatformLinux ||
pi.platform == "Windows" || pi.platform == kPeerPlatformWindows ||
pi.platform == "Mac OS")) { pi.platform == kPeerPlatformMacOS)) {
more.add(PopupMenuItem<String>( more.add(PopupMenuItem<String>(
child: Text(translate('Restart Remote Device')), value: 'restart')); child: Text(translate('Restart Remote Device')), value: 'restart'));
} }
@ -740,7 +740,7 @@ class _RemotePageState extends State<RemotePage> {
} }
final pi = gFFI.ffiModel.pi; final pi = gFFI.ffiModel.pi;
final isMac = pi.platform == "Mac OS"; final isMac = pi.platform == kPeerPlatformMacOS;
final modifiers = <Widget>[ final modifiers = <Widget>[
wrap('Ctrl ', () { wrap('Ctrl ', () {
setState(() => inputModel.ctrl = !inputModel.ctrl); setState(() => inputModel.ctrl = !inputModel.ctrl);
@ -995,7 +995,7 @@ void showOptions(
} }
more.add(getToggle( more.add(getToggle(
id, setState, 'lock-after-session-end', 'Lock after session end')); id, setState, 'lock-after-session-end', 'Lock after session end'));
if (pi.platform == 'Windows') { if (pi.platform == kPeerPlatformWindows) {
more.add(getToggle(id, setState, 'privacy-mode', 'Privacy mode')); more.add(getToggle(id, setState, 'privacy-mode', 'Privacy mode'));
} }
} }

View File

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
@ -347,7 +348,7 @@ class FileModel extends ChangeNotifier {
id: parent.target?.id ?? "", name: "remote_show_hidden")) id: parent.target?.id ?? "", name: "remote_show_hidden"))
.isNotEmpty; .isNotEmpty;
_remoteOption.isWindows = _remoteOption.isWindows =
parent.target?.ffiModel.pi.platform.toLowerCase() == "windows"; parent.target?.ffiModel.pi.platform == kPeerPlatformWindows;
await Future.delayed(Duration(milliseconds: 100)); await Future.delayed(Duration(milliseconds: 100));

View File

@ -61,7 +61,7 @@ class FfiModel with ChangeNotifier {
bool get touchMode => _touchMode; bool get touchMode => _touchMode;
bool get isPeerAndroid => _pi.platform == 'Android'; bool get isPeerAndroid => _pi.platform == kPeerPlatformAndroid;
set inputBlocked(v) { set inputBlocked(v) {
_inputBlocked = v; _inputBlocked = v;
@ -238,6 +238,11 @@ class FfiModel with ChangeNotifier {
if ((_display.width > _display.height) != oldOrientation) { if ((_display.width > _display.height) != oldOrientation) {
gFFI.canvasModel.updateViewStyle(); gFFI.canvasModel.updateViewStyle();
} }
if (_pi.platform == kPeerPlatformLinux ||
_pi.platform == kPeerPlatformWindows ||
_pi.platform == kPeerPlatformMacOS) {
parent.target?.canvasModel.updateViewStyle();
}
parent.target?.recordingModel.onSwitchDisplay(); parent.target?.recordingModel.onSwitchDisplay();
notifyListeners(); notifyListeners();
} }