Merge pull request #1733 from 21pages/disabled-cursor

Disabled cursor
This commit is contained in:
RustDesk 2022-10-17 12:06:32 +08:00 committed by GitHub
commit ede1ebd4de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 81 additions and 15 deletions

View File

@ -36,6 +36,9 @@ class _ConnectionPageState extends State<ConnectionPage>
Timer? _updateTimer; Timer? _updateTimer;
final RxBool _idInputFocused = false.obs;
final FocusNode _idFocusNode = FocusNode();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -121,10 +124,8 @@ class _ConnectionPageState extends State<ConnectionPage>
/// UI for the remote ID TextField. /// UI for the remote ID TextField.
/// Search for a peer and connect to it if the id exists. /// Search for a peer and connect to it if the id exists.
Widget _buildRemoteIDTextField(BuildContext context) { Widget _buildRemoteIDTextField(BuildContext context) {
RxBool inputFocused = false.obs; _idFocusNode.addListener(() {
FocusNode focusNode = FocusNode(); _idInputFocused.value = _idFocusNode.hasFocus;
focusNode.addListener(() {
inputFocused.value = focusNode.hasFocus;
}); });
var w = Container( var w = Container(
width: 320 + 20 * 2, width: 320 + 20 * 2,
@ -155,7 +156,7 @@ class _ConnectionPageState extends State<ConnectionPage>
autocorrect: false, autocorrect: false,
enableSuggestions: false, enableSuggestions: false,
keyboardType: TextInputType.visiblePassword, keyboardType: TextInputType.visiblePassword,
focusNode: focusNode, focusNode: _idFocusNode,
style: const TextStyle( style: const TextStyle(
fontFamily: 'WorkSans', fontFamily: 'WorkSans',
fontSize: 22, fontSize: 22,
@ -165,7 +166,7 @@ class _ConnectionPageState extends State<ConnectionPage>
cursorColor: cursorColor:
Theme.of(context).textTheme.titleLarge?.color, Theme.of(context).textTheme.titleLarge?.color,
decoration: InputDecoration( decoration: InputDecoration(
hintText: inputFocused.value hintText: _idInputFocused.value
? null ? null
: translate('Enter Remote ID'), : translate('Enter Remote ID'),
border: OutlineInputBorder( border: OutlineInputBorder(

View File

@ -977,9 +977,11 @@ Widget _OptionCheckBox(BuildContext context, String label, String key,
], ],
), ),
).marginOnly(left: _kCheckBoxLeftMargin), ).marginOnly(left: _kCheckBoxLeftMargin),
onTap: () { onTap: enabled
onChanged(!ref.value); ? () {
}, onChanged(!ref.value);
}
: null,
); );
}); });
} }

View File

