fix, check session's keyboard mode on conn
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
69f643447d
commit
fcf3577f67
@ -11,6 +11,10 @@ const int kMainWindowId = 0;
|
|||||||
|
|
||||||
const kAllDisplayValue = -1;
|
const kAllDisplayValue = -1;
|
||||||
|
|
||||||
|
const kKeyLegacyMode = 'legacy';
|
||||||
|
const kKeyMapMode = 'map';
|
||||||
|
const kKeyTranslateMode = 'translate';
|
||||||
|
|
||||||
const String kPeerPlatformWindows = "Windows";
|
const String kPeerPlatformWindows = "Windows";
|
||||||
const String kPeerPlatformLinux = "Linux";
|
const String kPeerPlatformLinux = "Linux";
|
||||||
const String kPeerPlatformMacOS = "Mac OS";
|
const String kPeerPlatformMacOS = "Mac OS";
|
||||||
|
@ -26,10 +26,6 @@ import '../../common/shared_state.dart';
|
|||||||
import './popup_menu.dart';
|
import './popup_menu.dart';
|
||||||
import './kb_layout_type_chooser.dart';
|
import './kb_layout_type_chooser.dart';
|
||||||
|
|
||||||
const _kKeyLegacyMode = 'legacy';
|
|
||||||
const _kKeyMapMode = 'map';
|
|
||||||
const _kKeyTranslateMode = 'translate';
|
|
||||||
|
|
||||||
class ToolbarState {
|
class ToolbarState {
|
||||||
final kStoreKey = 'remoteMenubarState';
|
final kStoreKey = 'remoteMenubarState';
|
||||||
late RxBool show;
|
late RxBool show;
|
||||||
@ -1406,18 +1402,16 @@ class _KeyboardMenu extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var ffiModel = Provider.of<FfiModel>(context);
|
var ffiModel = Provider.of<FfiModel>(context);
|
||||||
if (!ffiModel.keyboard) return Offstage();
|
if (!ffiModel.keyboard) return Offstage();
|
||||||
|
// If use flutter to grab keys, we can only use one mode.
|
||||||
|
// Map mode and Legacy mode, at least one of them is supported.
|
||||||
String? modeOnly;
|
String? modeOnly;
|
||||||
if (stateGlobal.grabKeyboard) {
|
if (stateGlobal.grabKeyboard) {
|
||||||
if (bind.sessionIsKeyboardModeSupported(
|
if (bind.sessionIsKeyboardModeSupported(
|
||||||
sessionId: ffi.sessionId, mode: _kKeyMapMode)) {
|
sessionId: ffi.sessionId, mode: kKeyMapMode)) {
|
||||||
bind.sessionSetKeyboardMode(
|
modeOnly = kKeyMapMode;
|
||||||
sessionId: ffi.sessionId, value: _kKeyMapMode);
|
|
||||||
modeOnly = _kKeyMapMode;
|
|
||||||
} else if (bind.sessionIsKeyboardModeSupported(
|
} else if (bind.sessionIsKeyboardModeSupported(
|
||||||
sessionId: ffi.sessionId, mode: _kKeyLegacyMode)) {
|
sessionId: ffi.sessionId, mode: kKeyLegacyMode)) {
|
||||||
bind.sessionSetKeyboardMode(
|
modeOnly = kKeyLegacyMode;
|
||||||
sessionId: ffi.sessionId, value: _kKeyLegacyMode);
|
|
||||||
modeOnly = _kKeyLegacyMode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _IconSubmenuButton(
|
return _IconSubmenuButton(
|
||||||
@ -1439,13 +1433,13 @@ class _KeyboardMenu extends StatelessWidget {
|
|||||||
keyboardMode(String? modeOnly) {
|
keyboardMode(String? modeOnly) {
|
||||||
return futureBuilder(future: () async {
|
return futureBuilder(future: () async {
|
||||||
return await bind.sessionGetKeyboardMode(sessionId: ffi.sessionId) ??
|
return await bind.sessionGetKeyboardMode(sessionId: ffi.sessionId) ??
|
||||||
_kKeyLegacyMode;
|
kKeyLegacyMode;
|
||||||
}(), hasData: (data) {
|
}(), hasData: (data) {
|
||||||
final groupValue = data as String;
|
final groupValue = data as String;
|
||||||
List<InputModeMenu> modes = [
|
List<InputModeMenu> modes = [
|
||||||
InputModeMenu(key: _kKeyLegacyMode, menu: 'Legacy mode'),
|
InputModeMenu(key: kKeyLegacyMode, menu: 'Legacy mode'),
|
||||||
InputModeMenu(key: _kKeyMapMode, menu: 'Map mode'),
|
InputModeMenu(key: kKeyMapMode, menu: 'Map mode'),
|
||||||
InputModeMenu(key: _kKeyTranslateMode, menu: 'Translate mode'),
|
InputModeMenu(key: kKeyTranslateMode, menu: 'Translate mode'),
|
||||||
];
|
];
|
||||||
List<RdoMenuButton> list = [];
|
List<RdoMenuButton> list = [];
|
||||||
final enabled = !ffi.ffiModel.viewOnly;
|
final enabled = !ffi.ffiModel.viewOnly;
|
||||||
@ -1463,12 +1457,12 @@ class _KeyboardMenu extends StatelessWidget {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pi.isWayland && mode.key != _kKeyMapMode) {
|
if (pi.isWayland && mode.key != kKeyMapMode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = translate(mode.menu);
|
var text = translate(mode.menu);
|
||||||
if (mode.key == _kKeyTranslateMode) {
|
if (mode.key == kKeyTranslateMode) {
|
||||||
text = '$text beta';
|
text = '$text beta';
|
||||||
}
|
}
|
||||||
list.add(RdoMenuButton<String>(
|
list.add(RdoMenuButton<String>(
|
||||||
|
@ -703,6 +703,10 @@ class FfiModel with ChangeNotifier {
|
|||||||
_pi.isSet.value = true;
|
_pi.isSet.value = true;
|
||||||
stateGlobal.resetLastResolutionGroupValues(peerId);
|
stateGlobal.resetLastResolutionGroupValues(peerId);
|
||||||
|
|
||||||
|
if (isDesktop) {
|
||||||
|
checkDesktopKeyboardMode();
|
||||||
|
}
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
if (!isCache) {
|
if (!isCache) {
|
||||||
@ -710,6 +714,36 @@ class FfiModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkDesktopKeyboardMode() async {
|
||||||
|
final curMode = await bind.sessionGetKeyboardMode(sessionId: sessionId);
|
||||||
|
if (curMode != null) {
|
||||||
|
if (bind.sessionIsKeyboardModeSupported(
|
||||||
|
sessionId: sessionId, mode: curMode)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If current keyboard mode is not supported, change to another one.
|
||||||
|
|
||||||
|
if (stateGlobal.grabKeyboard) {
|
||||||
|
for (final mode in [kKeyMapMode, kKeyLegacyMode]) {
|
||||||
|
if (bind.sessionIsKeyboardModeSupported(
|
||||||
|
sessionId: sessionId, mode: mode)) {
|
||||||
|
bind.sessionSetKeyboardMode(sessionId: sessionId, value: mode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (final mode in [kKeyMapMode, kKeyTranslateMode, kKeyLegacyMode]) {
|
||||||
|
if (bind.sessionIsKeyboardModeSupported(
|
||||||
|
sessionId: sessionId, mode: mode)) {
|
||||||
|
bind.sessionSetKeyboardMode(sessionId: sessionId, value: mode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tryUseAllMyDisplaysForTheRemoteSession(String peerId) async {
|
tryUseAllMyDisplaysForTheRemoteSession(String peerId) async {
|
||||||
if (bind.sessionGetUseAllMyDisplaysForTheRemoteSession(
|
if (bind.sessionGetUseAllMyDisplaysForTheRemoteSession(
|
||||||
sessionId: sessionId) !=
|
sessionId: sessionId) !=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user