From f2460c26ca9861c424bcb090892c9ab82013206e Mon Sep 17 00:00:00 2001 From: kingtous Date: Mon, 27 Jun 2022 09:25:20 +0800 Subject: [PATCH] feat: add specific keyboard hook --- flutter/lib/desktop/pages/remote_page.dart | 13 +++++++++++-- flutter/macos/Runner/bridge_generated.h | 3 +++ src/flutter_ffi.rs | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 9412e03c5..f0708f909 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -630,8 +630,17 @@ class _RemotePageState extends State id: widget.id, )); } - return Container( - color: MyTheme.canvasColor, child: Stack(children: paints)); + paints.add(getHelpTools()); + return MouseRegion( + onEnter: (evt) { + _ffi.bind.hostStopSystemKeyPropagate(stopped: false); + }, + onExit: (evt) { + _ffi.bind.hostStopSystemKeyPropagate(stopped: true); + }, + child: Container( + color: MyTheme.canvasColor, child: Stack(children: paints)), + ); } int lastMouseDownButtons = 0; diff --git a/flutter/macos/Runner/bridge_generated.h b/flutter/macos/Runner/bridge_generated.h index 6eb6cbd51..215e6249f 100644 --- a/flutter/macos/Runner/bridge_generated.h +++ b/flutter/macos/Runner/bridge_generated.h @@ -21,6 +21,8 @@ void wire_rustdesk_core_main(int64_t port_); void wire_start_global_event_stream(int64_t port_); +void wire_host_stop_system_key_propagate(int64_t port_, bool stopped); + void wire_session_connect(int64_t port_, struct wire_uint_8_list *id, bool is_file_transfer); void wire_get_session_remember(int64_t port_, struct wire_uint_8_list *id); @@ -170,6 +172,7 @@ static int64_t dummy_method_to_enforce_bundling(void) { int64_t dummy_var = 0; dummy_var ^= ((int64_t) (void*) wire_rustdesk_core_main); dummy_var ^= ((int64_t) (void*) wire_start_global_event_stream); + dummy_var ^= ((int64_t) (void*) wire_host_stop_system_key_propagate); dummy_var ^= ((int64_t) (void*) wire_session_connect); dummy_var ^= ((int64_t) (void*) wire_get_session_remember); dummy_var ^= ((int64_t) (void*) wire_get_session_toggle_option); diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 055e62721..34d432dbe 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -69,6 +69,11 @@ pub fn start_global_event_stream(s: StreamSink) -> ResultType<()> { Ok(()) } +pub fn host_stop_system_key_propagate(stopped: bool) { + #[cfg(windows)] + crate::platform::windows::stop_system_key_propagate(stopped); +} + pub fn session_connect( events2ui: StreamSink, id: String,