Merge pull request #1658 from fufesou/fix_linux_cursor_image

flutter_desktop: fix cursor image when cursor moved in from other window
This commit is contained in:
RustDesk 2022-10-04 14:52:58 +08:00 committed by GitHub
commit 46613397e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -1113,3 +1113,12 @@ Future<Map<String, String>> getHttpHeaders() async {
'Bearer ${await bind.mainGetLocalOption(key: 'access_token')}'
};
}
// Simple wrapper of built-in types for refrence use.
class SimpleWrapper<T> {
T t;
SimpleWrapper(this.t);
T get value => t;
set value(T t) => this.t = t;
}

View File

@ -20,6 +20,7 @@ import '../../models/platform_model.dart';
import '../../common/shared_state.dart';
bool _isCustomCursorInited = false;
final SimpleWrapper<bool> _firstEnterImage = SimpleWrapper(false);
class RemotePage extends StatefulWidget {
const RemotePage({
@ -102,6 +103,10 @@ class _RemotePageState extends State<RemotePage>
if (!_isCustomCursorInited) {
customCursorController.registerNeedUpdateCursorCallback(
(String? lastKey, String? currentKey) async {
if (_firstEnterImage.value) {
_firstEnterImage.value = false;
return true;
}
return lastKey == null || lastKey != currentKey;
});
_isCustomCursorInited = true;
@ -172,6 +177,7 @@ class _RemotePageState extends State<RemotePage>
_rawKeyFocusNode.requestFocus();
}
_cursorOverImage.value = true;
_firstEnterImage.value = true;
if (_onEnterOrLeaveImage4Menubar != null) {
try {
_onEnterOrLeaveImage4Menubar!(true);
@ -184,6 +190,7 @@ class _RemotePageState extends State<RemotePage>
void leaveView(PointerExitEvent evt) {
_cursorOverImage.value = false;
_firstEnterImage.value = false;
if (_onEnterOrLeaveImage4Menubar != null) {
try {
_onEnterOrLeaveImage4Menubar!(false);