diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 394ace7..446010e 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -2,7 +2,7 @@ use windows::Win32::Graphics::Gdi::ClientToScreen; use windows::Win32::System::Com::VT_I4; use windows::Win32::System::Ole::{VariantClear, VariantInit}; use windows::Win32::UI::Accessibility::{ - AccessibleObjectFromEvent, AccessibleObjectFromWindow, IAccessible, + AccessibleObjectFromEvent, IAccessible, }; use std::sync::atomic::AtomicPtr; @@ -16,7 +16,7 @@ use windows::Win32::UI::WindowsAndMessaging::{ GetWindowThreadProcessId, IsHungAppWindow, PostMessageW, RegisterWindowMessageW, TranslateMessage, CHILDID_SELF, EVENT_OBJECT_DESTROY, EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_NAMECHANGE, EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_MINIMIZEEND, MSG, - OBJECT_IDENTIFIER, OBJID_WINDOW, STATE_SYSTEM_FOCUSED, WINEVENT_OUTOFCONTEXT, + OBJECT_IDENTIFIER, OBJID_WINDOW, STATE_SYSTEM_FOCUSED, WINEVENT_OUTOFCONTEXT, SetTimer, }; use windows::Win32::{ Foundation::HWND, @@ -370,6 +370,7 @@ impl Runtime { self.target.destroyed_change.bind(); let has_access = self.has_uipi_access(); + if let Some(bounds) = self.get_content_bounds() { self.underlay_tx .send(UnderlayEvent::Attach { bounds, has_access }) @@ -380,6 +381,7 @@ impl Runtime { } else { self.target.hwnd = Default::default(); } + } fn msaa_check_window_focused_state(&mut self, hwnd: HWND) -> bool { @@ -461,6 +463,8 @@ impl Runtime { } } +const OW_FOREGROUND_TIMER_MS: u32 = 83; + pub fn init( window_title: String, tx: std::sync::mpsc::Sender, @@ -493,6 +497,7 @@ pub fn init( }; runtime.foreground_change.bind(); runtime.unminimize_change.bind(); + unsafe { SetTimer(HWND::default(), 0, OW_FOREGROUND_TIMER_MS, Some(global_timer_hook)) }; GLOBAL_CALLBACK_SENDER.store( Box::into_raw(Box::new(Arc::new(Mutex::new(runtime)))),