Opt: Change keyboard mode by ui
This commit is contained in:
parent
72d357e14b
commit
3d7377f9b6
@ -41,6 +41,7 @@ class _RemotePageState extends State<RemotePage>
|
||||
Timer? _timer;
|
||||
bool _showBar = !isWebDesktop;
|
||||
String _value = '';
|
||||
String keyboardMode = "legacy";
|
||||
final _cursorOverImage = false.obs;
|
||||
|
||||
final FocusNode _mobileFocusNode = FocusNode();
|
||||
@ -254,8 +255,11 @@ class _RemotePageState extends State<RemotePage>
|
||||
}
|
||||
|
||||
KeyEventResult handleRawKeyEvent(FocusNode data, RawKeyEvent e) {
|
||||
String? keyboardMode = Platform.environment['KEYBOARD_MODE'];
|
||||
keyboardMode ??= 'legacy';
|
||||
bind.sessionGetKeyboardName(id: widget.id).then((result) {
|
||||
setState(() {
|
||||
keyboardMode = result.toString();
|
||||
});
|
||||
});
|
||||
|
||||
if (keyboardMode == 'map') {
|
||||
mapKeyboardMode(e);
|
||||
@ -285,7 +289,6 @@ class _RemotePageState extends State<RemotePage>
|
||||
RawKeyEventDataLinux newData = e.data as RawKeyEventDataLinux;
|
||||
scanCode = newData.scanCode;
|
||||
keyCode = newData.keyCode;
|
||||
debugPrint(newData.unicodeScalarValues.toString());
|
||||
} else {
|
||||
scanCode = -1;
|
||||
keyCode = -1;
|
||||
@ -537,10 +540,8 @@ class _RemotePageState extends State<RemotePage>
|
||||
onPointerUp: _onPointUpImage,
|
||||
onPointerMove: _onPointMoveImage,
|
||||
onPointerSignal: _onPointerSignalImage,
|
||||
child: MouseRegion(
|
||||
onEnter: enterView,
|
||||
onExit: leaveView,
|
||||
child: child));
|
||||
child:
|
||||
MouseRegion(onEnter: enterView, onExit: leaveView, child: child));
|
||||
}
|
||||
|
||||
Widget getBodyForDesktop(BuildContext context, bool keyboard) {
|
||||
|
@ -93,6 +93,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
menubarItems.add(_buildMonitor(context));
|
||||
menubarItems.add(_buildControl(context));
|
||||
menubarItems.add(_buildDisplay(context));
|
||||
menubarItems.add(_buildKeyboard(context));
|
||||
if (!isWeb) {
|
||||
menubarItems.add(_buildChat(context));
|
||||
}
|
||||
@ -264,6 +265,29 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildKeyboard(BuildContext context) {
|
||||
return mod_menu.PopupMenuButton(
|
||||
padding: EdgeInsets.zero,
|
||||
icon: const Icon(
|
||||
Icons.keyboard,
|
||||
color: _MenubarTheme.commonColor,
|
||||
),
|
||||
tooltip: translate('Keyboard Settings'),
|
||||
position: mod_menu.PopupMenuPosition.under,
|
||||
onSelected: (String item) {},
|
||||
itemBuilder: (BuildContext context) => _getKeyboardMenu()
|
||||
.map((entry) => entry.build(
|
||||
context,
|
||||
const MenuConfig(
|
||||
commonColor: _MenubarTheme.commonColor,
|
||||
height: _MenubarTheme.height,
|
||||
dividerHeight: _MenubarTheme.dividerHeight,
|
||||
)))
|
||||
.expand((i) => i)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildClose(BuildContext context) {
|
||||
return IconButton(
|
||||
tooltip: translate('Close'),
|
||||
@ -555,6 +579,28 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
||||
return displayMenu;
|
||||
}
|
||||
|
||||
List<MenuEntryBase<String>> _getKeyboardMenu() {
|
||||
final keyboardMenu = [
|
||||
MenuEntryRadios<String>(
|
||||
text: translate('Ratio'),
|
||||
optionsGetter: () => [
|
||||
MenuEntryRadioOption(
|
||||
text: translate('Legacy mode'), value: 'legacy'),
|
||||
MenuEntryRadioOption(text: translate('Map mode'), value: 'map'),
|
||||
],
|
||||
curOptionGetter: () async {
|
||||
return await bind.sessionGetKeyboardName(id: widget.id) ?? 'legacy';
|
||||
},
|
||||
optionSetter: (String oldValue, String newValue) async {
|
||||
await bind.sessionSetKeyboardMode(
|
||||
id: widget.id, keyboardMode: newValue);
|
||||
widget.ffi.canvasModel.updateViewStyle();
|
||||
})
|
||||
];
|
||||
|
||||
return keyboardMenu;
|
||||
}
|
||||
|
||||
MenuEntrySwitch<String> _createSwitchMenuEntry(String text, String option) {
|
||||
return MenuEntrySwitch<String>(
|
||||
text: translate(text),
|
||||
|
@ -1003,6 +1003,10 @@ class FFI {
|
||||
downOrUp: down);
|
||||
}
|
||||
|
||||
Future<String> getKeyboardMode(){
|
||||
return bind.sessionGetKeyboardName(id: id);
|
||||
}
|
||||
|
||||
void enterOrLeave(bool enter) {
|
||||
bind.sessionEnterOrLeave(id: id, enter: enter);
|
||||
}
|
||||
|
@ -298,6 +298,19 @@ pub fn session_get_peer_option(id: String, name: String) -> String {
|
||||
"".to_string()
|
||||
}
|
||||
|
||||
pub fn session_get_keyboard_name(id: String) -> String {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
return session.get_keyboard_mode();
|
||||
}
|
||||
"legacy".to_string()
|
||||
}
|
||||
|
||||
pub fn session_set_keyboard_mode(id: String, keyboard_mode: String) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.save_keyboard_mode(keyboard_mode);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_input_os_password(id: String, value: String) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
|
||||
session.input_os_password(value, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user