@ -280,10 +280,12 @@ class ImagePaint extends StatelessWidget {
final s = c.scale; final s = c.scale;
mouseRegion({child}) => Obx(() => MouseRegion( mouseRegion({child}) => Obx(() => MouseRegion(
cursor: (cursorOverImage.isTrue && keyboardEnabled.isTrue) cursor: cursorOverImage.isTrue
? (remoteCursorMoved.isTrue ? keyboardEnabled.isTrue
? SystemMouseCursors.none ? (remoteCursorMoved.isTrue
: _buildCustomCursorLinux(context, s)) ? SystemMouseCursors.none
: _buildCustomCursorLinux(context, s))
: _buildDisabledCursor(context, s)
: MouseCursor.defer, : MouseCursor.defer,
onHover: (evt) {}, onHover: (evt) {},
child: child)); child: child));
@ -350,6 +352,28 @@ class ImagePaint extends StatelessWidget {
} }
} }
MouseCursor _buildDisabledCursor(BuildContext context, double scale) {
final cursor = Provider.of<CursorModel>(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( Widget _buildCrossScrollbarFromLayout(
BuildContext context, Widget child, Size layoutSize, Size size) { BuildContext context, Widget child, Size layoutSize, Size size) {
final scrollConfig = CustomMouseWheelScrollConfig( final scrollConfig = CustomMouseWheelScrollConfig(

View File

@ -364,6 +364,10 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
} }
Widget _buildKeyboard(BuildContext context) { Widget _buildKeyboard(BuildContext context) {
FfiModel ffiModel = Provider.of<FfiModel>(context);
if (ffiModel.permissions['keyboard'] == false) {
return Offstage();
}
return mod_menu.PopupMenuButton( return mod_menu.PopupMenuButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
icon: const Icon( icon: const Icon(
@ -517,7 +521,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
)); ));
} }
} }
if (gFFI.ffiModel.permissions["restart"] != false && if (perms["restart"] != false &&
(pi.platform == "Linux" || (pi.platform == "Linux" ||
pi.platform == "Windows" || pi.platform == "Windows" ||
pi.platform == "Mac OS")) { pi.platform == "Mac OS")) {

View File

@ -79,7 +79,10 @@ class FfiModel with ChangeNotifier {
if (k == 'name' || k.isEmpty) return; if (k == 'name' || k.isEmpty) return;
_permissions[k] = v == 'true'; _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'); debugPrint('$_permissions');
notifyListeners(); notifyListeners();
} }
@ -938,6 +941,12 @@ class CursorModel with ChangeNotifier {
customCursorController.freeCache(key); customCursorController.freeCache(key);
} }
} }
Uint8List? cachedForbidmemoryCursorData;
void updateForbiddenCursorBuffer() {
cachedForbidmemoryCursorData ??= base64Decode(
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAkZQTFRFAAAA2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G2B4G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zIKKg9SEBIdE8sZh6SAJZ6Tkx0qD1YQkpCYlIwclCng0AXLQxSEpKalZyCryATKZwkhKQjJzsnNQ1KQXwBUUVhUXBJYWgZREFJeUVmFpMKlWg+anmqgCkJq6+obkG1pLEBTENLU3NKKrIKhrb2js8u4G6Kgpze0r3/CRAZMAHbkpJDJU6ZMmTqtFbuC6TNmhsyaMnsOFlmwgrnzpsxfELJwEXZ5Bp/FS3yWLlsesmLlKuwKVk9Ys5Zh3foN0zduwq5g85atDAzbpqSGbN9RhV0FGOzctWH3lD14FOzdt3H/gQw8Cg4u2gQPAwBYDXXdIH+wqAAAAABJRU5ErkJggg==');
}
} }
class QualityMonitorData { class QualityMonitorData {

View File

@ -556,6 +556,9 @@ class Client {
data['keyboard'] = keyboard; data['keyboard'] = keyboard;
data['clipboard'] = clipboard; data['clipboard'] = clipboard;
data['audio'] = audio; data['audio'] = audio;
data['file'] = file;
data['restart'] = restart;
data['recording'] = recording;
data['disconnected'] = disconnected; data['disconnected'] = disconnected;
return data; return data;
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", "会话已结束"), ("Disconnected", "会话已结束"),
("Other", "其他"), ("Other", "其他"),
("Confirm before closing multiple tabs", "关闭多个标签页时向您确认"), ("Confirm before closing multiple tabs", "关闭多个标签页时向您确认"),
("Keyboard Settings", "键盘设置"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", "Afbrudt"), ("Disconnected", "Afbrudt"),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", "他の"), ("Other", "他の"),
("Confirm before closing multiple tabs", "同時に複数のタブを閉じる前に確認する"), ("Confirm before closing multiple tabs", "同時に複数のタブを閉じる前に確認する"),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", "會話已結束"), ("Disconnected", "會話已結束"),
("Other", "其他"), ("Other", "其他"),
("Confirm before closing multiple tabs", "關閉多個分頁前跟我確認"), ("Confirm before closing multiple tabs", "關閉多個分頁前跟我確認"),
("Keyboard Settings", "鍵盤設置"),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }

View File

@ -373,5 +373,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Disconnected", ""), ("Disconnected", ""),
("Other", ""), ("Other", ""),
("Confirm before closing multiple tabs", ""), ("Confirm before closing multiple tabs", ""),
("Keyboard Settings", ""),
].iter().cloned().collect(); ].iter().cloned().collect();
} }