mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
multi flutter ui sessions, refact 'Show displays as individual windows'
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
@@ -2590,15 +2590,6 @@ String getDesktopTabLabel(String peerId, String alias) {
|
||||
return label;
|
||||
}
|
||||
|
||||
String getChooseDisplayBehavior() {
|
||||
var current = bind.mainGetOptionSync(key: kKeyChooseDisplayBehavior);
|
||||
if (![kChooseDisplayBehaviorSwitch, kChooseDisplayBehaviorOpen]
|
||||
.contains(current)) {
|
||||
current = kChooseDisplayBehaviorOpen;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
sessionRefreshVideo(SessionID sessionId, PeerInfo pi) async {
|
||||
if (pi.currentDisplay == kAllDisplayValue) {
|
||||
for (int i = 0; i < pi.displays.length; i++) {
|
||||
@@ -2609,5 +2600,7 @@ sessionRefreshVideo(SessionID sessionId, PeerInfo pi) async {
|
||||
}
|
||||
}
|
||||
|
||||
bool get isChooseDisplayToOpen =>
|
||||
getChooseDisplayBehavior() != kChooseDisplayBehaviorSwitch;
|
||||
bool isChooseDisplayToOpenInNewWindow(PeerInfo pi, SessionID sessionId) =>
|
||||
pi.isSupportMultiDisplay &&
|
||||
bind.sessionGetDisplaysAsIndividualWindows(sessionId: sessionId) == 'Y';
|
||||
|
||||
|
||||
@@ -515,5 +515,23 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
|
||||
},
|
||||
child: Text(translate('Swap control-command key'))));
|
||||
}
|
||||
|
||||
if (pi.isSupportMultiDisplay &&
|
||||
PrivacyModeState.find(id).isFalse &&
|
||||
pi.displaysCount.value > 1 &&
|
||||
bind.mainGetUserDefaultOption(key: kKeyShowMonitorsToolbar) == 'Y') {
|
||||
final value =
|
||||
bind.sessionGetDisplaysAsIndividualWindows(sessionId: ffi.sessionId) ==
|
||||
'Y';
|
||||
v.add(TToggleMenu(
|
||||
value: value,
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
bind.sessionSetDisplaysAsIndividualWindows(
|
||||
sessionId: sessionId, value: value ? 'Y' : '');
|
||||
},
|
||||
child: Text(translate('Show displays as individual windows'))));
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -66,9 +66,8 @@ const int kWindowMainId = 0;
|
||||
const String kPointerEventKindTouch = "touch";
|
||||
const String kPointerEventKindMouse = "mouse";
|
||||
|
||||
const String kKeyChooseDisplayBehavior = 'choose-display-behavior';
|
||||
const String kChooseDisplayBehaviorSwitch = 'switch';
|
||||
const String kChooseDisplayBehaviorOpen = 'open';
|
||||
const String kKeyShowDisplaysAsIndividualWindows = 'displays_as_individual_windows';
|
||||
const String kKeyShowMonitorsToolbar = 'show_monitors_toolbar';
|
||||
|
||||
// the executable name of the portable version
|
||||
const String kEnvPortableExecutable = "RUSTDESK_APPNAME";
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
|
||||
import 'package:flutter_hbb/desktop/pages/desktop_tab_page.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:flutter_hbb/models/desktop_render_texture.dart';
|
||||
import 'package:flutter_hbb/models/server_model.dart';
|
||||
import 'package:flutter_hbb/plugin/manager.dart';
|
||||
import 'package:flutter_hbb/plugin/widgets/desktop_settings.dart';
|
||||
@@ -1124,7 +1123,6 @@ class _DisplayState extends State<_Display> {
|
||||
controller: scrollController,
|
||||
physics: DraggableNeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
chooseDisplay(context),
|
||||
viewStyle(context),
|
||||
scrollStyle(context),
|
||||
imageQuality(context),
|
||||
@@ -1133,29 +1131,6 @@ class _DisplayState extends State<_Display> {
|
||||
]).marginOnly(bottom: _kListViewBottomMargin));
|
||||
}
|
||||
|
||||
Widget chooseDisplay(BuildContext context) {
|
||||
if (!useTextureRender) return const Offstage();
|
||||
|
||||
var current = getChooseDisplayBehavior();
|
||||
onChanged(String value) {
|
||||
bind.mainSetOption(key: kKeyChooseDisplayBehavior, value: value);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
return _Card(title: 'Choose display behavior', children: [
|
||||
_Radio<String>(context,
|
||||
value: kChooseDisplayBehaviorSwitch,
|
||||
groupValue: current,
|
||||
label: 'Switch display',
|
||||
onChanged: onChanged),
|
||||
_Radio<String>(context,
|
||||
value: kChooseDisplayBehaviorOpen,
|
||||
groupValue: current,
|
||||
label: 'Open in new window',
|
||||
onChanged: onChanged),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget viewStyle(BuildContext context) {
|
||||
final key = 'view_style';
|
||||
onChanged(String value) async {
|
||||
@@ -1314,7 +1289,7 @@ class _DisplayState extends State<_Display> {
|
||||
Widget other(BuildContext context) {
|
||||
return _Card(title: 'Other Default Options', children: [
|
||||
otherRow('View Mode', 'view_only'),
|
||||
otherRow('show_monitors_tip', 'show_monitors_toolbar'),
|
||||
otherRow('show_monitors_tip', kKeyShowMonitorsToolbar),
|
||||
otherRow('Collapse toolbar', 'collapse_toolbar'),
|
||||
otherRow('Show remote cursor', 'show_remote_cursor'),
|
||||
otherRow('Zoom cursor', 'zoom-cursor'),
|
||||
@@ -1325,6 +1300,8 @@ class _DisplayState extends State<_Display> {
|
||||
otherRow('Lock after session end', 'lock_after_session_end'),
|
||||
otherRow('Privacy mode', 'privacy_mode'),
|
||||
otherRow('Reverse mouse wheel', 'reverse_mouse_wheel'),
|
||||
otherRow('Show displays as individual windows',
|
||||
kKeyShowDisplaysAsIndividualWindows),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ class _MonitorMenu extends StatelessWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
bool get showMonitorsToolbar =>
|
||||
bind.mainGetUserDefaultOption(key: 'show_monitors_toolbar') == 'Y';
|
||||
bind.mainGetUserDefaultOption(key: kKeyShowMonitorsToolbar) == 'Y';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
@@ -614,13 +614,40 @@ class _MonitorMenu extends StatelessWidget {
|
||||
menuStyle: MenuStyle(
|
||||
padding:
|
||||
MaterialStatePropertyAll(EdgeInsets.symmetric(horizontal: 6))),
|
||||
menuChildren: [Row(children: buildMonitorList(false))]);
|
||||
menuChildren: [buildMonitorSubmenuWidget()]);
|
||||
}
|
||||
|
||||
Widget buildMultiMonitorMenu() {
|
||||
return Row(children: buildMonitorList(true));
|
||||
}
|
||||
|
||||
Widget buildMonitorSubmenuWidget() {
|
||||
final pi = ffi.ffiModel.pi;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(children: buildMonitorList(false)),
|
||||
pi.isSupportMultiDisplay ? Divider() : Offstage(),
|
||||
pi.isSupportMultiDisplay ? chooseDisplayBehavior() : Offstage(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget chooseDisplayBehavior() {
|
||||
final value =
|
||||
bind.sessionGetDisplaysAsIndividualWindows(sessionId: ffi.sessionId) ==
|
||||
'Y';
|
||||
return CkbMenuButton(
|
||||
value: value,
|
||||
onChanged: (value) async {
|
||||
if (value == null) return;
|
||||
await bind.sessionSetDisplaysAsIndividualWindows(
|
||||
sessionId: ffi.sessionId, value: value ? 'Y' : '');
|
||||
},
|
||||
ffi: ffi,
|
||||
child: Text(translate('Show displays as individual windows')));
|
||||
}
|
||||
|
||||
List<Widget> buildMonitorList(bool isMulti) {
|
||||
final List<Widget> monitorList = [];
|
||||
final pi = ffi.ffiModel.pi;
|
||||
@@ -746,7 +773,7 @@ class _MonitorMenu extends StatelessWidget {
|
||||
_menuDismissCallback(ffi);
|
||||
RxInt display = CurrentDisplayState.find(id);
|
||||
if (display.value != i) {
|
||||
if (pi.isSupportMultiDisplay) {
|
||||
if (isChooseDisplayToOpenInNewWindow(pi, ffi.sessionId)) {
|
||||
openMonitorInNewTabOrWindow(i, pi);
|
||||
} else {
|
||||
openMonitorInTheSameTab(i, pi);
|
||||
|
||||
@@ -430,7 +430,7 @@ class FfiModel with ChangeNotifier {
|
||||
final curDisplay = int.parse(evt['display']);
|
||||
|
||||
// The message should be handled by the another UI session.
|
||||
if (_pi.isSupportMultiDisplay) {
|
||||
if (isChooseDisplayToOpenInNewWindow(_pi, sessionId)) {
|
||||
if (curDisplay != _pi.currentDisplay) {
|
||||
return;
|
||||
}
|
||||
@@ -2211,8 +2211,7 @@ class PeerInfo with ChangeNotifier {
|
||||
bool get isWayland => platformDdditions['is_wayland'] == true;
|
||||
bool get isHeadless => platformDdditions['headless'] == true;
|
||||
|
||||
bool get isSupportMultiDisplay =>
|
||||
isDesktop && isSupportMultiUiSession && isChooseDisplayToOpen;
|
||||
bool get isSupportMultiDisplay => isDesktop && isSupportMultiUiSession;
|
||||
|
||||
bool get cursorEmbedded => tryGetDisplay()?.cursorEmbedded ?? false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user