listen flutter key event when there's no input monitor permission
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
6157889bb0
commit
9dbd1f88f5
@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/models/state_model.dart';
|
|
||||||
|
|
||||||
import '../../common.dart';
|
|
||||||
import '../../models/input_model.dart';
|
import '../../models/input_model.dart';
|
||||||
|
|
||||||
class RawKeyFocusScope extends StatelessWidget {
|
class RawKeyFocusScope extends StatelessWidget {
|
||||||
@ -20,13 +18,6 @@ class RawKeyFocusScope extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final FocusOnKeyCallback? onKey;
|
|
||||||
if (isAndroid) {
|
|
||||||
onKey = inputModel.handleRawKeyEvent;
|
|
||||||
} else {
|
|
||||||
onKey = stateGlobal.grabKeyboard ? inputModel.handleRawKeyEvent : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FocusScope(
|
return FocusScope(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
child: Focus(
|
child: Focus(
|
||||||
@ -34,7 +25,7 @@ class RawKeyFocusScope extends StatelessWidget {
|
|||||||
canRequestFocus: true,
|
canRequestFocus: true,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
onFocusChange: onFocusChange,
|
onFocusChange: onFocusChange,
|
||||||
onKey: onKey,
|
onKey: inputModel.handleRawKeyEvent,
|
||||||
child: child));
|
child: child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ const String kAppTypeDesktopPortForward = "port forward";
|
|||||||
|
|
||||||
const String kWindowMainWindowOnTop = "main_window_on_top";
|
const String kWindowMainWindowOnTop = "main_window_on_top";
|
||||||
const String kWindowGetWindowInfo = "get_window_info";
|
const String kWindowGetWindowInfo = "get_window_info";
|
||||||
|
const String kWindowDisableGrabKeyboard = "disable_grab_keyboard";
|
||||||
const String kWindowActionRebuild = "rebuild";
|
const String kWindowActionRebuild = "rebuild";
|
||||||
const String kWindowEventHide = "hide";
|
const String kWindowEventHide = "hide";
|
||||||
const String kWindowEventShow = "show";
|
const String kWindowEventShow = "show";
|
||||||
|
@ -14,6 +14,7 @@ import 'package:flutter_hbb/desktop/pages/desktop_tab_page.dart';
|
|||||||
import 'package:flutter_hbb/desktop/widgets/scroll_wrapper.dart';
|
import 'package:flutter_hbb/desktop/widgets/scroll_wrapper.dart';
|
||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:flutter_hbb/models/server_model.dart';
|
import 'package:flutter_hbb/models/server_model.dart';
|
||||||
|
import 'package:flutter_hbb/models/state_model.dart';
|
||||||
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@ -498,6 +499,10 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
if (watchIsInputMonitoring) {
|
if (watchIsInputMonitoring) {
|
||||||
if (bind.mainIsCanInputMonitoring(prompt: false)) {
|
if (bind.mainIsCanInputMonitoring(prompt: false)) {
|
||||||
watchIsInputMonitoring = false;
|
watchIsInputMonitoring = false;
|
||||||
|
// Do not notify for now.
|
||||||
|
// Monitoring may not take effect until the process is restarted.
|
||||||
|
// rustDeskWinManager.call(
|
||||||
|
// WindowType.RemoteDesktop, kWindowDisableGrabKeyboard, '');
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,8 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
forceRelay: args['forceRelay'],
|
forceRelay: args['forceRelay'],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
} else if (call.method == kWindowDisableGrabKeyboard) {
|
||||||
|
stateGlobal.grabKeyboard = false;
|
||||||
} else if (call.method == "onDestroy") {
|
} else if (call.method == "onDestroy") {
|
||||||
tabController.clear();
|
tabController.clear();
|
||||||
} else if (call.method == kWindowActionRebuild) {
|
} else if (call.method == kWindowActionRebuild) {
|
||||||
|
@ -650,6 +650,12 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildKeyboard(BuildContext context) {
|
Widget _buildKeyboard(BuildContext context) {
|
||||||
|
// Do not support peer 1.1.9.
|
||||||
|
if (Platform.isMacOS && stateGlobal.grabKeyboard) {
|
||||||
|
bind.sessionSetKeyboardMode(id: widget.id, value: 'map');
|
||||||
|
return Offstage();
|
||||||
|
}
|
||||||
|
|
||||||
FfiModel ffiModel = Provider.of<FfiModel>(context);
|
FfiModel ffiModel = Provider.of<FfiModel>(context);
|
||||||
if (ffiModel.permissions['keyboard'] == false) {
|
if (ffiModel.permissions['keyboard'] == false) {
|
||||||
return Offstage();
|
return Offstage();
|
||||||
|
@ -58,6 +58,10 @@ class InputModel {
|
|||||||
InputModel(this.parent);
|
InputModel(this.parent);
|
||||||
|
|
||||||
KeyEventResult handleRawKeyEvent(FocusNode data, RawKeyEvent e) {
|
KeyEventResult handleRawKeyEvent(FocusNode data, RawKeyEvent e) {
|
||||||
|
if (!stateGlobal.grabKeyboard) {
|
||||||
|
return KeyEventResult.handled;
|
||||||
|
}
|
||||||
|
|
||||||
// * Currently mobile does not enable map mode
|
// * Currently mobile does not enable map mode
|
||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
bind.sessionGetKeyboardMode(id: id).then((result) {
|
bind.sessionGetKeyboardMode(id: id).then((result) {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
use crate::common::get_default_sound_input;
|
||||||
use crate::{
|
use crate::{
|
||||||
client::file_trait::FileManager,
|
client::file_trait::FileManager,
|
||||||
common::make_fd_to_json,
|
|
||||||
common::is_keyboard_mode_supported,
|
common::is_keyboard_mode_supported,
|
||||||
|
common::make_fd_to_json,
|
||||||
flutter::{self, SESSIONS},
|
flutter::{self, SESSIONS},
|
||||||
flutter::{session_add, session_start_},
|
flutter::{session_add, session_start_},
|
||||||
ui_interface::{self, *},
|
ui_interface::{self, *},
|
||||||
};
|
};
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
use crate::common::get_default_sound_input;
|
|
||||||
use flutter_rust_bridge::{StreamSink, SyncReturn};
|
use flutter_rust_bridge::{StreamSink, SyncReturn};
|
||||||
use hbb_common::{
|
use hbb_common::{
|
||||||
config::{self, LocalConfig, PeerConfig, ONLINE},
|
config::{self, LocalConfig, PeerConfig, ONLINE},
|
||||||
@ -1181,6 +1181,9 @@ pub fn main_start_grab_keyboard() -> SyncReturn<bool> {
|
|||||||
return SyncReturn(false);
|
return SyncReturn(false);
|
||||||
}
|
}
|
||||||
crate::keyboard::client::start_grab_loop();
|
crate::keyboard::client::start_grab_loop();
|
||||||
|
if !is_can_input_monitoring(false) {
|
||||||
|
return SyncReturn(false);
|
||||||
|
}
|
||||||
SyncReturn(true)
|
SyncReturn(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user