@@ -590,7 +590,7 @@ fn find_desktop_entries<'a>(
590
590
app_ids. iter ( ) . map ( |fav| {
591
591
let unicase_fav = fde:: unicase:: Ascii :: new ( fav. as_str ( ) ) ;
592
592
fde:: find_app_by_id ( desktop_entries, unicase_fav) . map_or_else (
593
- || fde:: DesktopEntry :: from_appid ( fav. clone ( ) ) . clone ( ) ,
593
+ || fde:: DesktopEntry :: from_appid ( fav. clone ( ) ) ,
594
594
ToOwned :: to_owned,
595
595
)
596
596
} )
@@ -612,7 +612,7 @@ impl CosmicAppList {
612
612
. map ( |( pinned_ctr, ( e, original_id) ) | DockItem {
613
613
id : pinned_ctr as u32 ,
614
614
toplevels : Vec :: new ( ) ,
615
- desktop_info : e. clone ( ) ,
615
+ desktop_info : e,
616
616
original_app_id : original_id. clone ( ) ,
617
617
} )
618
618
. collect ( ) ;
@@ -1490,7 +1490,10 @@ impl cosmic::Application for CosmicAppList {
1490
1490
} else {
1491
1491
0
1492
1492
} ;
1493
- let favorites: Vec < _ > = ( & mut self . pinned_list . iter ( ) . rev ( ) )
1493
+ let favorites: Vec < _ > = self
1494
+ . pinned_list
1495
+ . iter ( )
1496
+ . rev ( )
1494
1497
. filter ( |f| {
1495
1498
if favorite_to_remove > 0 && f. toplevels . is_empty ( ) {
1496
1499
favorite_to_remove -= 1 ;
@@ -1812,11 +1815,7 @@ impl cosmic::Application for CosmicAppList {
1812
1815
Message :: Exec ( exec. to_string ( ) , None , desktop_info. terminal ( ) ) ,
1813
1816
) ) ;
1814
1817
} else if let Some ( gpus) = self . gpus . as_ref ( ) {
1815
- let default_idx = if desktop_info. prefers_non_default_gpu ( ) {
1816
- gpus. iter ( ) . position ( |gpu| !gpu. default ) . unwrap_or ( 0 )
1817
- } else {
1818
- gpus. iter ( ) . position ( |gpu| gpu. default ) . unwrap_or ( 0 )
1819
- } ;
1818
+ let default_idx = preferred_gpu_idx ( desktop_info, gpus. iter ( ) ) ;
1820
1819
for ( i, gpu) in gpus. iter ( ) . enumerate ( ) {
1821
1820
content = content. push (
1822
1821
menu_button ( text:: body ( format ! (
@@ -2101,7 +2100,10 @@ impl cosmic::Application for CosmicAppList {
2101
2100
0
2102
2101
} ;
2103
2102
let mut favorites_extra = Vec :: with_capacity ( favorite_to_remove) ;
2104
- let mut favorites: Vec < _ > = ( & mut self . pinned_list . iter ( ) . rev ( ) )
2103
+ let mut favorites: Vec < _ > = self
2104
+ . pinned_list
2105
+ . iter ( )
2106
+ . rev ( )
2105
2107
. filter ( |f| {
2106
2108
if favorite_to_remove > 0 && f. toplevels . is_empty ( ) {
2107
2109
favorite_to_remove -= 1 ;
@@ -2299,9 +2301,9 @@ impl CosmicAppList {
2299
2301
if self . active_workspaces . is_empty ( ) {
2300
2302
return Vec :: new ( ) ;
2301
2303
}
2302
- let current_output = self . core . applet . output_name . clone ( ) ;
2304
+ let current_output = self . core . applet . output_name . as_ref ( ) ;
2303
2305
let mut focused_toplevels: Vec < ExtForeignToplevelHandleV1 > = Vec :: new ( ) ;
2304
- let active_workspaces = self . active_workspaces . clone ( ) ;
2306
+ let active_workspaces = & self . active_workspaces ;
2305
2307
for toplevel_list in self . active_list . iter ( ) . chain ( self . pinned_list . iter ( ) ) {
2306
2308
for ( t_info, _) in & toplevel_list. toplevels {
2307
2309
if t_info. state . contains ( & State :: Activated )
@@ -2378,13 +2380,7 @@ impl CosmicAppList {
2378
2380
fn launch_on_preferred_gpu ( desktop_info : & DesktopEntry , gpus : Option < & [ Gpu ] > ) -> Option < Message > {
2379
2381
let exec = desktop_info. exec ( ) ?;
2380
2382
2381
- let gpu_idx = gpus. map ( |gpus| {
2382
- if desktop_info. prefers_non_default_gpu ( ) {
2383
- gpus. iter ( ) . position ( |gpu| !gpu. default ) . unwrap_or ( 0 )
2384
- } else {
2385
- gpus. iter ( ) . position ( |gpu| gpu. default ) . unwrap_or ( 0 )
2386
- }
2387
- } ) ;
2383
+ let gpu_idx = gpus. map ( |gpus| preferred_gpu_idx ( desktop_info, gpus. iter ( ) ) ) ;
2388
2384
2389
2385
Some ( Message :: Exec (
2390
2386
exec. to_string ( ) ,
@@ -2393,6 +2389,14 @@ fn launch_on_preferred_gpu(desktop_info: &DesktopEntry, gpus: Option<&[Gpu]>) ->
2393
2389
) )
2394
2390
}
2395
2391
2392
+ fn preferred_gpu_idx < ' a , I > ( desktop_info : & DesktopEntry , mut gpus : I ) -> usize
2393
+ where
2394
+ I : Iterator < Item = & ' a Gpu > ,
2395
+ {
2396
+ gpus. position ( |gpu| gpu. default ^ desktop_info. prefers_non_default_gpu ( ) )
2397
+ . unwrap_or ( 0 )
2398
+ }
2399
+
2396
2400
#[ derive( Debug , Default , Clone ) ]
2397
2401
pub struct DndPathBuf ( PathBuf ) ;
2398
2402
@@ -2428,8 +2432,6 @@ impl AsMimeTypes for DndPathBuf {
2428
2432
}
2429
2433
2430
2434
fn as_bytes ( & self , _mime_type : & str ) -> Option < std:: borrow:: Cow < ' static , [ u8 ] > > {
2431
- Some ( Cow :: Owned (
2432
- self . 0 . clone ( ) . to_str ( ) ?. to_string ( ) . into_bytes ( ) ,
2433
- ) )
2435
+ Some ( Cow :: Owned ( self . 0 . to_str ( ) ?. as_bytes ( ) . to_vec ( ) ) )
2434
2436
}
2435
2437
}
0 commit comments