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;
final RxBool _idInputFocused = false.obs;
final FocusNode _idFocusNode = FocusNode();
@override
void initState() {
super.initState();
@ -121,10 +124,8 @@ class _ConnectionPageState extends State<ConnectionPage>
/// 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<ConnectionPage>
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<ConnectionPage>
cursorColor:
Theme.of(context).textTheme.titleLarge?.color,
decoration: InputDecoration(
hintText: inputFocused.value
hintText: _idInputFocused.value
? null
: translate('Enter Remote ID'),
border: OutlineInputBorder(

View File

@ -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,
);
});
}

View File

@ -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<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(
BuildContext context, Widget child, Size layoutSize, Size size) {
final scrollConfig = CustomMouseWheelScrollConfig(

View File

@ -364,6 +364,10 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
}
Widget _buildKeyboard(BuildContext context) {
FfiModel ffiModel = Provider.of<FfiModel>(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<RemoteMenubar> {
));
}
}
if (gFFI.ffiModel.permissions["restart"] != false &&
if (perms["restart"] != false &&
(pi.platform == "Linux" ||
pi.platform == "Windows" ||
pi.platform == "Mac OS")) {

View File

@ -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+/iYmJY2NjAgICAAAA9PT0Ojo6AAAAAAAAAAAA+/v7SkpKhYWFr6+vAAAAAAAA8/PzOTk5ERER9fX1KCgoAAAAgYGBKioqAAAAAAAApqamlpaWAAAAAAAAAAAAAAAAAAAAAAAALi4u/v7+GRkZAAAAAAAAAAAAAAAAAAAAfn5+AAAAAAAAV1dXkJCQAAAAAAAAAQEBAAAAAAAAAAAA7Hz6BAAAAMJ0Uk5TAAIWEwEynNz6//fVkCAatP2fDUHs6cDD8d0mPfT5fiEskiIR584A0gejr3AZ+P4plfALf5ZiTL85a4ziD6697fzN3UYE4v/4TwrNHuT///tdRKZh///+1U/ZBv///yjb///eAVL//50Cocv//6oFBbPvpGZCbfT//7cIhv///8INM///zBEcWYSZmO7//////1P////ts/////8vBv//////gv//R/z///QQz9sevP///2waXhNO/+fc//8mev/5gAe2r90MAAAByUlEQVR4nGNggANGJmYWBpyAlY2dg5OTi5uHF6s0H78AJxRwCAphyguLgKRExcQlQLSkFLq8tAwnp6ycPNABjAqKQKNElVDllVU4OVVhVquJA81Q10BRoAkUUYbJa4Edoo0sr6PLqaePLG/AyWlohKTAmJPTBFnelAFoixmSAnNOTgsUeQZLTk4rJAXWnJw2EHlbiDyDPCenHZICe04HFrh+RydnBgYWPU5uJAWinJwucPNd3dw9GDw5Ob2QFHBzcnrD7ffx9fMPCOTkDEINhmC4+3x8Q0LDwlEDIoKTMzIKKg9SEBIdE8sZh6SAJZ6Tkx0qD1YQkpCYlIwclCng0AXLQxSEpKalZyCryATKZwkhKQjJzsnNQ1KQXwBUUVhUXBJYWgZREFJeUVmFpMKlWg+anmqgCkJq6+obkG1pLEBTENLU3NKKrIKhrb2js8u4G6Kgpze0r3/CRAZMAHbkpJDJU6ZMmTqtFbuC6TNmhsyaMnsOFlmwgrnzpsxfELJwEXZ5Bp/FS3yWLlsesmLlKuwKVk9Ys5Zh3foN0zduwq5g85atDAzbpqSGbN9RhV0FGOzctWH3lD14FOzdt3H/gQw8Cg4u2gQPAwBYDXXdIH+wqAAAAABJRU5ErkJggg==');
}
}
class QualityMonitorData {

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}