@@ -241,29 +241,14 @@ pub fn get_focused_window_with_retry(
241241pub struct WindowInfo {
242242 pub pid : i32 ,
243243 pub title : String ,
244- pub role : String ,
245- }
246-
247- impl WindowInfo {
248- pub fn display_string ( & self ) -> String {
249- let app_name = get_app_name ( self . pid ) . unwrap_or_else ( |_| "Unknown" . to_string ( ) ) ;
250- if self . title . is_empty ( ) {
251- format ! ( "{} (PID: {})" , app_name, self . pid)
252- } else {
253- format ! ( "{} - \" {}\" (PID: {})" , app_name, self . title, self . pid)
254- }
255- }
256244}
257245
258246/// Get information about a window element
259247pub fn get_window_info ( element : & AXUIElement ) -> Result < WindowInfo , PixieError > {
260248 let title = element. title ( ) . map ( |s| s. to_string ( ) ) . unwrap_or_default ( ) ;
261-
262- let role = element. role ( ) . map ( |s| s. to_string ( ) ) . unwrap_or_default ( ) ;
263-
264249 let pid = get_pid ( element) ?;
265250
266- Ok ( WindowInfo { pid, title, role } )
251+ Ok ( WindowInfo { pid, title } )
267252}
268253
269254/// Get the PID from an AXUIElement
@@ -435,7 +420,11 @@ fn read_bundle_icon_name(bundle_path: &str) -> Option<String> {
435420 use std:: process:: Command ;
436421
437422 let output = Command :: new ( "defaults" )
438- . args ( [ "read" , & format ! ( "{bundle_path}/Contents/Info" ) , "CFBundleIconFile" ] )
423+ . args ( [
424+ "read" ,
425+ & format ! ( "{bundle_path}/Contents/Info" ) ,
426+ "CFBundleIconFile" ,
427+ ] )
439428 . output ( )
440429 . ok ( ) ?;
441430 if !output. status . success ( ) {
@@ -589,7 +578,6 @@ pub struct WindowRect {
589578 pub y : f64 ,
590579 pub width : f64 ,
591580 pub height : f64 ,
592- pub element : AXUIElement ,
593581 pub pid : i32 ,
594582 pub window_id : Option < u32 > ,
595583}
@@ -627,7 +615,6 @@ pub fn get_window_rect(element: &AXUIElement) -> Result<WindowRect, PixieError>
627615 y : rect. origin . y ,
628616 width : rect. size . width ,
629617 height : rect. size . height ,
630- element : element. clone ( ) ,
631618 pid,
632619 window_id,
633620 } )
@@ -850,7 +837,7 @@ fn get_dict_f64(dict: &CFDictionary, key: &str) -> f64 {
850837 let key = CFString :: new ( key) ;
851838 unsafe {
852839 let mut value: * const std:: ffi:: c_void = std:: ptr:: null ( ) ;
853- let key_ptr = key. as_CFTypeRef ( ) as * const std :: ffi :: c_void ;
840+ let key_ptr = key. as_CFTypeRef ( ) ;
854841 if core_foundation:: dictionary:: CFDictionaryGetValueIfPresent (
855842 dict. as_concrete_TypeRef ( ) ,
856843 key_ptr,
@@ -920,11 +907,6 @@ pub fn get_screens() -> Result<Vec<Screen>, PixieError> {
920907 Ok ( screens)
921908}
922909
923- /// Get all visible windows on a specific monitor
924- pub fn get_windows_on_monitor ( screen : & Screen ) -> Result < Vec < WindowEntry > , PixieError > {
925- get_picker_windows ( Some ( screen) )
926- }
927-
928910/// Get all windows used by the picker (including off-screen/minimized)
929911pub fn get_all_windows ( ) -> Result < Vec < WindowEntry > , PixieError > {
930912 get_picker_windows ( None )
@@ -1085,7 +1067,9 @@ fn get_picker_windows(screen: Option<&Screen>) -> Result<Vec<WindowEntry>, Pixie
10851067 Ok ( windows)
10861068}
10871069
1088- fn get_window_titles_for_pid ( pid : i32 ) -> Result < std:: collections:: HashMap < u32 , String > , PixieError > {
1070+ fn get_window_titles_for_pid (
1071+ pid : i32 ,
1072+ ) -> Result < std:: collections:: HashMap < u32 , String > , PixieError > {
10891073 let app_element = AXUIElement :: application ( pid) ;
10901074
10911075 let windows = app_element
@@ -1097,7 +1081,10 @@ fn get_window_titles_for_pid(pid: i32) -> Result<std::collections::HashMap<u32,
10971081 if let Some ( win) = windows. get ( i) {
10981082 let win = win. clone ( ) ;
10991083 if let Ok ( win_id) = get_window_id ( & win) {
1100- titles. insert ( win_id, win. title ( ) . map ( |s| s. to_string ( ) ) . unwrap_or_default ( ) ) ;
1084+ titles. insert (
1085+ win_id,
1086+ win. title ( ) . map ( |s| s. to_string ( ) ) . unwrap_or_default ( ) ,
1087+ ) ;
11011088 }
11021089 }
11031090 }
@@ -1320,23 +1307,6 @@ pub fn toggle_fullscreen(element: &AXUIElement) -> Result<(), PixieError> {
13201307 Ok ( ( ) )
13211308}
13221309
1323- pub fn center_window ( element : & AXUIElement ) -> Result < ( ) , PixieError > {
1324- let window_rect = get_window_rect ( element) ?;
1325- let screen = get_screen_for_window ( & window_rect) ?;
1326-
1327- let menu_bar_height = if screen. is_main { 25.0 } else { 0.0 } ;
1328-
1329- let available_x = screen. x ;
1330- let available_y = screen. y + menu_bar_height;
1331- let available_width = screen. width ;
1332- let available_height = screen. height - menu_bar_height;
1333-
1334- let new_x = available_x + ( available_width - window_rect. width ) / 2.0 ;
1335- let new_y = available_y + ( available_height - window_rect. height ) / 2.0 ;
1336-
1337- set_window_rect ( element, new_x, new_y, window_rect. width , window_rect. height )
1338- }
1339-
13401310#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
13411311pub enum MonitorDirection {
13421312 Left ,
0 commit comments