From 52a21234d4f2bf95ce6a8de568c2d4338bda6471 Mon Sep 17 00:00:00 2001 From: 21pages Date: Sun, 16 Oct 2022 12:29:51 +0800 Subject: [PATCH 1/2] show disabled cursor on the control end Signed-off-by: 21pages --- flutter/lib/desktop/pages/remote_page.dart | 32 +++++++++++++++++++--- flutter/lib/models/model.dart | 11 +++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 3757d96e6..01229ab2b 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -280,10 +280,12 @@ class ImagePaint extends StatelessWidget { final s = c.scale; mouseRegion({child}) => Obx(() => MouseRegion( - cursor: (cursorOverImage.isTrue && keyboardEnabled.isTrue) - ? (remoteCursorMoved.isTrue - ? SystemMouseCursors.none - : _buildCustomCursorLinux(context, s)) + cursor: cursorOverImage.isTrue + ? keyboardEnabled.isTrue + ? (remoteCursorMoved.isTrue + ? SystemMouseCursors.none + : _buildCustomCursorLinux(context, s)) + : _buildDisabledCursor(context, s) : MouseCursor.defer, onHover: (evt) {}, child: child)); @@ -350,6 +352,28 @@ class ImagePaint extends StatelessWidget { } } + MouseCursor _buildDisabledCursor(BuildContext context, double scale) { + final cursor = Provider.of(context); + final cacheLinux = cursor.cacheLinux; + if (cacheLinux == null) { + return MouseCursor.defer; + } else { + if (cursor.cachedForbidmemoryCursorData == null) { + cursor.updateForbiddenCursorBuffer(); + } + final key = 'disabled_cursor_key'; + cursor.addKeyLinux(key); + return FlutterCustomMemoryImageCursor( + pixbuf: cursor.cachedForbidmemoryCursorData, + key: key, + hotx: cacheLinux.hotx, + hoty: cacheLinux.hoty, + imageWidth: 32, + imageHeight: 32, + ); + } + } + Widget _buildCrossScrollbarFromLayout( BuildContext context, Widget child, Size layoutSize, Size size) { final scrollConfig = CustomMouseWheelScrollConfig( diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 8b4d89461..1fd33bc77 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -79,7 +79,10 @@ class FfiModel with ChangeNotifier { if (k == 'name' || k.isEmpty) return; _permissions[k] = v == 'true'; }); - KeyboardEnabledState.find(id).value = _permissions['keyboard'] != false; + // Only inited at remote page + if (desktopType == DesktopType.remote) { + KeyboardEnabledState.find(id).value = _permissions['keyboard'] != false; + } debugPrint('$_permissions'); notifyListeners(); } @@ -938,6 +941,12 @@ class CursorModel with ChangeNotifier { customCursorController.freeCache(key); } } + + Uint8List? cachedForbidmemoryCursorData; + void updateForbiddenCursorBuffer() { + cachedForbidmemoryCursorData ??= base64Decode( + 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAkZQTFRFAAAA2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4GWAwCAAAAAAAA2B4GAAAAMTExAAAAAAAA2B4G2B4G2B4GAAAAmZmZkZGRAQEBAAAA2B4G2B4G2B4G////oKCgAwMDag8D2B4G2B4G2B4Gra2tBgYGbg8D2B4G2B4Gubm5CQkJTwsCVgwC2B4GxcXFDg4OAAAAAAAA2B4G2B4Gz8/PFBQUAAAAAAAA2B4G2B4G2B4G2B4G2B4G2B4G2B4GDgIA2NjYGxsbAAAAAAAA2B4GFwMB4eHhIyMjAAAAAAAA2B4G6OjoLCwsAAAAAAAA2B4G2B4G2B4G2B4G2B4GCQEA4ODgv7+/iYmJY2NjAgICAA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RU5ErkJggg=='); + } } class QualityMonitorData { From cba450b32f6d1048b713dd3d61305306763f64fe Mon Sep 17 00:00:00 2001 From: 21pages Date: Sun, 16 Oct 2022 12:32:52 +0800 Subject: [PATCH 2/2] fix id input focus problem Signed-off-by: 21pages --- flutter/lib/desktop/pages/connection_page.dart | 13 +++++++------ flutter/lib/desktop/pages/desktop_setting_page.dart | 8 +++++--- flutter/lib/desktop/widgets/remote_menubar.dart | 6 +++++- flutter/lib/models/server_model.dart | 3 +++ src/lang/cn.rs | 1 + src/lang/cs.rs | 1 + src/lang/da.rs | 1 + src/lang/de.rs | 1 + src/lang/eo.rs | 1 + src/lang/es.rs | 1 + src/lang/fr.rs | 1 + src/lang/hu.rs | 1 + src/lang/id.rs | 1 + src/lang/it.rs | 1 + src/lang/ja.rs | 1 + src/lang/ko.rs | 1 + src/lang/kz.rs | 1 + src/lang/pl.rs | 1 + src/lang/pt_PT.rs | 1 + src/lang/ptbr.rs | 1 + src/lang/ru.rs | 1 + src/lang/sk.rs | 1 + src/lang/template.rs | 1 + src/lang/tr.rs | 1 + src/lang/tw.rs | 1 + src/lang/ua.rs | 1 + src/lang/vn.rs | 1 + 27 files changed, 43 insertions(+), 10 deletions(-) diff --git a/flutter/lib/desktop/pages/connection_page.dart b/flutter/lib/desktop/pages/connection_page.dart index 9a606d122..2e7026071 100644 --- a/flutter/lib/desktop/pages/connection_page.dart +++ b/flutter/lib/desktop/pages/connection_page.dart @@ -36,6 +36,9 @@ class _ConnectionPageState extends State Timer? _updateTimer; + final RxBool _idInputFocused = false.obs; + final FocusNode _idFocusNode = FocusNode(); + @override void initState() { super.initState(); @@ -121,10 +124,8 @@ class _ConnectionPageState extends State /// UI for the remote ID TextField. /// Search for a peer and connect to it if the id exists. Widget _buildRemoteIDTextField(BuildContext context) { - RxBool inputFocused = false.obs; - FocusNode focusNode = FocusNode(); - focusNode.addListener(() { - inputFocused.value = focusNode.hasFocus; + _idFocusNode.addListener(() { + _idInputFocused.value = _idFocusNode.hasFocus; }); var w = Container( width: 320 + 20 * 2, @@ -155,7 +156,7 @@ class _ConnectionPageState extends State autocorrect: false, enableSuggestions: false, keyboardType: TextInputType.visiblePassword, - focusNode: focusNode, + focusNode: _idFocusNode, style: const TextStyle( fontFamily: 'WorkSans', fontSize: 22, @@ -165,7 +166,7 @@ class _ConnectionPageState extends State cursorColor: Theme.of(context).textTheme.titleLarge?.color, decoration: InputDecoration( - hintText: inputFocused.value + hintText: _idInputFocused.value ? null : translate('Enter Remote ID'), border: OutlineInputBorder( diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 55fd93bcc..0c4cc0aec 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -977,9 +977,11 @@ Widget _OptionCheckBox(BuildContext context, String label, String key, ], ), ).marginOnly(left: _kCheckBoxLeftMargin), - onTap: () { - onChanged(!ref.value); - }, + onTap: enabled + ? () { + onChanged(!ref.value); + } + : null, ); }); } diff --git a/flutter/lib/desktop/widgets/remote_menubar.dart b/flutter/lib/desktop/widgets/remote_menubar.dart index 13aa1932f..72cc56cad 100644 --- a/flutter/lib/desktop/widgets/remote_menubar.dart +++ b/flutter/lib/desktop/widgets/remote_menubar.dart @@ -364,6 +364,10 @@ class _RemoteMenubarState extends State { } Widget _buildKeyboard(BuildContext context) { + FfiModel ffiModel = Provider.of(context); + if (ffiModel.permissions['keyboard'] == false) { + return Offstage(); + } return mod_menu.PopupMenuButton( padding: EdgeInsets.zero, icon: const Icon( @@ -517,7 +521,7 @@ class _RemoteMenubarState extends State { )); } } - if (gFFI.ffiModel.permissions["restart"] != false && + if (perms["restart"] != false && (pi.platform == "Linux" || pi.platform == "Windows" || pi.platform == "Mac OS")) { diff --git a/flutter/lib/models/server_model.dart b/flutter/lib/models/server_model.dart index decb10e54..87ac9c8ea 100644 --- a/flutter/lib/models/server_model.dart +++ b/flutter/lib/models/server_model.dart @@ -556,6 +556,9 @@ class Client { data['keyboard'] = keyboard; data['clipboard'] = clipboard; data['audio'] = audio; + data['file'] = file; + data['restart'] = restart; + data['recording'] = recording; data['disconnected'] = disconnected; return data; } diff --git a/src/lang/cn.rs b/src/lang/cn.rs index 0d0b9e208..47b5f0bcb 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", "会话已结束"), ("Other", "其他"), ("Confirm before closing multiple tabs", "关闭多个标签页时向您确认"), + ("Keyboard Settings", "键盘设置"), ].iter().cloned().collect(); } diff --git a/src/lang/cs.rs b/src/lang/cs.rs index 9ca84a28b..2515f2231 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/da.rs b/src/lang/da.rs index 10cd64dd4..df1a06f6d 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", "Afbrudt"), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/de.rs b/src/lang/de.rs index f45a583f9..1b9973957 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/eo.rs b/src/lang/eo.rs index f243eb28a..3c6b3b771 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/es.rs b/src/lang/es.rs index 413cef26b..3826650af 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fr.rs b/src/lang/fr.rs index 79c93a4d9..4b76b8941 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/hu.rs b/src/lang/hu.rs index b4ddebc94..98e15397c 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/id.rs b/src/lang/id.rs index a751c11c0..437ec52cd 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/it.rs b/src/lang/it.rs index ae98a5690..6856eca60 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ja.rs b/src/lang/ja.rs index 46428d74c..77f47964a 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", "他の"), ("Confirm before closing multiple tabs", "同時に複数のタブを閉じる前に確認する"), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ko.rs b/src/lang/ko.rs index 3c857424e..4d0ff5f3e 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/kz.rs b/src/lang/kz.rs index f83b8b04b..602413ba9 100644 --- a/src/lang/kz.rs +++ b/src/lang/kz.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pl.rs b/src/lang/pl.rs index 9130d6b9a..dc6cdb750 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index 0fd796cb3..ff3d31b83 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index a20fdd557..0c0150e88 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ru.rs b/src/lang/ru.rs index c86d5cc31..4192f8490 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sk.rs b/src/lang/sk.rs index 8d4105118..819eee109 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/template.rs b/src/lang/template.rs index 02bfc95c0..c1d93b224 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tr.rs b/src/lang/tr.rs index e4ee58e23..7761c1ff3 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tw.rs b/src/lang/tw.rs index 5b0dc48aa..ab175cf11 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", "會話已結束"), ("Other", "其他"), ("Confirm before closing multiple tabs", "關閉多個分頁前跟我確認"), + ("Keyboard Settings", "鍵盤設置"), ].iter().cloned().collect(); } diff --git a/src/lang/ua.rs b/src/lang/ua.rs index 7d5037807..0399705b9 100644 --- a/src/lang/ua.rs +++ b/src/lang/ua.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); } diff --git a/src/lang/vn.rs b/src/lang/vn.rs index 4e441abff..db09d03a3 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Disconnected", ""), ("Other", ""), ("Confirm before closing multiple tabs", ""), + ("Keyboard Settings", ""), ].iter().cloned().collect(); }