From 630014b2ee3caa981ddc4e054bb993c5bf19f460 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Wed, 4 Sep 2024 12:14:55 +0200 Subject: [PATCH] #1136 Windows: Fix special handling of SPACE and text field handling --- .../infrastructure/plugin/backbone_shell.rs | 33 ++++++++++--------- .../src/infrastructure/ui/app/app_instance.rs | 8 ++--- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/main/src/infrastructure/plugin/backbone_shell.rs b/main/src/infrastructure/plugin/backbone_shell.rs index 17241d1d2..c4ebe9c64 100644 --- a/main/src/infrastructure/plugin/backbone_shell.rs +++ b/main/src/infrastructure/plugin/backbone_shell.rs @@ -152,10 +152,10 @@ static APP_LIBRARY: std::sync::OnceLock; +RealearnAccelerator; pub type RealearnControlSurface = - MiddlewareControlSurface>; +MiddlewareControlSurface>; /// Just the old term as alias for easier class search. type _App = BackboneShell; @@ -923,7 +923,7 @@ impl BackboneShell { #[allow(dead_code)] pub fn spawn_in_async_runtime( &self, - f: impl Future + Send + 'static, + f: impl Future + Send + 'static, ) -> tokio::task::JoinHandle where R: Send + 'static, @@ -1054,7 +1054,7 @@ impl BackboneShell { self.controller_preset_manager.borrow().log_debug_info(); } - pub fn changed(&self) -> impl LocalObservable<'static, Item = (), Err = ()> + 'static { + pub fn changed(&self) -> impl LocalObservable<'static, Item=(), Err=()> + 'static { self.sessions_changed_subject.borrow().clone() } @@ -1234,7 +1234,7 @@ impl BackboneShell { .iter() .find(|i| i.is_main_unit && i.instance_id == instance_id) }) - .ok() + .ok() } #[cfg(feature = "playtime")] @@ -1928,7 +1928,7 @@ impl BackboneShell { compartment, target, ) - .or_else(|| self.find_first_session_with_target(None, compartment, target)) + .or_else(|| self.find_first_session_with_target(None, compartment, target)) } fn find_first_session_with_target( @@ -1983,7 +1983,7 @@ impl BackboneShell { Some(Reaper::get().current_project()), input_descriptor, ) - .or_else(|| self.find_first_session_with_input_from(None, input_descriptor)) + .or_else(|| self.find_first_session_with_input_from(None, input_descriptor)) } fn find_first_session_with_input_from( @@ -2008,13 +2008,13 @@ impl BackboneShell { compartment, capture_result, ) - .or_else(|| { - self.find_first_session_with_learnable_source_matching( - None, - compartment, - capture_result, - ) - }) + .or_else(|| { + self.find_first_session_with_learnable_source_matching( + None, + compartment, + capture_result, + ) + }) } fn find_first_session_with_learnable_source_matching( @@ -2318,8 +2318,11 @@ impl HwndInfo for BackboneShell { // Flutter essentially just uses one big HWND on windows ... text fields are not different HWNDs and // therefore not identifiable as text field (via Window classes "Edit", "RichEdit" etc.). // When we end up here, we are on Windows (for macOS, the hook is not registered). + let Some(parent_window) = Window::from_hwnd(hwnd).parent() else { + return IGNORE; + }; // The queried window has a parent - match app_window_is_in_text_entry_mode(hwnd) { + match app_window_is_in_text_entry_mode(parent_window.raw_hwnd()) { None => { // Probably not a Helgobox App window IGNORE diff --git a/main/src/infrastructure/ui/app/app_instance.rs b/main/src/infrastructure/ui/app/app_instance.rs index 352274093..853f83b02 100644 --- a/main/src/infrastructure/ui/app/app_instance.rs +++ b/main/src/infrastructure/ui/app/app_instance.rs @@ -38,11 +38,11 @@ pub trait AppInstance: Debug { /// Returns the app window. /// - /// That should be the thing that REAPER passes in the `HwndInfo` hook. + /// On Windows, that is the app handle (HWND), which is the **parent** window of whatever REAPER passes into + /// the `HwndInfo` hook. /// - /// On Windows, that currently is the parent window of the app handle window. - /// - /// On macOS, that's currently the content view (NSView) of the app handle window. + /// On macOS, this is the content view (NSView) of the app handle (NSWindow), which is exactly what + /// REAPER passes into the `HwndInfo` hook. fn window(&self) -> Option; fn notify_app_is_in_text_entry_mode(&mut self, is_in_text_entry_mode: bool);