chore: apply recommendations from clippy
This commit is contained in:
parent
cec55dafd7
commit
8e0f1c4a09
56 changed files with 720 additions and 824 deletions
|
|
@ -269,22 +269,22 @@ impl DockItem {
|
|||
.first()
|
||||
.map(|t| Message::Toggle(t.0.foreign_toplevel.clone()))
|
||||
} else {
|
||||
Some(Message::TopLevelListPopup((*id).into(), window_id))
|
||||
Some(Message::TopLevelListPopup(*id, window_id))
|
||||
})
|
||||
.width(Length::Shrink)
|
||||
.height(Length::Shrink),
|
||||
)
|
||||
.on_right_release(Message::Popup((*id).into(), window_id))
|
||||
.on_right_release(Message::Popup(*id, window_id))
|
||||
.on_middle_release({
|
||||
launch_on_preferred_gpu(desktop_info, gpus)
|
||||
.unwrap_or_else(|| Message::Popup((*id).into(), window_id))
|
||||
.unwrap_or(Message::Popup(*id, window_id))
|
||||
})
|
||||
.into()
|
||||
} else {
|
||||
icon_button.into()
|
||||
};
|
||||
|
||||
let path = desktop_info.path.to_path_buf();
|
||||
let path = desktop_info.path.clone();
|
||||
let icon_button = if dnd_source_enabled && interaction_enabled {
|
||||
dnd_source(icon_button)
|
||||
.window(window_id)
|
||||
|
|
@ -420,7 +420,7 @@ fn index_in_list(
|
|||
|
||||
if let Some(existing_preview) = existing_preview {
|
||||
if index >= existing_preview {
|
||||
index.checked_sub(1).unwrap_or_default()
|
||||
index.saturating_sub(1)
|
||||
} else {
|
||||
index
|
||||
}
|
||||
|
|
@ -589,9 +589,10 @@ fn find_desktop_entries<'a>(
|
|||
) -> impl Iterator<Item = fde::DesktopEntry> + 'a {
|
||||
app_ids.iter().map(|fav| {
|
||||
let unicase_fav = fde::unicase::Ascii::new(fav.as_str());
|
||||
fde::find_app_by_id(desktop_entries, unicase_fav)
|
||||
.map(ToOwned::to_owned)
|
||||
.unwrap_or_else(|| fde::DesktopEntry::from_appid(fav.clone()).to_owned())
|
||||
fde::find_app_by_id(desktop_entries, unicase_fav).map_or_else(
|
||||
|| fde::DesktopEntry::from_appid(fav.clone()).clone(),
|
||||
ToOwned::to_owned,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -610,7 +611,7 @@ impl CosmicAppList {
|
|||
.enumerate()
|
||||
.map(|(pinned_ctr, (e, original_id))| DockItem {
|
||||
id: pinned_ctr as u32,
|
||||
toplevels: Default::default(),
|
||||
toplevels: Vec::new(),
|
||||
desktop_info: e.clone(),
|
||||
original_app_id: original_id.clone(),
|
||||
})
|
||||
|
|
@ -681,12 +682,9 @@ impl cosmic::Application for CosmicAppList {
|
|||
.chain(self.pinned_list.iter())
|
||||
.find(|t| t.id == id)
|
||||
{
|
||||
let rectangle = match self.rectangles.get(&toplevel_group.id.into()) {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
tracing::error!("No rectangle found for toplevel group");
|
||||
return Task::none();
|
||||
}
|
||||
let Some(rectangle) = self.rectangles.get(&toplevel_group.id.into()) else {
|
||||
tracing::error!("No rectangle found for toplevel group");
|
||||
return Task::none();
|
||||
};
|
||||
|
||||
let new_id = window::Id::unique();
|
||||
|
|
@ -751,9 +749,8 @@ impl cosmic::Application for CosmicAppList {
|
|||
}
|
||||
}
|
||||
|
||||
let rectangle = match self.rectangles.get(&toplevel_group.id.into()) {
|
||||
Some(r) => r,
|
||||
None => return Task::none(),
|
||||
let Some(rectangle) = self.rectangles.get(&toplevel_group.id.into()) else {
|
||||
return Task::none();
|
||||
};
|
||||
|
||||
let new_id = window::Id::unique();
|
||||
|
|
@ -1040,7 +1037,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
self.active_list.remove(pos)
|
||||
};
|
||||
dock_item.toplevels = t.toplevels;
|
||||
};
|
||||
}
|
||||
dock_item.id = self.item_ctr;
|
||||
|
||||
if dock_item.desktop_info.exec().is_some() {
|
||||
|
|
@ -1095,7 +1092,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
pending::<()>().await;
|
||||
}
|
||||
},
|
||||
|_| Message::IncrementSubscriptionCtr,
|
||||
|()| Message::IncrementSubscriptionCtr,
|
||||
)
|
||||
.map(cosmic::action::app);
|
||||
}
|
||||
|
|
@ -1242,7 +1239,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
app_id.as_deref(),
|
||||
terminal,
|
||||
)
|
||||
.await
|
||||
.await;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1307,13 +1304,13 @@ impl cosmic::Application for CosmicAppList {
|
|||
{
|
||||
let mut d = self.active_list.remove(p);
|
||||
// but use the id from the config
|
||||
d.original_app_id = original_id.clone();
|
||||
d.original_app_id.clone_from(original_id);
|
||||
d
|
||||
} else {
|
||||
self.item_ctr += 1;
|
||||
DockItem {
|
||||
id: self.item_ctr,
|
||||
toplevels: Default::default(),
|
||||
toplevels: Vec::new(),
|
||||
desktop_info: de.clone(),
|
||||
original_app_id: original_id.clone(),
|
||||
}
|
||||
|
|
@ -1369,9 +1366,10 @@ impl cosmic::Application for CosmicAppList {
|
|||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
let (_favorite_popup_cutoff, active_popup_cutoff) =
|
||||
self.panel_overflow_lengths();
|
||||
let popup_applet_count = self.active_list.len().saturating_sub(
|
||||
(active_popup_cutoff.unwrap_or_default()).saturating_sub(1) as usize,
|
||||
) as f32;
|
||||
let popup_applet_count =
|
||||
self.active_list.len().saturating_sub(
|
||||
(active_popup_cutoff.unwrap_or_default()).saturating_sub(1),
|
||||
) as f32;
|
||||
let popup_applet_size = applet_suggested_size as f32 * popup_applet_count
|
||||
+ 4.0 * (popup_applet_count - 1.);
|
||||
let (max_width, max_height) = match self.core.applet.anchor {
|
||||
|
|
@ -1425,9 +1423,10 @@ impl cosmic::Application for CosmicAppList {
|
|||
+ 2 * self.core.applet.suggested_padding(false);
|
||||
let (favorite_popup_cutoff, _active_popup_cutoff) =
|
||||
self.panel_overflow_lengths();
|
||||
let popup_applet_count = self.pinned_list.len().saturating_sub(
|
||||
favorite_popup_cutoff.unwrap_or_default().saturating_sub(1) as usize,
|
||||
) as f32;
|
||||
let popup_applet_count =
|
||||
self.pinned_list.len().saturating_sub(
|
||||
favorite_popup_cutoff.unwrap_or_default().saturating_sub(1),
|
||||
) as f32;
|
||||
let popup_applet_size = applet_suggested_size as f32 * popup_applet_count
|
||||
+ 4.0 * (popup_applet_count - 1.);
|
||||
let (max_width, max_height) = match self.core.applet.anchor {
|
||||
|
|
@ -1462,7 +1461,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
Task::none()
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
fn view(&self) -> Element<'_, Message> {
|
||||
let focused_item = self.currently_active_toplevel();
|
||||
let theme = self.core.system_theme();
|
||||
let dot_radius = theme.cosmic().radius_xs();
|
||||
|
|
@ -1589,45 +1588,44 @@ impl cosmic::Application for CosmicAppList {
|
|||
);
|
||||
}
|
||||
|
||||
let mut active: Vec<_> = self.active_list[..active_popup_cutoff
|
||||
.map(|n| {
|
||||
let mut active: Vec<_> =
|
||||
self.active_list[..active_popup_cutoff.map_or(self.active_list.len(), |n| {
|
||||
if n < self.active_list.len() {
|
||||
n.saturating_sub(1)
|
||||
} else {
|
||||
n
|
||||
}
|
||||
})
|
||||
.unwrap_or(self.active_list.len())]
|
||||
.iter()
|
||||
.map(|dock_item| {
|
||||
self.core
|
||||
.applet
|
||||
.applet_tooltip(
|
||||
dock_item.as_icon(
|
||||
&self.core.applet,
|
||||
self.rectangle_tracker.as_ref(),
|
||||
self.popup.is_none(),
|
||||
self.config.enable_drag_source,
|
||||
self.gpus.as_deref(),
|
||||
})]
|
||||
.iter()
|
||||
.map(|dock_item| {
|
||||
self.core
|
||||
.applet
|
||||
.applet_tooltip(
|
||||
dock_item.as_icon(
|
||||
&self.core.applet,
|
||||
self.rectangle_tracker.as_ref(),
|
||||
self.popup.is_none(),
|
||||
self.config.enable_drag_source,
|
||||
self.gpus.as_deref(),
|
||||
dock_item
|
||||
.toplevels
|
||||
.iter()
|
||||
.any(|y| focused_item.contains(&y.0.foreign_toplevel)),
|
||||
dot_radius,
|
||||
self.core.main_window_id().unwrap(),
|
||||
),
|
||||
dock_item
|
||||
.toplevels
|
||||
.iter()
|
||||
.any(|y| focused_item.contains(&y.0.foreign_toplevel)),
|
||||
dot_radius,
|
||||
self.core.main_window_id().unwrap(),
|
||||
),
|
||||
dock_item
|
||||
.desktop_info
|
||||
.full_name(&self.locales)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
self.popup.is_some(),
|
||||
Message::Surface,
|
||||
None,
|
||||
)
|
||||
.into()
|
||||
})
|
||||
.collect();
|
||||
.desktop_info
|
||||
.full_name(&self.locales)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
self.popup.is_some(),
|
||||
Message::Surface,
|
||||
None,
|
||||
)
|
||||
.into()
|
||||
})
|
||||
.collect();
|
||||
|
||||
if active_popup_cutoff.is_some_and(|n| n < self.active_list.len()) {
|
||||
// button to show more active
|
||||
|
|
@ -1658,15 +1656,13 @@ impl cosmic::Application for CosmicAppList {
|
|||
+ self.core.applet.suggested_padding(false) * 2;
|
||||
window_size
|
||||
.map(|w| w.width)
|
||||
.map(|b| (b / suggested_width as f32) as u32)
|
||||
.unwrap_or(u32::MAX) as usize
|
||||
.map_or(u32::MAX, |b| (b / suggested_width as f32) as u32) as usize
|
||||
} else {
|
||||
let suggested_height = self.core.applet.suggested_size(false).1
|
||||
+ self.core.applet.suggested_padding(false) * 2;
|
||||
window_size
|
||||
.map(|w| w.height)
|
||||
.map(|b| (b / suggested_height as f32) as u32)
|
||||
.unwrap_or(u32::MAX) as usize
|
||||
.map_or(u32::MAX, |b| (b / suggested_height as f32) as u32) as usize
|
||||
}
|
||||
.max(4);
|
||||
if max_num < favorites.len() + active.len() {
|
||||
|
|
@ -1682,7 +1678,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
row(favorites).spacing(app_icon.icon_spacing),
|
||||
|_, _| Message::DndDropFinished,
|
||||
)
|
||||
.drag_id(DND_FAVORITES.clone()),
|
||||
.drag_id(DND_FAVORITES),
|
||||
row(active).spacing(app_icon.icon_spacing).into(),
|
||||
container(vertical_rule(1))
|
||||
.height(Length::Fill)
|
||||
|
|
@ -1697,7 +1693,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
column(favorites).spacing(app_icon.icon_spacing),
|
||||
|_data: Option<DndPathBuf>, _| Message::DndDropFinished,
|
||||
)
|
||||
.drag_id(DND_FAVORITES.clone()),
|
||||
.drag_id(DND_FAVORITES),
|
||||
column(active).spacing(app_icon.icon_spacing).into(),
|
||||
container(divider::horizontal::default())
|
||||
.width(Length::Fill)
|
||||
|
|
@ -1766,7 +1762,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
.into()
|
||||
}
|
||||
|
||||
fn view_window(&self, id: window::Id) -> Element<Message> {
|
||||
fn view_window(&self, id: window::Id) -> Element<'_, Message> {
|
||||
let theme = self.core.system_theme();
|
||||
|
||||
if let Some((_, item, _, _)) = self.dnd_source.as_ref().filter(|s| s.0 == id) {
|
||||
|
|
@ -1907,7 +1903,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
}),
|
||||
);
|
||||
|
||||
if toplevels.len() > 0 {
|
||||
if !toplevels.is_empty() {
|
||||
content = content.push(divider::horizontal::light());
|
||||
content = match toplevels.len() {
|
||||
1 => content.push(
|
||||
|
|
@ -2011,45 +2007,44 @@ impl cosmic::Application for CosmicAppList {
|
|||
let focused_item = self.currently_active_toplevel();
|
||||
let dot_radius = theme.cosmic().radius_xs();
|
||||
// show the overflow popup for active list
|
||||
let active: Vec<_> = self.active_list[active_popup_cutoff
|
||||
.map(|n| {
|
||||
let active: Vec<_> =
|
||||
self.active_list[..active_popup_cutoff.map_or(self.active_list.len(), |n| {
|
||||
if n < self.active_list.len() {
|
||||
n.saturating_sub(1)
|
||||
} else {
|
||||
n - 1
|
||||
}
|
||||
})
|
||||
.unwrap_or(self.active_list.len() - 1)..]
|
||||
.iter()
|
||||
.map(|dock_item| {
|
||||
self.core
|
||||
.applet
|
||||
.applet_tooltip(
|
||||
dock_item.as_icon(
|
||||
&self.core.applet,
|
||||
self.rectangle_tracker.as_ref(),
|
||||
self.popup.is_none(),
|
||||
self.config.enable_drag_source,
|
||||
self.gpus.as_deref(),
|
||||
})]
|
||||
.iter()
|
||||
.map(|dock_item| {
|
||||
self.core
|
||||
.applet
|
||||
.applet_tooltip(
|
||||
dock_item.as_icon(
|
||||
&self.core.applet,
|
||||
self.rectangle_tracker.as_ref(),
|
||||
self.popup.is_none(),
|
||||
self.config.enable_drag_source,
|
||||
self.gpus.as_deref(),
|
||||
dock_item
|
||||
.toplevels
|
||||
.iter()
|
||||
.any(|y| focused_item.contains(&y.0.foreign_toplevel)),
|
||||
dot_radius,
|
||||
self.core.main_window_id().unwrap(),
|
||||
),
|
||||
dock_item
|
||||
.toplevels
|
||||
.iter()
|
||||
.any(|y| focused_item.contains(&y.0.foreign_toplevel)),
|
||||
dot_radius,
|
||||
id,
|
||||
),
|
||||
dock_item
|
||||
.desktop_info
|
||||
.full_name(&self.locales)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
self.popup.is_some(),
|
||||
Message::Surface,
|
||||
Some(id),
|
||||
)
|
||||
.into()
|
||||
})
|
||||
.collect();
|
||||
.desktop_info
|
||||
.full_name(&self.locales)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
self.popup.is_some(),
|
||||
Message::Surface,
|
||||
None,
|
||||
)
|
||||
.into()
|
||||
})
|
||||
.collect();
|
||||
let content = match &self.core.applet.anchor {
|
||||
PanelAnchor::Left | PanelAnchor::Right => container(
|
||||
Column::with_children(active)
|
||||
|
|
@ -2117,7 +2112,7 @@ impl cosmic::Application for CosmicAppList {
|
|||
}
|
||||
})
|
||||
.collect();
|
||||
favorites.extend(favorites_extra[..favorite_to_remove].into_iter().cloned());
|
||||
favorites.extend(favorites_extra[..favorite_to_remove].iter().copied());
|
||||
let favorites: Vec<_> = favorites
|
||||
.iter()
|
||||
.rev()
|
||||
|
|
@ -2297,7 +2292,7 @@ impl CosmicAppList {
|
|||
favorite_index = (btn_count as usize).min(self.pinned_list.len());
|
||||
}
|
||||
// tracing::error!("{} {} {:?}", btn_count, favorite_index, active_index);
|
||||
return (Some(favorite_index), active_index);
|
||||
(Some(favorite_index), active_index)
|
||||
}
|
||||
|
||||
fn currently_active_toplevel(&self) -> Vec<ExtForeignToplevelHandleV1> {
|
||||
|
|
@ -2331,61 +2326,57 @@ impl CosmicAppList {
|
|||
info: &ToplevelInfo,
|
||||
unicase_appid: Ascii<&str>,
|
||||
) -> DesktopEntry {
|
||||
match fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
Some(appid) => appid.clone(),
|
||||
None => {
|
||||
// Update desktop entries in case it was not found.
|
||||
if let Some(appid) = fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
appid.clone()
|
||||
} else {
|
||||
// Update desktop entries in case it was not found.
|
||||
|
||||
self.update_desktop_entries();
|
||||
match fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
Some(appid) => appid.clone(),
|
||||
None => {
|
||||
tracing::error!(id = info.app_id, "could not find desktop entry for app");
|
||||
self.update_desktop_entries();
|
||||
if let Some(appid) = fde::find_app_by_id(&self.desktop_entries, unicase_appid) {
|
||||
appid.clone()
|
||||
} else {
|
||||
tracing::error!(id = info.app_id, "could not find desktop entry for app");
|
||||
|
||||
let mut fallback_entry = fde::DesktopEntry::from_appid(info.app_id.clone());
|
||||
let mut fallback_entry = fde::DesktopEntry::from_appid(info.app_id.clone());
|
||||
|
||||
// proton opens games as steam_app_X, where X is either
|
||||
// the steam appid or "default". games with a steam appid
|
||||
// can have a desktop entry generated elsewhere; this
|
||||
// specifically handles non-steam games opened
|
||||
// under proton
|
||||
// in addition, try to match WINE entries who have its
|
||||
// appid = the full name of the executable (incl. .exe)
|
||||
let is_proton_game = info.app_id == "steam_app_default";
|
||||
if is_proton_game || info.app_id.ends_with(".exe") {
|
||||
for entry in &self.desktop_entries {
|
||||
let localised_name = entry
|
||||
.name(&self.locales)
|
||||
.map(|x| x.to_string())
|
||||
.unwrap_or_default();
|
||||
// proton opens games as steam_app_X, where X is either
|
||||
// the steam appid or "default". games with a steam appid
|
||||
// can have a desktop entry generated elsewhere; this
|
||||
// specifically handles non-steam games opened
|
||||
// under proton
|
||||
// in addition, try to match WINE entries who have its
|
||||
// appid = the full name of the executable (incl. .exe)
|
||||
let is_proton_game = info.app_id == "steam_app_default";
|
||||
if is_proton_game || info.app_id.ends_with(".exe") {
|
||||
for entry in &self.desktop_entries {
|
||||
let localised_name = entry
|
||||
.name(&self.locales)
|
||||
.map(|x| x.to_string())
|
||||
.unwrap_or_default();
|
||||
|
||||
if localised_name == info.title {
|
||||
// if this is a proton game, we only want
|
||||
// to look for game entries
|
||||
if is_proton_game
|
||||
&& !entry.categories().unwrap_or_default().contains(&"Game")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fallback_entry = entry.clone();
|
||||
break;
|
||||
}
|
||||
if localised_name == info.title {
|
||||
// if this is a proton game, we only want
|
||||
// to look for game entries
|
||||
if is_proton_game
|
||||
&& !entry.categories().unwrap_or_default().contains(&"Game")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fallback_entry
|
||||
fallback_entry = entry.clone();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fallback_entry
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn launch_on_preferred_gpu(desktop_info: &DesktopEntry, gpus: Option<&[Gpu]>) -> Option<Message> {
|
||||
let Some(exec) = desktop_info.exec() else {
|
||||
return None;
|
||||
};
|
||||
let exec = desktop_info.exec()?;
|
||||
|
||||
let gpu_idx = gpus.map(|gpus| {
|
||||
if desktop_info.prefers_non_default_gpu() {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,6 @@ pub fn localize() {
|
|||
let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages();
|
||||
|
||||
if let Err(error) = localizer.select(&requested_languages) {
|
||||
eprintln!("Error while loading language for App List {}", error);
|
||||
eprintln!("Error while loading language for App List {error}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ impl ActivationHandler for AppData {
|
|||
fn new_token(&mut self, token: String, data: &ExecRequestData) {
|
||||
let _ = self.tx.unbounded_send(WaylandUpdate::ActivationToken {
|
||||
token: Some(token),
|
||||
app_id: data.app_id().map(|x| x.to_owned()),
|
||||
app_id: data.app_id().map(String::from),
|
||||
exec: data.exec.clone(),
|
||||
gpu_idx: data.gpu_idx,
|
||||
terminal: data.terminal,
|
||||
|
|
@ -313,7 +313,10 @@ impl Session {
|
|||
self.condvar.notify_all();
|
||||
}
|
||||
|
||||
fn wait_while<F: FnMut(&SessionInner) -> bool>(&self, mut f: F) -> MutexGuard<SessionInner> {
|
||||
fn wait_while<F: FnMut(&SessionInner) -> bool>(
|
||||
&self,
|
||||
mut f: F,
|
||||
) -> MutexGuard<'_, SessionInner> {
|
||||
self.condvar
|
||||
.wait_while(self.inner.lock().unwrap(), |data| f(data))
|
||||
.unwrap()
|
||||
|
|
@ -337,7 +340,7 @@ impl Dispatch<wl_shm_pool::WlShmPool, ()> for AppData {
|
|||
_app_data: &mut Self,
|
||||
_buffer: &wl_shm_pool::WlShmPool,
|
||||
_event: wl_shm_pool::Event,
|
||||
_: &(),
|
||||
(): &(),
|
||||
_: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
|
|
@ -349,7 +352,7 @@ impl Dispatch<wl_buffer::WlBuffer, ()> for AppData {
|
|||
_app_data: &mut Self,
|
||||
_buffer: &wl_buffer::WlBuffer,
|
||||
_event: wl_buffer::Event,
|
||||
_: &(),
|
||||
(): &(),
|
||||
_: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
|
|
@ -387,7 +390,7 @@ impl CaptureData {
|
|||
&self.qh,
|
||||
SessionData {
|
||||
session: session.clone(),
|
||||
session_data: Default::default(),
|
||||
session_data: ScreencopySessionData::default(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -405,22 +408,19 @@ impl CaptureData {
|
|||
}
|
||||
|
||||
// XXX
|
||||
if !formats
|
||||
.shm_formats
|
||||
.contains(&wl_shm::Format::Abgr8888.into())
|
||||
{
|
||||
if !formats.shm_formats.contains(&wl_shm::Format::Abgr8888) {
|
||||
tracing::error!("No suitable buffer format found");
|
||||
tracing::warn!("Available formats: {:#?}", formats);
|
||||
return None;
|
||||
};
|
||||
}
|
||||
|
||||
let buf_len = width * height * 4;
|
||||
if let Some(len) = len {
|
||||
if len != buf_len {
|
||||
return None;
|
||||
}
|
||||
} else if let Err(_err) = rustix::fs::ftruncate(&fd, buf_len as _) {
|
||||
};
|
||||
} else if let Err(_err) = rustix::fs::ftruncate(&fd, buf_len.into()) {
|
||||
}
|
||||
let pool = self
|
||||
.wl_shm
|
||||
.create_pool(fd.as_fd(), buf_len as i32, &self.qh, ());
|
||||
|
|
@ -439,7 +439,7 @@ impl CaptureData {
|
|||
&[],
|
||||
&self.qh,
|
||||
FrameData {
|
||||
frame_data: Default::default(),
|
||||
frame_data: ScreencopyFrameData::default(),
|
||||
session: capture_session.clone(),
|
||||
},
|
||||
);
|
||||
|
|
@ -484,7 +484,7 @@ impl AppData {
|
|||
handle: &ExtForeignToplevelHandleV1,
|
||||
) -> Option<ZcosmicToplevelHandleV1> {
|
||||
self.toplevel_info_state
|
||||
.info(&handle)?
|
||||
.info(handle)?
|
||||
.cosmic_toplevel
|
||||
.clone()
|
||||
}
|
||||
|
|
@ -498,8 +498,7 @@ impl AppData {
|
|||
capturer: self.screencopy_state.capturer().clone(),
|
||||
};
|
||||
std::thread::spawn(move || {
|
||||
use std::ffi::CStr;
|
||||
let name = unsafe { CStr::from_bytes_with_nul_unchecked(b"app-list-screencopy\0") };
|
||||
let name = c"app-list-screencopy";
|
||||
let Ok(fd) = rustix::fs::memfd_create(name, rustix::fs::MemfdFlags::CLOEXEC) else {
|
||||
tracing::error!("Failed to get fd for capture");
|
||||
return;
|
||||
|
|
@ -535,7 +534,7 @@ impl AppData {
|
|||
tx.unbounded_send(WaylandUpdate::Image(handle, WaylandImage::new(img)))
|
||||
{
|
||||
tracing::error!("Failed to send image event to subscription {err:?}");
|
||||
};
|
||||
}
|
||||
} else {
|
||||
tracing::error!("Failed to capture image");
|
||||
}
|
||||
|
|
@ -624,7 +623,7 @@ pub(crate) fn wayland_handler(
|
|||
.expect("Failed to insert wayland source.");
|
||||
|
||||
if handle
|
||||
.insert_source(rx, |event, _, state| match event {
|
||||
.insert_source(rx, |event, (), state| match event {
|
||||
calloop::channel::Event::Msg(req) => match req {
|
||||
WaylandRequest::Screencopy(handle) => {
|
||||
state.send_image(handle.clone());
|
||||
|
|
|
|||
|
|
@ -91,16 +91,13 @@ async fn start_listening(
|
|||
}
|
||||
guard.as_mut().unwrap()
|
||||
};
|
||||
match rx.next().await {
|
||||
Some(u) => {
|
||||
_ = output.send(u).await;
|
||||
State::Waiting
|
||||
}
|
||||
None => {
|
||||
_ = output.send(WaylandUpdate::Finished).await;
|
||||
tracing::error!("Wayland handler thread died");
|
||||
State::Finished
|
||||
}
|
||||
if let Some(u) = rx.next().await {
|
||||
_ = output.send(u).await;
|
||||
State::Waiting
|
||||
} else {
|
||||
_ = output.send(WaylandUpdate::Finished).await;
|
||||
tracing::error!("Wayland handler thread died");
|
||||
State::Finished
|
||||
}
|
||||
}
|
||||
State::Finished => iced::futures::future::pending().await,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue