Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Evelye authored Sep 14, 2024
2 parents c035c6a + d9ea717 commit b4ec0de
Show file tree
Hide file tree
Showing 23 changed files with 684 additions and 644 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flutter/lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3154,6 +3154,7 @@ class _ReconnectCountDownButtonState extends State<_ReconnectCountDownButton> {

importConfig(List<TextEditingController>? controllers, List<RxString>? errMsgs,
String? text) {
text = text?.trim();
if (text != null && text.isNotEmpty) {
try {
final sc = ServerConfig.decode(text);
Expand Down
12 changes: 10 additions & 2 deletions flutter/lib/common/widgets/custom_password.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class UppercaseValidationRule extends ValidationRule {
String get name => translate('uppercase');
@override
bool validate(String value) {
return value.contains(RegExp(r'[A-Z]'));
return value.runes.any((int rune) {
var character = String.fromCharCode(rune);
return character.toUpperCase() == character &&
character.toLowerCase() != character;
});
}
}

Expand All @@ -24,7 +28,11 @@ class LowercaseValidationRule extends ValidationRule {

@override
bool validate(String value) {
return value.contains(RegExp(r'[a-z]'));
return value.runes.any((int rune) {
var character = String.fromCharCode(rune);
return character.toLowerCase() == character &&
character.toUpperCase() != character;
});
}
}

Expand Down
38 changes: 33 additions & 5 deletions flutter/lib/common/widgets/peers_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class _PeersViewState extends State<_PeersView>
var _lastChangeTime = DateTime.now();
var _lastQueryPeers = <String>{};
var _lastQueryTime = DateTime.now();
var _lastWindowRestoreTime = DateTime.now();
var _queryCount = 0;
var _exit = false;
bool _isActive = true;
Expand Down Expand Up @@ -117,11 +118,37 @@ class _PeersViewState extends State<_PeersView>
@override
void onWindowFocus() {
_queryCount = 0;
_isActive = true;
}

@override
void onWindowMinimize() {
void onWindowBlur() {
// We need this comparison because window restore (on Windows) also triggers `onWindowBlur()`.
// Maybe it's a bug of the window manager, but the source code seems to be correct.
//
// Although `onWindowRestore()` is called after `onWindowBlur()` in my test,
// we need the following comparison to ensure that `_isActive` is true in the end.
if (isWindows && DateTime.now().difference(_lastWindowRestoreTime) <
const Duration(milliseconds: 300)) {
return;
}
_queryCount = _maxQueryCount;
_isActive = false;
}

@override
void onWindowRestore() {
// Window restore (on MacOS and Linux) also triggers `onWindowFocus()`.
// But on Windows, it triggers `onWindowBlur()`, mybe it's a bug of the window manager.
if (!isWindows) return;
_queryCount = 0;
_isActive = true;
_lastWindowRestoreTime = DateTime.now();
}

@override
void onWindowMinimize() {
// Window minimize also triggers `onWindowBlur()`.
}

// This function is required for mobile.
Expand Down Expand Up @@ -234,10 +261,11 @@ class _PeersViewState extends State<_PeersView>
physics: DraggableNeverScrollableScrollPhysics(),
itemCount: peers.length,
itemBuilder: (BuildContext context, int index) {
return buildOnePeer(peers[index], false).marginOnly(
right: space,
top: index == 0 ? 0 : space / 2,
bottom: space / 2);
return buildOnePeer(peers[index], false)
.marginOnly(
right: space,
top: index == 0 ? 0 : space / 2,
bottom: space / 2);
}),
)
: DesktopScrollWrapper(
Expand Down
6 changes: 4 additions & 2 deletions flutter/lib/desktop/pages/remote_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,10 @@ class _RemotePageState extends State<RemotePage>
super.dispose();
debugPrint("REMOTE PAGE dispose session $sessionId ${widget.id}");
_ffi.textureModel.onRemotePageDispose(closeSession);
// ensure we leave this session, this is a double check
_ffi.inputModel.enterOrLeave(false);
if (closeSession) {
// ensure we leave this session, this is a double check
_ffi.inputModel.enterOrLeave(false);
}
DesktopMultiWindow.removeListener(this);
_ffi.dialogManager.hideMobileActionsOverlay();
_ffi.imageModel.disposeImage();
Expand Down
4 changes: 3 additions & 1 deletion flutter/lib/desktop/widgets/remote_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,9 @@ class _KeyboardMenu extends StatelessWidget {
if (value == null) return;
await bind.sessionToggleOption(
sessionId: ffi.sessionId, value: kOptionToggleViewOnly);
ffiModel.setViewOnly(id, value);
final viewOnly = await bind.sessionGetToggleOption(
sessionId: ffi.sessionId, arg: kOptionToggleViewOnly);
ffiModel.setViewOnly(id, viewOnly ?? value);
}
: null,
ffi: ffi,
Expand Down
13 changes: 8 additions & 5 deletions flutter/lib/models/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,12 @@ class FfiModel with ChangeNotifier {
newDisplay.width = int.tryParse(evt['width']) ?? newDisplay.width;
newDisplay.height = int.tryParse(evt['height']) ?? newDisplay.height;
newDisplay.cursorEmbedded = int.tryParse(evt['cursor_embedded']) == 1;
newDisplay.originalWidth =
int.tryParse(evt['original_width']) ?? kInvalidResolutionValue;
newDisplay.originalHeight =
int.tryParse(evt['original_height']) ?? kInvalidResolutionValue;
newDisplay.originalWidth = int.tryParse(
evt['original_width'] ?? kInvalidResolutionValue.toString()) ??
kInvalidResolutionValue;
newDisplay.originalHeight = int.tryParse(
evt['original_height'] ?? kInvalidResolutionValue.toString()) ??
kInvalidResolutionValue;
newDisplay._scale = _pi.scaleOfDisplay(display);
_pi.displays[display] = newDisplay;

Expand Down Expand Up @@ -793,7 +795,7 @@ class FfiModel with ChangeNotifier {
isRefreshing = false;
}
Map<String, dynamic> features = json.decode(evt['features']);
_pi.features.privacyMode = features['privacy_mode'] == 1;
_pi.features.privacyMode = features['privacy_mode'] == true;
if (!isCache) {
handleResolutions(peerId, evt["resolutions"]);
}
Expand Down Expand Up @@ -2509,6 +2511,7 @@ class FFI {
onEvent2UIRgba();
imageModel.onRgba(display, data);
});
this.id = id;
return;
}

Expand Down
17 changes: 13 additions & 4 deletions flutter/lib/models/peer_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,33 @@ class Peers extends ChangeNotifier {
}

void _updateOnlineState(Map<String, dynamic> evt) {
int changedCount = 0;
evt['onlines'].split(',').forEach((online) {
for (var i = 0; i < peers.length; i++) {
if (peers[i].id == online) {
peers[i].online = true;
if (!peers[i].online) {
changedCount += 1;
peers[i].online = true;
}
}
}
});

evt['offlines'].split(',').forEach((offline) {
for (var i = 0; i < peers.length; i++) {
if (peers[i].id == offline) {
peers[i].online = false;
if (peers[i].online) {
changedCount += 1;
peers[i].online = false;
}
}
}
});

event = UpdateEvent.online;
notifyListeners();
if (changedCount > 0) {
event = UpdateEvent.online;
notifyListeners();
}
}

void _updatePeers(Map<String, dynamic> evt) {
Expand Down
16 changes: 9 additions & 7 deletions flutter/lib/web/bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ class RustdeskImpl {
required bool on,
dynamic hint}) {
return Future(() => js.context.callMethod('setByName', [
'option:toggle',
jsonEncode({implKey, on})
'toggle_privacy_mode',
jsonEncode({'impl_key': implKey, 'on': on})
]));
}

Expand Down Expand Up @@ -391,9 +391,9 @@ class RustdeskImpl {
return Future(() => js.context.callMethod('setByName', [
'switch_display',
jsonEncode({
isDesktop: isDesktop,
sessionId: sessionId.toString(),
value: value
'isDesktop': isDesktop,
'sessionId': sessionId.toString(),
'value': value
})
]));
}
Expand Down Expand Up @@ -1204,8 +1204,10 @@ class RustdeskImpl {
required int index,
required bool on,
dynamic hint}) {
// TODO
throw UnimplementedError();
return Future(() => js.context.callMethod('setByName', [
'toggle_virtual_display',
jsonEncode({'index': index, 'on': on})
]));
}

Future<void> mainSetHomeDir({required String home, dynamic hint}) {
Expand Down
Loading

0 comments on commit b4ec0de

Please sign in to comment.