Pass toplevel_capabilities from backend to frontend

This commit is contained in:
Ian Douglas Scott 2025-04-21 14:02:36 -07:00
parent fc784af1b9
commit 77ff4e62e9
4 changed files with 28 additions and 2 deletions

View file

@ -5,6 +5,7 @@ use cosmic::{
cctk::{ cctk::{
cosmic_protocols::{ cosmic_protocols::{
toplevel_info::v1::client::zcosmic_toplevel_handle_v1, toplevel_info::v1::client::zcosmic_toplevel_handle_v1,
toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
workspace::v2::client::zcosmic_workspace_handle_v2, workspace::v2::client::zcosmic_workspace_handle_v2,
}, },
wayland_client::{ wayland_client::{
@ -219,6 +220,11 @@ fn start(_conn: Connection) -> mpsc::Receiver<Event> {
outputs: Vec::new(), outputs: Vec::new(),
workspaces: Vec::new(), workspaces: Vec::new(),
}; };
app_data.send_event(Event::ToplevelCapabilities(vec![
zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1::Close,
zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1::Activate,
zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1::MoveToWorkspace,
]));
app_data.send_event(Event::CmdSender(cmd_sender)); app_data.send_event(Event::CmdSender(cmd_sender));
loop { loop {
event_loop.dispatch(None, &mut app_data).unwrap(); event_loop.dispatch(None, &mut app_data).unwrap();

View file

@ -8,7 +8,10 @@
//! backend for testing without any special protocols. //! backend for testing without any special protocols.
use cosmic::{ use cosmic::{
cctk::wayland_client::protocol::wl_output, cctk::{
cosmic_protocols::toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
wayland_client::protocol::wl_output,
},
iced_winit::platform_specific::wayland::subsurface_widget::SubsurfaceBuffer, iced_winit::platform_specific::wayland::subsurface_widget::SubsurfaceBuffer,
}; };
use std::collections::HashSet; use std::collections::HashSet;
@ -62,6 +65,9 @@ pub enum Event {
UpdateToplevel(ExtForeignToplevelHandleV1, ToplevelInfo), UpdateToplevel(ExtForeignToplevelHandleV1, ToplevelInfo),
CloseToplevel(ExtForeignToplevelHandleV1), CloseToplevel(ExtForeignToplevelHandleV1),
ToplevelCapture(ExtForeignToplevelHandleV1, CaptureImage), ToplevelCapture(ExtForeignToplevelHandleV1, CaptureImage),
ToplevelCapabilities(
Vec<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>,
),
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -58,10 +58,18 @@ impl ToplevelManagerHandler for AppData {
&mut self, &mut self,
_conn: &Connection, _conn: &Connection,
_qh: &QueueHandle<Self>, _qh: &QueueHandle<Self>,
_capabilities: Vec< capabilities: Vec<
WEnum<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>, WEnum<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>,
>, >,
) { ) {
let capabilities = capabilities
.into_iter()
.filter_map(|i| match i {
WEnum::Value(value) => Some(value),
WEnum::Unknown(_) => None,
})
.collect();
self.send_event(Event::ToplevelCapabilities(capabilities));
} }
} }

View file

@ -4,6 +4,7 @@
#![allow(clippy::single_match)] #![allow(clippy::single_match)]
use cctk::{ use cctk::{
cosmic_protocols::toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
sctk::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer}, sctk::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer},
wayland_client::{protocol::wl_output, Connection, Proxy}, wayland_client::{protocol::wl_output, Connection, Proxy},
wayland_protocols::ext::workspace::v1::client::ext_workspace_handle_v1, wayland_protocols::ext::workspace::v1::client::ext_workspace_handle_v1,
@ -169,6 +170,8 @@ struct App {
outputs: Vec<Output>, outputs: Vec<Output>,
workspaces: Vec<Workspace>, workspaces: Vec<Workspace>,
toplevels: Vec<Toplevel>, toplevels: Vec<Toplevel>,
toplevel_capabilities:
Vec<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>,
conn: Option<Connection>, conn: Option<Connection>,
visible: bool, visible: bool,
wayland_cmd_sender: Option<calloop::channel::Sender<backend::Cmd>>, wayland_cmd_sender: Option<calloop::channel::Sender<backend::Cmd>>,
@ -463,6 +466,9 @@ impl Application for App {
toplevel.img = Some(image); toplevel.img = Some(image);
} }
} }
backend::Event::ToplevelCapabilities(capabilities) => {
self.toplevel_capabilities = capabilities;
}
} }
} }
Msg::Close => { Msg::Close => {