Merge pull request #2617 from Kingtous/master
opt: allows handle key events by rdev with mouse moves to outside of window
This commit is contained in:
commit
370b8041d9
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -48,7 +49,7 @@ class RemotePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RemotePageState extends State<RemotePage>
|
class _RemotePageState extends State<RemotePage>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin, MultiWindowListener {
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
String keyboardMode = "legacy";
|
String keyboardMode = "legacy";
|
||||||
final _cursorOverImage = false.obs;
|
final _cursorOverImage = false.obs;
|
||||||
@ -57,7 +58,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
late RxBool _remoteCursorMoved;
|
late RxBool _remoteCursorMoved;
|
||||||
late RxBool _keyboardEnabled;
|
late RxBool _keyboardEnabled;
|
||||||
|
|
||||||
final FocusNode _rawKeyFocusNode = FocusNode();
|
final FocusNode _rawKeyFocusNode = FocusNode(debugLabel: "rawkeyFocusNode");
|
||||||
var _imageFocused = false;
|
var _imageFocused = false;
|
||||||
|
|
||||||
Function(bool)? _onEnterOrLeaveImage4Menubar;
|
Function(bool)? _onEnterOrLeaveImage4Menubar;
|
||||||
@ -111,6 +112,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
id: widget.id, arg: 'show-remote-cursor');
|
id: widget.id, arg: 'show-remote-cursor');
|
||||||
_zoomCursor.value =
|
_zoomCursor.value =
|
||||||
bind.sessionGetToggleOptionSync(id: widget.id, arg: 'zoom-cursor');
|
bind.sessionGetToggleOptionSync(id: widget.id, arg: 'zoom-cursor');
|
||||||
|
DesktopMultiWindow.addListener(this);
|
||||||
// if (!_isCustomCursorInited) {
|
// if (!_isCustomCursorInited) {
|
||||||
// customCursorController.registerNeedUpdateCursorCallback(
|
// customCursorController.registerNeedUpdateCursorCallback(
|
||||||
// (String? lastKey, String? currentKey) async {
|
// (String? lastKey, String? currentKey) async {
|
||||||
@ -124,9 +126,18 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onWindowBlur() {
|
||||||
|
super.onWindowBlur();
|
||||||
|
// unfocus the key focus when the whole window is lost focus,
|
||||||
|
// and let OS to handle events instead.
|
||||||
|
_rawKeyFocusNode.unfocus();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
debugPrint("REMOTE PAGE dispose ${widget.id}");
|
debugPrint("REMOTE PAGE dispose ${widget.id}");
|
||||||
|
DesktopMultiWindow.removeListener(this);
|
||||||
_ffi.dialogManager.hideMobileActionsOverlay();
|
_ffi.dialogManager.hideMobileActionsOverlay();
|
||||||
_ffi.recordingModel.onClose();
|
_ffi.recordingModel.onClose();
|
||||||
_rawKeyFocusNode.dispose();
|
_rawKeyFocusNode.dispose();
|
||||||
@ -157,6 +168,11 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
focusNode: _rawKeyFocusNode,
|
focusNode: _rawKeyFocusNode,
|
||||||
onFocusChange: (bool v) {
|
onFocusChange: (bool v) {
|
||||||
_imageFocused = v;
|
_imageFocused = v;
|
||||||
|
if (_imageFocused) {
|
||||||
|
_ffi.inputModel.enterOrLeave(true);
|
||||||
|
} else {
|
||||||
|
_ffi.inputModel.enterOrLeave(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
inputModel: _ffi.inputModel,
|
inputModel: _ffi.inputModel,
|
||||||
child: getBodyForDesktop(context)));
|
child: getBodyForDesktop(context)));
|
||||||
@ -195,7 +211,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ffi.inputModel.enterOrLeave(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void leaveView(PointerExitEvent evt) {
|
void leaveView(PointerExitEvent evt) {
|
||||||
@ -208,7 +223,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ffi.inputModel.enterOrLeave(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getBodyForDesktop(BuildContext context) {
|
Widget getBodyForDesktop(BuildContext context) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user