cargo fmt

This commit is contained in:
ellieplayswow 2025-06-16 14:35:47 +01:00 committed by Ashley Wulber
parent 68ac7ea809
commit e5bdc727db

View file

@ -19,6 +19,7 @@ use cctk::{
workspace::v1::client::ext_workspace_handle_v1::ExtWorkspaceHandleV1, workspace::v1::client::ext_workspace_handle_v1::ExtWorkspaceHandleV1,
}, },
}; };
use cosmic::desktop::fde::unicase::Ascii;
use cosmic::desktop::fde::{get_languages_from_env, DesktopEntry}; use cosmic::desktop::fde::{get_languages_from_env, DesktopEntry};
use cosmic::{ use cosmic::{
app, app,
@ -57,7 +58,6 @@ use iced::{widget::container, Alignment, Background, Length};
use itertools::Itertools; use itertools::Itertools;
use rand::{rng, Rng}; use rand::{rng, Rng};
use std::{borrow::Cow, collections::HashMap, path::PathBuf, rc::Rc, str::FromStr, time::Duration}; use std::{borrow::Cow, collections::HashMap, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
use cosmic::desktop::fde::unicase::Ascii;
use switcheroo_control::Gpu; use switcheroo_control::Gpu;
use tokio::time::sleep; use tokio::time::sleep;
use url::Url; use url::Url;
@ -1105,7 +1105,8 @@ impl cosmic::Application for CosmicAppList {
WaylandUpdate::Toplevel(event) => match event { WaylandUpdate::Toplevel(event) => match event {
ToplevelUpdate::Add(mut info) => { ToplevelUpdate::Add(mut info) => {
let unicase_appid = fde::unicase::Ascii::new(&*info.app_id); let unicase_appid = fde::unicase::Ascii::new(&*info.app_id);
let new_desktop_info = self.find_desktop_entry_for_toplevel(&info, unicase_appid); let new_desktop_info =
self.find_desktop_entry_for_toplevel(&info, unicase_appid);
if let Some(t) = self if let Some(t) = self
.active_list .active_list
@ -1178,7 +1179,10 @@ impl cosmic::Application for CosmicAppList {
self.active_list.retain(|t| !t.toplevels.is_empty()); self.active_list.retain(|t| !t.toplevels.is_empty());
// find a new one for it // find a new one for it
let new_desktop_entry = self.find_desktop_entry_for_toplevel(&info, Ascii::new(&info.app_id)); let new_desktop_entry = self.find_desktop_entry_for_toplevel(
&info,
Ascii::new(&info.app_id),
);
if let Some(t) = self if let Some(t) = self
.active_list .active_list
@ -2329,28 +2333,23 @@ impl CosmicAppList {
focused_toplevels focused_toplevels
} }
fn find_desktop_entry_for_toplevel(&mut self, info: &ToplevelInfo, unicase_appid: Ascii<&str>) -> DesktopEntry { fn find_desktop_entry_for_toplevel(
&mut self,
info: &ToplevelInfo,
unicase_appid: Ascii<&str>,
) -> DesktopEntry {
match fde::find_app_by_id(&self.desktop_entries, unicase_appid) { match fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
Some(appid) => appid.clone(), Some(appid) => appid.clone(),
None => { None => {
// Update desktop entries in case it was not found. // Update desktop entries in case it was not found.
self.update_desktop_entries(); self.update_desktop_entries();
match fde::find_app_by_id( match fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
&self.desktop_entries,
unicase_appid,
) {
Some(appid) => appid.clone(), Some(appid) => appid.clone(),
None => { None => {
tracing::error!( tracing::error!(id = info.app_id, "could not find desktop entry for app");
id = info.app_id,
"could not find desktop entry for app"
);
let mut fallback_entry = let mut fallback_entry = fde::DesktopEntry::from_appid(info.app_id.clone());
fde::DesktopEntry::from_appid(
info.app_id.clone(),
);
// proton opens games as steam_app_X, where X is either // proton opens games as steam_app_X, where X is either
// the steam appid or "default". games with a steam appid // the steam appid or "default". games with a steam appid
@ -2359,8 +2358,7 @@ impl CosmicAppList {
// under proton // under proton
// in addition, try to match WINE entries who have its // in addition, try to match WINE entries who have its
// appid = the full name of the executable (incl. .exe) // appid = the full name of the executable (incl. .exe)
let is_proton_game = let is_proton_game = info.app_id == "steam_app_default";
info.app_id == "steam_app_default";
if is_proton_game || info.app_id.ends_with(".exe") { if is_proton_game || info.app_id.ends_with(".exe") {
for entry in &self.desktop_entries { for entry in &self.desktop_entries {
let localised_name = entry let localised_name = entry
@ -2372,10 +2370,7 @@ impl CosmicAppList {
// if this is a proton game, we only want // if this is a proton game, we only want
// to look for game entries // to look for game entries
if is_proton_game if is_proton_game
&& !entry && !entry.categories().unwrap_or_default().contains(&"Game")
.categories()
.unwrap_or_default()
.contains(&"Game")
{ {
continue; continue;
} }