@@ -177,31 +177,24 @@ impl DockItem {
177
177
. width ( app_icon. icon_size . into ( ) )
178
178
. height ( app_icon. icon_size . into ( ) ) ;
179
179
180
- let dots = if toplevels. is_empty ( ) {
181
- ( 0 ..1 )
182
- . map ( |_| {
183
- container ( vertical_space ( ) . height ( Length :: Fixed ( 0.0 ) ) )
184
- . padding ( app_icon. dot_radius )
185
- . into ( )
186
- } )
187
- . collect_vec ( )
188
- } else {
189
- ( 0 ..1 )
190
- . map ( |_| {
191
- container ( if toplevels. len ( ) == 1 {
192
- vertical_space ( ) . height ( Length :: Fixed ( 0.0 ) )
193
- } else {
194
- match applet. anchor {
195
- PanelAnchor :: Left | PanelAnchor :: Right => {
196
- vertical_space ( ) . height ( app_icon. bar_size )
197
- }
198
- PanelAnchor :: Top | PanelAnchor :: Bottom => {
199
- horizontal_space ( ) . width ( app_icon. bar_size )
200
- }
201
- }
202
- } )
203
- . padding ( app_icon. dot_radius )
204
- . class ( theme:: style:: Container :: Custom ( Box :: new ( move |theme| {
180
+ let dot_constructor = || {
181
+ let space = if toplevels. len ( ) <= 1 {
182
+ vertical_space ( ) . height ( Length :: Fixed ( 0.0 ) )
183
+ } else {
184
+ match applet. anchor {
185
+ PanelAnchor :: Left | PanelAnchor :: Right => {
186
+ vertical_space ( ) . height ( app_icon. bar_size )
187
+ }
188
+ PanelAnchor :: Top | PanelAnchor :: Bottom => {
189
+ horizontal_space ( ) . width ( app_icon. bar_size )
190
+ }
191
+ }
192
+ } ;
193
+ let mut container = container ( space) . padding ( app_icon. dot_radius ) ;
194
+
195
+ if !toplevels. is_empty ( ) {
196
+ container =
197
+ container. class ( theme:: style:: Container :: Custom ( Box :: new ( move |theme| {
205
198
container:: Style {
206
199
text_color : Some ( Color :: TRANSPARENT ) ,
207
200
background : if is_focused {
@@ -218,34 +211,35 @@ impl DockItem {
218
211
icon_color : Some ( Color :: TRANSPARENT ) ,
219
212
}
220
213
} ) ) )
221
- . into ( )
222
- } )
223
- . collect_vec ( )
214
+ }
215
+ container. into ( )
224
216
} ;
225
217
218
+ let dots = [ dot_constructor ( ) , dot_constructor ( ) ] ;
219
+
226
220
let icon_wrapper: Element < _ > = match applet. anchor {
227
- PanelAnchor :: Left => row ( vec ! [
221
+ PanelAnchor :: Left => row ( [
228
222
column ( dots) . into ( ) ,
229
223
horizontal_space ( ) . width ( Length :: Fixed ( 1.0 ) ) . into ( ) ,
230
224
cosmic_icon. clone ( ) . into ( ) ,
231
225
] )
232
226
. align_y ( Alignment :: Center )
233
227
. into ( ) ,
234
- PanelAnchor :: Right => row ( vec ! [
228
+ PanelAnchor :: Right => row ( [
235
229
cosmic_icon. clone ( ) . into ( ) ,
236
230
horizontal_space ( ) . width ( Length :: Fixed ( 1.0 ) ) . into ( ) ,
237
231
column ( dots) . into ( ) ,
238
232
] )
239
233
. align_y ( Alignment :: Center )
240
234
. into ( ) ,
241
- PanelAnchor :: Top => column ( vec ! [
235
+ PanelAnchor :: Top => column ( [
242
236
row ( dots) . into ( ) ,
243
237
vertical_space ( ) . height ( Length :: Fixed ( 1.0 ) ) . into ( ) ,
244
238
cosmic_icon. clone ( ) . into ( ) ,
245
239
] )
246
240
. align_x ( Alignment :: Center )
247
241
. into ( ) ,
248
- PanelAnchor :: Bottom => column ( vec ! [
242
+ PanelAnchor :: Bottom => column ( [
249
243
cosmic_icon. clone ( ) . into ( ) ,
250
244
vertical_space ( ) . height ( Length :: Fixed ( 1.0 ) ) . into ( ) ,
251
245
row ( dots) . into ( ) ,
@@ -470,7 +464,7 @@ where
470
464
img. img. clone( ) ,
471
465
) ) )
472
466
} else {
473
- Image :: new( Handle :: from_rgba( 1 , 1 , vec! [ 0 , 0 , 0 , 255 ] ) ) . into( )
467
+ Image :: new( Handle :: from_rgba( 1 , 1 , [ 0u8 , 0u8 , 0u8 , 255u8 ] . as_slice ( ) ) ) . into( )
474
468
} )
475
469
. class( Container :: Custom ( Box :: new( move |theme| {
476
470
container:: Style {
@@ -590,7 +584,7 @@ fn find_desktop_entries<'a>(
590
584
app_ids. iter ( ) . map ( |fav| {
591
585
let unicase_fav = fde:: unicase:: Ascii :: new ( fav. as_str ( ) ) ;
592
586
fde:: find_app_by_id ( desktop_entries, unicase_fav) . map_or_else (
593
- || fde:: DesktopEntry :: from_appid ( fav. clone ( ) ) . clone ( ) ,
587
+ || fde:: DesktopEntry :: from_appid ( fav. clone ( ) ) ,
594
588
ToOwned :: to_owned,
595
589
)
596
590
} )
@@ -612,7 +606,7 @@ impl CosmicAppList {
612
606
. map ( |( pinned_ctr, ( e, original_id) ) | DockItem {
613
607
id : pinned_ctr as u32 ,
614
608
toplevels : Vec :: new ( ) ,
615
- desktop_info : e. clone ( ) ,
609
+ desktop_info : e,
616
610
original_app_id : original_id. clone ( ) ,
617
611
} )
618
612
. collect ( ) ;
@@ -673,7 +667,7 @@ impl cosmic::Application for CosmicAppList {
673
667
} else {
674
668
self . overflow_active_popup = None ;
675
669
self . overflow_favorites_popup = None ;
676
- return Task :: batch ( vec ! [ destroy_popup( popup_id) , destroy_popup( parent) ] ) ;
670
+ return Task :: batch ( [ destroy_popup ( popup_id) , destroy_popup ( parent) ] ) ;
677
671
}
678
672
}
679
673
if let Some ( toplevel_group) = self
@@ -733,7 +727,7 @@ impl cosmic::Application for CosmicAppList {
733
727
} else {
734
728
self . overflow_active_popup = None ;
735
729
self . overflow_favorites_popup = None ;
736
- return Task :: batch ( vec ! [ destroy_popup( popup_id) , destroy_popup( parent) ] ) ;
730
+ return Task :: batch ( [ destroy_popup ( popup_id) , destroy_popup ( parent) ] ) ;
737
731
}
738
732
}
739
733
if let Some ( toplevel_group) = self
@@ -1490,7 +1484,10 @@ impl cosmic::Application for CosmicAppList {
1490
1484
} else {
1491
1485
0
1492
1486
} ;
1493
- let favorites: Vec < _ > = ( & mut self . pinned_list . iter ( ) . rev ( ) )
1487
+ let favorites: Vec < _ > = self
1488
+ . pinned_list
1489
+ . iter ( )
1490
+ . rev ( )
1494
1491
. filter ( |f| {
1495
1492
if favorite_to_remove > 0 && f. toplevels . is_empty ( ) {
1496
1493
favorite_to_remove -= 1 ;
@@ -1812,11 +1809,7 @@ impl cosmic::Application for CosmicAppList {
1812
1809
Message :: Exec ( exec. to_string ( ) , None , desktop_info. terminal ( ) ) ,
1813
1810
) ) ;
1814
1811
} 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
- } ;
1812
+ let default_idx = preferred_gpu_idx ( desktop_info, gpus. iter ( ) ) ;
1820
1813
for ( i, gpu) in gpus. iter ( ) . enumerate ( ) {
1821
1814
content = content. push (
1822
1815
menu_button ( text:: body ( format ! (
@@ -2101,7 +2094,10 @@ impl cosmic::Application for CosmicAppList {
2101
2094
0
2102
2095
} ;
2103
2096
let mut favorites_extra = Vec :: with_capacity ( favorite_to_remove) ;
2104
- let mut favorites: Vec < _ > = ( & mut self . pinned_list . iter ( ) . rev ( ) )
2097
+ let mut favorites: Vec < _ > = self
2098
+ . pinned_list
2099
+ . iter ( )
2100
+ . rev ( )
2105
2101
. filter ( |f| {
2106
2102
if favorite_to_remove > 0 && f. toplevels . is_empty ( ) {
2107
2103
favorite_to_remove -= 1 ;
@@ -2190,7 +2186,7 @@ impl cosmic::Application for CosmicAppList {
2190
2186
}
2191
2187
2192
2188
fn subscription ( & self ) -> Subscription < Message > {
2193
- Subscription :: batch ( vec ! [
2189
+ Subscription :: batch ( [
2194
2190
wayland_subscription ( ) . map ( Message :: Wayland ) ,
2195
2191
listen_with ( |e, _, id| match e {
2196
2192
cosmic:: iced_runtime:: core:: Event :: PlatformSpecific (
@@ -2299,9 +2295,9 @@ impl CosmicAppList {
2299
2295
if self . active_workspaces . is_empty ( ) {
2300
2296
return Vec :: new ( ) ;
2301
2297
}
2302
- let current_output = self . core . applet . output_name . clone ( ) ;
2298
+ let current_output = self . core . applet . output_name . as_ref ( ) ;
2303
2299
let mut focused_toplevels: Vec < ExtForeignToplevelHandleV1 > = Vec :: new ( ) ;
2304
- let active_workspaces = self . active_workspaces . clone ( ) ;
2300
+ let active_workspaces = & self . active_workspaces ;
2305
2301
for toplevel_list in self . active_list . iter ( ) . chain ( self . pinned_list . iter ( ) ) {
2306
2302
for ( t_info, _) in & toplevel_list. toplevels {
2307
2303
if t_info. state . contains ( & State :: Activated )
@@ -2378,13 +2374,7 @@ impl CosmicAppList {
2378
2374
fn launch_on_preferred_gpu ( desktop_info : & DesktopEntry , gpus : Option < & [ Gpu ] > ) -> Option < Message > {
2379
2375
let exec = desktop_info. exec ( ) ?;
2380
2376
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
- } ) ;
2377
+ let gpu_idx = gpus. map ( |gpus| preferred_gpu_idx ( desktop_info, gpus. iter ( ) ) ) ;
2388
2378
2389
2379
Some ( Message :: Exec (
2390
2380
exec. to_string ( ) ,
@@ -2393,6 +2383,14 @@ fn launch_on_preferred_gpu(desktop_info: &DesktopEntry, gpus: Option<&[Gpu]>) ->
2393
2383
) )
2394
2384
}
2395
2385
2386
+ fn preferred_gpu_idx < ' a , I > ( desktop_info : & DesktopEntry , mut gpus : I ) -> usize
2387
+ where
2388
+ I : Iterator < Item = & ' a Gpu > ,
2389
+ {
2390
+ gpus. position ( |gpu| gpu. default ^ desktop_info. prefers_non_default_gpu ( ) )
2391
+ . unwrap_or ( 0 )
2392
+ }
2393
+
2396
2394
#[ derive( Debug , Default , Clone ) ]
2397
2395
pub struct DndPathBuf ( PathBuf ) ;
2398
2396
@@ -2428,8 +2426,6 @@ impl AsMimeTypes for DndPathBuf {
2428
2426
}
2429
2427
2430
2428
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
- ) )
2429
+ Some ( Cow :: Owned ( self . 0 . to_str ( ) ?. as_bytes ( ) . to_vec ( ) ) )
2434
2430
}
2435
2431
}
0 commit comments