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:
101
lib/rfb/remote_frame_buffer_mouse_detector.dart
Normal file
101
lib/rfb/remote_frame_buffer_mouse_detector.dart
Normal file
@@ -0,0 +1,101 @@
|
||||
import 'dart:isolate';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart' hide Image;
|
||||
import 'remote_frame_buffer_isolate_messages.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
class RemoteFrameBufferMouseDetector extends MouseRegion {
|
||||
final Image _image;
|
||||
final Size _remoteFrameBufferWidgetSize;
|
||||
final Option<SendPort> _sendPort;
|
||||
|
||||
RemoteFrameBufferMouseDetector({
|
||||
super.key,
|
||||
required final Image image,
|
||||
required final Size remoteFrameBufferWidgetSize,
|
||||
required final Option<SendPort> sendPort,
|
||||
super.child,
|
||||
}) : _image = image,
|
||||
_remoteFrameBufferWidgetSize = remoteFrameBufferWidgetSize,
|
||||
_sendPort = sendPort;
|
||||
|
||||
// @override
|
||||
// PointerHoverEventListener? get onHover =>
|
||||
// (final PointerEvent 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: (details.localPosition.dx /
|
||||
// _remoteFrameBufferWidgetSize.width *
|
||||
// _image.width)
|
||||
// .toInt(),
|
||||
// y: (details.localPosition.dy /
|
||||
// _remoteFrameBufferWidgetSize.height *
|
||||
// _image.height)
|
||||
// .toInt(),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
|
||||
@override
|
||||
PointerEnterEventListener? get onEnter =>
|
||||
(final PointerEnterEvent 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: (details.localPosition.dx /
|
||||
_remoteFrameBufferWidgetSize.width *
|
||||
_image.width)
|
||||
.toInt(),
|
||||
y: (details.localPosition.dy /
|
||||
_remoteFrameBufferWidgetSize.height *
|
||||
_image.height)
|
||||
.toInt(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
PointerExitEventListener? get onExit =>
|
||||
(final PointerExitEvent 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: (details.localPosition.dx /
|
||||
_remoteFrameBufferWidgetSize.width *
|
||||
_image.width)
|
||||
.toInt(),
|
||||
y: (details.localPosition.dy /
|
||||
_remoteFrameBufferWidgetSize.height *
|
||||
_image.height)
|
||||
.toInt(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user