File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use crate::{
88} ;
99use objc2:: rc:: autoreleasepool;
1010
11- static MAX_TEXT_DISPLAY_LEN : usize = 30 ;
11+ const MAX_TEXT_DISPLAY_LEN : usize = 30 ;
1212
1313impl AppEngine {
1414 pub ( super ) fn clear_drawing ( & mut self ) {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ use core_foundation::{
1818 boolean:: CFBoolean ,
1919 string:: CFString ,
2020} ;
21+ use objc2:: rc:: autoreleasepool;
2122use objc2_core_foundation:: { CGPoint , CGSize } ;
2223use std:: { collections:: HashMap , sync:: mpsc:: Sender } ;
2324
@@ -1020,16 +1021,18 @@ pub fn traverse(
10201021 vis_level : VisibilityCheckingLevel ,
10211022 result_tx : Sender < ElementSignal > ,
10221023) {
1023- let target_c = target. clone ( ) ;
1024- let tx_c = result_tx. clone ( ) ;
1025- traverse_elements (
1026- root,
1027- & parent_frame,
1028- & window_frame,
1029- & target_c,
1030- vis_level,
1031- tx_c,
1032- 0 ,
1033- ) ;
1034- let _ = result_tx. send ( ElementSignal :: TraversalFinished ( target) ) ;
1024+ autoreleasepool ( |_| {
1025+ let target_c = target. clone ( ) ;
1026+ let tx_c = result_tx. clone ( ) ;
1027+ traverse_elements (
1028+ root,
1029+ & parent_frame,
1030+ & window_frame,
1031+ & target_c,
1032+ vis_level,
1033+ tx_c,
1034+ 0 ,
1035+ ) ;
1036+ let _ = result_tx. send ( ElementSignal :: TraversalFinished ( target) ) ;
1037+ } )
10351038}
Original file line number Diff line number Diff line change @@ -33,12 +33,23 @@ const APPLE_ALARM_BUNDLE_IDS: [&str; 3] = [
3333 "com.apple.CoreLocationAgent" ,
3434] ;
3535
36+ const APPLE_NOTIFICATION_CENTER_BUNDLE_ID : & str = "com.apple.notificationcenterui" ;
37+
3638pub fn get_system_alarm_window ( ) -> Option < AXUIElement > {
37- APPLE_ALARM_BUNDLE_IDS . iter ( ) . find_map ( |bundle_id| {
38- AXUIElement :: application_with_bundle ( bundle_id)
39- . and_then ( |app| app. focused_window ( ) )
40- . ok ( )
41- } )
39+ APPLE_ALARM_BUNDLE_IDS
40+ . iter ( )
41+ . find_map ( |bundle_id| {
42+ AXUIElement :: application_with_bundle ( bundle_id)
43+ . and_then ( |app| app. focused_window ( ) )
44+ . ok ( )
45+ } )
46+ . or_else ( || {
47+ let app =
48+ AXUIElement :: application_with_bundle ( APPLE_NOTIFICATION_CENTER_BUNDLE_ID ) . ok ( ) ?;
49+ // Notification banners are not focused, so we need to get the first window
50+ let windows = app. windows ( ) . ok ( ) ?;
51+ windows. iter ( ) . next ( ) . as_deref ( ) . cloned ( )
52+ } )
4253}
4354
4455pub fn get_focused ( ) -> Option < ( i32 , AXUIElement , bool ) > {
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ struct Menu {
2121 menu_string : Retained < NSMutableAttributedString > ,
2222}
2323
24- static BORDER_WIDTH : f64 = 2.0 ;
25- static MIN_FONT_SIZE : f64 = 10.0 ;
24+ const BORDER_WIDTH : f64 = 2.0 ;
25+ const MIN_FONT_SIZE : f64 = 10.0 ;
2626
2727impl Menu {
2828 fn new ( theme : & GlyphlowTheme ) -> Self {
You can’t perform that action at this time.
0 commit comments