mirror of
https://git.hmsn.ink/flutter/vnc_viewer.git
synced 2026-03-20 00:02:22 +09:00
first
This commit is contained in:
129
lib/rfb/remote_frame_buffer_gesture_detector.dart
Normal file
129
lib/rfb/remote_frame_buffer_gesture_detector.dart
Normal file
@@ -0,0 +1,129 @@
|
||||
import 'dart:isolate';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/widgets.dart' hide Image;
|
||||
import 'remote_frame_buffer_isolate_messages.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
class RemoteFrameBufferGestureDetector extends GestureDetector {
|
||||
final Image _image;
|
||||
final Size _remoteFrameBufferWidgetSize;
|
||||
final Option<SendPort> _sendPort;
|
||||
final bool _isFullscreen;
|
||||
|
||||
RemoteFrameBufferGestureDetector({
|
||||
super.key,
|
||||
required final Image image,
|
||||
required final Size remoteFrameBufferWidgetSize,
|
||||
required final Option<SendPort> sendPort,
|
||||
required final bool isFullscreen,
|
||||
super.child,
|
||||
}) : _image = image,
|
||||
_remoteFrameBufferWidgetSize = remoteFrameBufferWidgetSize,
|
||||
_sendPort = sendPort,
|
||||
_isFullscreen = isFullscreen;
|
||||
|
||||
@override
|
||||
GestureTapDownCallback? get onSecondaryTapDown =>
|
||||
(final TapDownDetails details) => _sendPort.match(
|
||||
() {},
|
||||
(final SendPort sendPort) => sendPort.send(
|
||||
RemoteFrameBufferIsolateSendMessage.pointerEvent(
|
||||
button1Down: false,
|
||||
button2Down: false,
|
||||
button3Down: true,
|
||||
button4Down: false,
|
||||
button5Down: false,
|
||||
button6Down: false,
|
||||
button7Down: false,
|
||||
button8Down: false,
|
||||
x: _isFullscreen ? details.localPosition.dx.toInt() : (details.localPosition.dx /
|
||||
_remoteFrameBufferWidgetSize.width *
|
||||
_image.width)
|
||||
.toInt(),
|
||||
y: _isFullscreen ? details.localPosition.dy.toInt() : (details.localPosition.dy /
|
||||
_remoteFrameBufferWidgetSize.height *
|
||||
_image.height)
|
||||
.toInt(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
GestureTapUpCallback? get onSecondaryTapUp =>
|
||||
(final TapUpDetails details) => _sendPort.match(
|
||||
() {},
|
||||
(final SendPort sendPort) => sendPort.send(
|
||||
RemoteFrameBufferIsolateSendMessage.pointerEvent(
|
||||
button1Down: false,
|
||||
button2Down: false,
|
||||
button3Down: false,
|
||||
button4Down: false,
|
||||
button5Down: false,
|
||||
button6Down: false,
|
||||
button7Down: false,
|
||||
button8Down: false,
|
||||
x: _isFullscreen ? details.localPosition.dx.toInt() : (details.localPosition.dx /
|
||||
_remoteFrameBufferWidgetSize.width *
|
||||
_image.width)
|
||||
.toInt(),
|
||||
y: _isFullscreen ? details.localPosition.dy.toInt() : (details.localPosition.dy /
|
||||
_remoteFrameBufferWidgetSize.height *
|
||||
_image.height)
|
||||
.toInt(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
GestureTapDownCallback? get onTapDown =>
|
||||
(final TapDownDetails details) => _sendPort.match(
|
||||
() {},
|
||||
(final SendPort sendPort) => sendPort.send(
|
||||
RemoteFrameBufferIsolateSendMessage.pointerEvent(
|
||||
button1Down: true,
|
||||
button2Down: false,
|
||||
button3Down: false,
|
||||
button4Down: false,
|
||||
button5Down: false,
|
||||
button6Down: false,
|
||||
button7Down: false,
|
||||
button8Down: false,
|
||||
x: _isFullscreen ? details.localPosition.dx.toInt() : (details.localPosition.dx /
|
||||
_remoteFrameBufferWidgetSize.width *
|
||||
_image.width)
|
||||
.toInt(),
|
||||
y: _isFullscreen ? details.localPosition.dy.toInt() : (details.localPosition.dy /
|
||||
_remoteFrameBufferWidgetSize.height *
|
||||
_image.height)
|
||||
.toInt(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
GestureTapUpCallback? get onTapUp =>
|
||||
(final TapUpDetails details) => _sendPort.match(
|
||||
() {},
|
||||
(final SendPort sendPort) => sendPort.send(
|
||||
RemoteFrameBufferIsolateSendMessage.pointerEvent(
|
||||
button1Down: false,
|
||||
button2Down: false,
|
||||
button3Down: false,
|
||||
button4Down: false,
|
||||
button5Down: false,
|
||||
button6Down: false,
|
||||
button7Down: false,
|
||||
button8Down: false,
|
||||
x: _isFullscreen ? details.localPosition.dx.toInt() : (details.localPosition.dx /
|
||||
_remoteFrameBufferWidgetSize.width *
|
||||
_image.width)
|
||||
.toInt(),
|
||||
y: _isFullscreen ? details.localPosition.dy.toInt() : (details.localPosition.dy /
|
||||
_remoteFrameBufferWidgetSize.height *
|
||||
_image.height)
|
||||
.toInt(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user