Activate workspace only if capability is present

Potentially relevant on compositors not advertising this, or if a
compositor wanted to advertise `Activate` support for some but not all
workspaces. This will be more relevant with other capabilities.
This commit is contained in:
Ian Douglas Scott 2025-04-21 13:20:42 -07:00
parent 655621fde0
commit 7037cd3d05

View file

@ -2,6 +2,7 @@ use cosmic::{
cctk::{
cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1,
wayland_client::protocol::wl_output,
wayland_protocols::ext::workspace::v1::client::ext_workspace_handle_v1,
},
iced::{
self,
@ -207,13 +208,15 @@ fn workspace_item(
let is_active = workspace.is_active();
// TODO editable name?
widget::button::custom(content)
let mut button = widget::button::custom(content)
.selected(workspace.is_active())
.class(cosmic::theme::Button::Custom {
active: Box::new(move |_focused, theme| {
workspace_item_appearance(theme, is_active, is_drop_target)
}),
disabled: Box::new(|_theme| unreachable!()),
disabled: Box::new(move |theme| {
workspace_item_appearance(theme, is_active, is_drop_target)
}),
hovered: Box::new(move |_focused, theme| {
workspace_item_appearance(theme, is_active, true)
}),
@ -221,9 +224,15 @@ fn workspace_item(
workspace_item_appearance(theme, is_active, true)
}),
})
.on_press(Msg::ActivateWorkspace(workspace.handle().clone()))
.padding(8)
.into()
.padding(8);
if workspace
.info
.capabilities
.contains(ext_workspace_handle_v1::WorkspaceCapabilities::Activate)
{
button = button.on_press(Msg::ActivateWorkspace(workspace.handle().clone()));
}
button.into()
}
fn workspace_sidebar_entry<'a>(