mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -126,9 +126,9 @@ class _RemotePageState extends State<RemotePage>
|
||||
// Register texture.
|
||||
_textureId.value = -1;
|
||||
textureRenderer.createTexture(_textureKey).then((id) async {
|
||||
debugPrint("id: $id, texture_key: $_textureKey");
|
||||
if (id != -1) {
|
||||
final ptr = await textureRenderer.getTexturePtr(_textureKey);
|
||||
debugPrint("id: $id, texture_key: $_textureKey");
|
||||
platformFFI.registerTexture(widget.id, ptr);
|
||||
_textureId.value = id;
|
||||
}
|
||||
@@ -197,6 +197,8 @@ class _RemotePageState extends State<RemotePage>
|
||||
@override
|
||||
void dispose() {
|
||||
debugPrint("REMOTE PAGE dispose ${widget.id}");
|
||||
platformFFI.registerTexture(widget.id, 0);
|
||||
textureRenderer.closeTexture(_textureKey);
|
||||
// ensure we leave this session, this is a double check
|
||||
bind.sessionEnterOrLeave(id: widget.id, enter: false);
|
||||
DesktopMultiWindow.removeListener(this);
|
||||
@@ -212,7 +214,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
Wakelock.disable();
|
||||
}
|
||||
Get.delete<FFI>(tag: widget.id);
|
||||
textureRenderer.closeTexture(_textureKey);
|
||||
super.dispose();
|
||||
_removeStates(widget.id);
|
||||
}
|
||||
@@ -484,15 +485,14 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
final imageWidth = c.getDisplayWidth() * s;
|
||||
final imageHeight = c.getDisplayHeight() * s;
|
||||
final imageSize = Size(imageWidth, imageHeight);
|
||||
print("width: $imageWidth/$imageHeight");
|
||||
// final imageWidget = CustomPaint(
|
||||
// size: imageSize,
|
||||
// painter: ImagePainter(image: m.image, x: 0, y: 0, scale: s),
|
||||
// );
|
||||
final imageWidget = SizedBox(
|
||||
width: imageHeight,
|
||||
width: imageWidth,
|
||||
height: imageHeight,
|
||||
child: Obx(() => Texture(textureId: widget.textureId.value)),
|
||||
child: Obx(() => Texture(textureId: widget.textureId.value)),
|
||||
);
|
||||
|
||||
return NotificationListener<ScrollNotification>(
|
||||
@@ -521,13 +521,22 @@ class _ImagePaintState extends State<ImagePaint> {
|
||||
// size: Size(c.size.width, c.size.height),
|
||||
// painter: ImagePainter(image: m.image, x: c.x / s, y: c.y / s, scale: s),
|
||||
// );
|
||||
final imageWidget = Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: c.size.width / c.size.height,
|
||||
child: Obx(() => Texture(textureId: widget.textureId.value)),
|
||||
),
|
||||
);
|
||||
return mouseRegion(child: _buildListener(imageWidget));
|
||||
if (c.size.width > 0 && c.size.height > 0) {
|
||||
final imageWidget = Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: c.x,
|
||||
top: c.y,
|
||||
width: c.getDisplayWidth() * s,
|
||||
height: c.getDisplayHeight() * s,
|
||||
child: Texture(textureId: widget.textureId.value),
|
||||
)
|
||||
],
|
||||
);
|
||||
return mouseRegion(child: _buildListener(imageWidget));
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,6 +252,8 @@ class FfiModel with ChangeNotifier {
|
||||
parent.target?.cursorModel.updateDisplayOrigin(_display.x, _display.y);
|
||||
}
|
||||
|
||||
_updateSessionWidthHeight(peerId, display.width, display.height);
|
||||
|
||||
try {
|
||||
CurrentDisplayState.find(peerId).value = _pi.currentDisplay;
|
||||
} catch (e) {
|
||||
@@ -367,6 +369,10 @@ class FfiModel with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
_updateSessionWidthHeight(String id, int width, int height) {
|
||||
bind.sessionSetSize(id: id, width: display.width, height: display.height);
|
||||
}
|
||||
|
||||
/// Handle the peer info event based on [evt].
|
||||
handlePeerInfo(Map<String, dynamic> evt, String peerId) async {
|
||||
// recent peer updated by handle_peer_info(ui_session_interface.rs) --> handle_peer_info(client.rs) --> save_config(client.rs)
|
||||
@@ -420,6 +426,7 @@ class FfiModel with ChangeNotifier {
|
||||
stateGlobal.displaysCount.value = _pi.displays.length;
|
||||
if (_pi.currentDisplay < _pi.displays.length) {
|
||||
_display = _pi.displays[_pi.currentDisplay];
|
||||
_updateSessionWidthHeight(peerId, display.width, display.height);
|
||||
}
|
||||
if (displays.isNotEmpty) {
|
||||
parent.target?.dialogManager.showLoading(
|
||||
@@ -485,19 +492,18 @@ class ImageModel with ChangeNotifier {
|
||||
|
||||
WeakReference<FFI> parent;
|
||||
|
||||
final List<Function(String)> _callbacksOnFirstImage = [];
|
||||
final List<Function(String)> callbacksOnFirstImage = [];
|
||||
|
||||
ImageModel(this.parent);
|
||||
|
||||
addCallbackOnFirstImage(Function(String) cb) =>
|
||||
_callbacksOnFirstImage.add(cb);
|
||||
addCallbackOnFirstImage(Function(String) cb) => callbacksOnFirstImage.add(cb);
|
||||
|
||||
onRgba(Uint8List rgba) {
|
||||
if (_waitForImage[id]!) {
|
||||
_waitForImage[id] = false;
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
if (isDesktop) {
|
||||
for (final cb in _callbacksOnFirstImage) {
|
||||
for (final cb in callbacksOnFirstImage) {
|
||||
cb(id);
|
||||
}
|
||||
}
|
||||
@@ -1445,16 +1451,27 @@ class FFI {
|
||||
debugPrint('json.decode fail1(): $e, ${message.field0}');
|
||||
}
|
||||
} else if (message is EventToUI_Rgba) {
|
||||
// Fetch the image buffer from rust codes.
|
||||
// final sz = platformFFI.getRgbaSize(id);
|
||||
// if (sz == null || sz == 0) {
|
||||
// return;
|
||||
// }
|
||||
// final rgba = platformFFI.getRgba(id, sz);
|
||||
// if (rgba != null) {
|
||||
// imageModel.onRgba(rgba);
|
||||
// }
|
||||
// imageModel.onRgba(rgba);
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
// Fetch the image buffer from rust codes.
|
||||
final sz = platformFFI.getRgbaSize(id);
|
||||
if (sz == null || sz == 0) {
|
||||
return;
|
||||
}
|
||||
final rgba = platformFFI.getRgba(id, sz);
|
||||
if (rgba != null) {
|
||||
imageModel.onRgba(rgba);
|
||||
}
|
||||
} else {
|
||||
if (_waitForImage[id]!) {
|
||||
_waitForImage[id] = false;
|
||||
dialogManager.dismissAll();
|
||||
for (final cb in imageModel.callbacksOnFirstImage) {
|
||||
cb(id);
|
||||
}
|
||||
await canvasModel.updateViewStyle();
|
||||
await canvasModel.updateScrollStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
debugPrint('Exit session event loop');
|
||||
|
||||
Reference in New Issue
Block a user