Refactor, optional parameter 'updateCursorPos'

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2023-12-02 22:01:05 +08:00
parent 3958090e0f
commit 570ce7d28d
4 changed files with 7 additions and 12 deletions

View File

@ -2698,7 +2698,7 @@ Future<List<Rect>> getScreenRectList() async {
: await getScreenListNotWayland(); : await getScreenListNotWayland();
} }
openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi, bool updateCursorPos) { openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi, {bool updateCursorPos = true}) {
final displays = i == kAllDisplayValue final displays = i == kAllDisplayValue
? List.generate(pi.displays.length, (index) => index) ? List.generate(pi.displays.length, (index) => index)
: [i]; : [i];
@ -2707,7 +2707,7 @@ openMonitorInTheSameTab(int i, FFI ffi, PeerInfo pi, bool updateCursorPos) {
sessionId: ffi.sessionId, sessionId: ffi.sessionId,
value: Int32List.fromList(displays), value: Int32List.fromList(displays),
); );
ffi.ffiModel.switchToNewDisplay(i, ffi.sessionId, ffi.id, updateCursorPos); ffi.ffiModel.switchToNewDisplay(i, ffi.sessionId, ffi.id, updateCursorPos: updateCursorPos);
} }
// Open new tab or window to show this monitor. // Open new tab or window to show this monitor.

View File

@ -820,8 +820,7 @@ class _MonitorMenu extends StatelessWidget {
if (isChooseDisplayToOpenInNewWindow(pi, ffi.sessionId)) { if (isChooseDisplayToOpenInNewWindow(pi, ffi.sessionId)) {
openMonitorInNewTabOrWindow(i, ffi.id, pi); openMonitorInNewTabOrWindow(i, ffi.id, pi);
} else { } else {
final updateCursorPos = !isMulti; openMonitorInTheSameTab(i, ffi, pi, updateCursorPos: !isMulti);
openMonitorInTheSameTab(i, ffi, pi, updateCursorPos);
} }
} }
} }

View File

@ -787,7 +787,7 @@ void showOptions(
children.add(InkWell( children.add(InkWell(
onTap: () { onTap: () {
if (i == cur) return; if (i == cur) return;
openMonitorInTheSameTab(i, gFFI, pi, true); openMonitorInTheSameTab(i, gFFI, pi);
gFFI.dialogManager.dismissAll(); gFFI.dialogManager.dismissAll();
}, },
child: Ink( child: Ink(

View File

@ -915,7 +915,7 @@ class FfiModel with ChangeNotifier {
if (_pi.isSupportMultiUiSession) { if (_pi.isSupportMultiUiSession) {
// If the peer supports multi-ui-session, no switch display message will be send back. // If the peer supports multi-ui-session, no switch display message will be send back.
// We need to update the display manually. // We need to update the display manually.
switchToNewDisplay(newDisplay, sessionId, peerId, true); switchToNewDisplay(newDisplay, sessionId, peerId);
} }
} else { } else {
msgBox(sessionId, 'nocancel-error', 'Prompt', 'No Displays', '', msgBox(sessionId, 'nocancel-error', 'Prompt', 'No Displays', '',
@ -955,12 +955,8 @@ class FfiModel with ChangeNotifier {
} }
// Directly switch to the new display without waiting for the response. // Directly switch to the new display without waiting for the response.
switchToNewDisplay( switchToNewDisplay(int display, SessionID sessionId, String peerId,
int display, {bool updateCursorPos = true}) {
SessionID sessionId,
String peerId,
bool updateCursorPos,
) {
// VideoHandler creation is upon when video frames are received, so either caching commands(don't know next width/height) or stopping recording when switching displays. // VideoHandler creation is upon when video frames are received, so either caching commands(don't know next width/height) or stopping recording when switching displays.
parent.target?.recordingModel.onClose(); parent.target?.recordingModel.onClose();
// no need to wait for the response // no need to wait for the response