From efaf63c57cee55ab967324e85657821b4f7cd734 Mon Sep 17 00:00:00 2001 From: fufesou Date: Tue, 28 Mar 2023 12:10:58 +0800 Subject: [PATCH] specify keyboard mode only Signed-off-by: fufesou --- .../lib/desktop/widgets/remote_toolbar.dart | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart index 25209912d..0ef8674ef 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart @@ -1638,12 +1638,15 @@ class _KeyboardMenu extends StatelessWidget { Widget build(BuildContext context) { var ffiModel = Provider.of(context); if (!ffiModel.keyboard) return Offstage(); + String? modeOnly; if (stateGlobal.grabKeyboard) { if (bind.sessionIsKeyboardModeSupported(id: id, mode: _kKeyMapMode)) { bind.sessionSetKeyboardMode(id: id, value: _kKeyMapMode); + modeOnly = _kKeyMapMode; } else if (bind.sessionIsKeyboardModeSupported( id: id, mode: _kKeyLegacyMode)) { bind.sessionSetKeyboardMode(id: id, value: _kKeyLegacyMode); + modeOnly = _kKeyLegacyMode; } } return _IconSubmenuButton( @@ -1653,14 +1656,14 @@ class _KeyboardMenu extends StatelessWidget { color: _MenubarTheme.blueColor, hoverColor: _MenubarTheme.hoverBlueColor, menuChildren: [ - mode(), + mode(modeOnly), localKeyboardType(), Divider(), view_mode(), ]); } - mode() { + mode(String? modeOnly) { return futureBuilder(future: () async { return await bind.sessionGetKeyboardMode(id: id) ?? _kKeyLegacyMode; }(), hasData: (data) { @@ -1678,22 +1681,28 @@ class _KeyboardMenu extends StatelessWidget { } for (KeyboardModeMenu mode in modes) { - if (bind.sessionIsKeyboardModeSupported(id: id, mode: mode.key)) { - if (pi.is_wayland && mode.key != _kKeyMapMode) { - continue; - } - var text = translate(mode.menu); - if (mode.key == _kKeyTranslateMode) { - text = '$text beta'; - } - list.add(_RadioMenuButton( - child: Text(text), - value: mode.key, - groupValue: groupValue, - onChanged: enabled ? onChanged : null, - ffi: ffi, - )); + if (modeOnly != null && mode.key != modeOnly) { + continue; + } else if (!bind.sessionIsKeyboardModeSupported( + id: id, mode: mode.key)) { + continue; } + + if (pi.is_wayland && mode.key != _kKeyMapMode) { + continue; + } + + var text = translate(mode.menu); + if (mode.key == _kKeyTranslateMode) { + text = '$text beta'; + } + list.add(_RadioMenuButton( + child: Text(text), + value: mode.key, + groupValue: groupValue, + onChanged: enabled ? onChanged : null, + ffi: ffi, + )); } return Column(children: list); });