fix: multi-displays, displays changed, switch idx (#9006)

Use init display index as the primary index.

But when displays changed, the primary display may also changes.

No need to change the old primary index.
But we need to make sure that the old primary index does not exceed the display number.

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-08-09 21:17:06 +08:00 committed by GitHub
parent 6820e2f4c7
commit 3c6ddd7403
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1003,14 +1003,15 @@ class FfiModel with ChangeNotifier {
// Notify to switch display
msgBox(sessionId, 'custom-nook-nocancel-hasclose-info', 'Prompt',
'display_is_plugged_out_msg', '', parent.target!.dialogManager);
final newDisplay = pi.primaryDisplay == kInvalidDisplayIndex
? 0
: pi.primaryDisplay;
final displays = newDisplay;
final isPeerPrimaryDisplayValid =
pi.primaryDisplay == kInvalidDisplayIndex ||
pi.primaryDisplay >= pi.displays.length;
final newDisplay =
isPeerPrimaryDisplayValid ? 0 : pi.primaryDisplay;
bind.sessionSwitchDisplay(
isDesktop: isDesktop,
sessionId: sessionId,
value: Int32List.fromList([displays]),
value: Int32List.fromList([newDisplay]),
);
if (_pi.isSupportMultiUiSession) {