fix notify peer resolution change
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
b8b3e99602
commit
59cd775d5f
@ -156,7 +156,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
} else if (name == 'clipboard') {
|
} else if (name == 'clipboard') {
|
||||||
Clipboard.setData(ClipboardData(text: evt['content']));
|
Clipboard.setData(ClipboardData(text: evt['content']));
|
||||||
} else if (name == 'permission') {
|
} else if (name == 'permission') {
|
||||||
parent.target?.ffiModel.updatePermission(evt, peerId);
|
updatePermission(evt, peerId);
|
||||||
} else if (name == 'chat_client_mode') {
|
} else if (name == 'chat_client_mode') {
|
||||||
parent.target?.chatModel
|
parent.target?.chatModel
|
||||||
.receive(ChatModel.clientModeID, evt['text'] ?? '');
|
.receive(ChatModel.clientModeID, evt['text'] ?? '');
|
||||||
@ -241,36 +241,33 @@ class FfiModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSwitchDisplay(Map<String, dynamic> evt, String peerId) {
|
_updateCurDisplay(String peerId, Display newDisplay) {
|
||||||
final oldOrientation = _display.width > _display.height;
|
if (newDisplay != _display) {
|
||||||
var old = _pi.currentDisplay;
|
if (newDisplay.x != _display.x || newDisplay.y != _display.y) {
|
||||||
_pi.currentDisplay = int.parse(evt['display']);
|
parent.target?.cursorModel
|
||||||
_display.x = double.parse(evt['x']);
|
.updateDisplayOrigin(newDisplay.x, newDisplay.y);
|
||||||
_display.y = double.parse(evt['y']);
|
}
|
||||||
_display.width = int.parse(evt['width']);
|
_display = newDisplay;
|
||||||
_display.height = int.parse(evt['height']);
|
_updateSessionWidthHeight(peerId);
|
||||||
_display.cursorEmbedded = int.parse(evt['cursor_embedded']) == 1;
|
}
|
||||||
if (old != _pi.currentDisplay) {
|
|
||||||
parent.target?.cursorModel.updateDisplayOrigin(_display.x, _display.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateSessionWidthHeight(peerId, display.width, display.height);
|
handleSwitchDisplay(Map<String, dynamic> evt, String peerId) {
|
||||||
|
_pi.currentDisplay = int.parse(evt['display']);
|
||||||
|
var newDisplay = Display();
|
||||||
|
newDisplay.x = double.parse(evt['x']);
|
||||||
|
newDisplay.y = double.parse(evt['y']);
|
||||||
|
newDisplay.width = int.parse(evt['width']);
|
||||||
|
newDisplay.height = int.parse(evt['height']);
|
||||||
|
newDisplay.cursorEmbedded = int.parse(evt['cursor_embedded']) == 1;
|
||||||
|
|
||||||
|
_updateCurDisplay(peerId, newDisplay);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CurrentDisplayState.find(peerId).value = _pi.currentDisplay;
|
CurrentDisplayState.find(peerId).value = _pi.currentDisplay;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
// remote is mobile, and orientation changed
|
|
||||||
if ((_display.width > _display.height) != oldOrientation) {
|
|
||||||
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();
|
||||||
handleResolutions(peerId, evt["resolutions"]);
|
handleResolutions(peerId, evt["resolutions"]);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -372,7 +369,8 @@ class FfiModel with ChangeNotifier {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateSessionWidthHeight(String id, int width, int height) {
|
_updateSessionWidthHeight(String id) {
|
||||||
|
parent.target?.canvasModel.updateViewStyle();
|
||||||
bind.sessionSetSize(id: id, width: display.width, height: display.height);
|
bind.sessionSetSize(id: id, width: display.width, height: display.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +427,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
stateGlobal.displaysCount.value = _pi.displays.length;
|
stateGlobal.displaysCount.value = _pi.displays.length;
|
||||||
if (_pi.currentDisplay < _pi.displays.length) {
|
if (_pi.currentDisplay < _pi.displays.length) {
|
||||||
_display = _pi.displays[_pi.currentDisplay];
|
_display = _pi.displays[_pi.currentDisplay];
|
||||||
_updateSessionWidthHeight(peerId, display.width, display.height);
|
_updateSessionWidthHeight(peerId);
|
||||||
}
|
}
|
||||||
if (displays.isNotEmpty) {
|
if (displays.isNotEmpty) {
|
||||||
parent.target?.dialogManager.showLoading(
|
parent.target?.dialogManager.showLoading(
|
||||||
@ -488,7 +486,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
_pi.displays = newDisplays;
|
_pi.displays = newDisplays;
|
||||||
stateGlobal.displaysCount.value = _pi.displays.length;
|
stateGlobal.displaysCount.value = _pi.displays.length;
|
||||||
if (_pi.currentDisplay >= 0 && _pi.currentDisplay < _pi.displays.length) {
|
if (_pi.currentDisplay >= 0 && _pi.currentDisplay < _pi.displays.length) {
|
||||||
_display = _pi.displays[_pi.currentDisplay];
|
_updateCurDisplay(peerId, _pi.displays[_pi.currentDisplay]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -797,12 +795,18 @@ class CanvasModel with ChangeNotifier {
|
|||||||
final dh = getDisplayHeight() * _scale;
|
final dh = getDisplayHeight() * _scale;
|
||||||
var dxOffset = 0;
|
var dxOffset = 0;
|
||||||
var dyOffset = 0;
|
var dyOffset = 0;
|
||||||
|
try {
|
||||||
if (dw > size.width) {
|
if (dw > size.width) {
|
||||||
dxOffset = (x - dw * (x / size.width) - _x).toInt();
|
dxOffset = (x - dw * (x / size.width) - _x).toInt();
|
||||||
}
|
}
|
||||||
if (dh > size.height) {
|
if (dh > size.height) {
|
||||||
dyOffset = (y - dh * (y / size.height) - _y).toInt();
|
dyOffset = (y - dh * (y / size.height) - _y).toInt();
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Unhandled Exception: Unsupported operation: Infinity or NaN toInt
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_x += dxOffset;
|
_x += dxOffset;
|
||||||
_y += dyOffset;
|
_y += dyOffset;
|
||||||
if (dxOffset != 0 || dyOffset != 0) {
|
if (dxOffset != 0 || dyOffset != 0) {
|
||||||
@ -1579,6 +1583,19 @@ class Display {
|
|||||||
? kDesktopDefaultDisplayHeight
|
? kDesktopDefaultDisplayHeight
|
||||||
: kMobileDefaultDisplayHeight;
|
: kMobileDefaultDisplayHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
other is Display &&
|
||||||
|
other.runtimeType == runtimeType &&
|
||||||
|
_innerEqual(other);
|
||||||
|
|
||||||
|
bool _innerEqual(Display other) =>
|
||||||
|
other.x == x &&
|
||||||
|
other.y == y &&
|
||||||
|
other.width == width &&
|
||||||
|
other.height == height &&
|
||||||
|
other.cursorEmbedded == cursorEmbedded;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Resolution {
|
class Resolution {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user