Match outputs by name
This commit is contained in:
parent
7afd6451d2
commit
7e20f7f4b2
2 changed files with 21 additions and 9 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -34,11 +34,12 @@ struct Workspace {
|
|||
name: String,
|
||||
img: Option<iced::widget::image::Handle>,
|
||||
handle: zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
|
||||
output: wl_output::WlOutput,
|
||||
output_name: Option<String>,
|
||||
}
|
||||
|
||||
struct LayerSurface {
|
||||
output: wl_output::WlOutput,
|
||||
output_name: Option<String>,
|
||||
// Active workspace
|
||||
// windows in workspace
|
||||
// - for transitions, would need windows in more than one workspace
|
||||
|
|
@ -84,6 +85,7 @@ impl Application for App {
|
|||
id.clone(),
|
||||
LayerSurface {
|
||||
output: output.clone(),
|
||||
output_name: info.name,
|
||||
},
|
||||
);
|
||||
return get_layer_surface(SctkLayerSurfaceSettings {
|
||||
|
|
@ -119,11 +121,11 @@ impl Application for App {
|
|||
// XXX efficiency
|
||||
// XXX removal
|
||||
self.workspaces = Vec::new();
|
||||
for (output, workspace) in workspaces {
|
||||
for (output_name, workspace) in workspaces {
|
||||
self.workspaces.push(Workspace {
|
||||
name: workspace.name,
|
||||
handle: workspace.handle,
|
||||
output,
|
||||
output_name,
|
||||
img: None,
|
||||
});
|
||||
println!("add workspace");
|
||||
|
|
@ -183,8 +185,11 @@ impl Application for App {
|
|||
}
|
||||
|
||||
fn layer_surface<'a>(app: &'a App, surface: &'a LayerSurface) -> cosmic::Element<'a, Msg> {
|
||||
//workspaces_sidebar(app.workspaces.iter().filter(|i| &i.output == &surface.output))
|
||||
workspaces_sidebar(app.workspaces.iter())
|
||||
workspaces_sidebar(
|
||||
app.workspaces
|
||||
.iter()
|
||||
.filter(|i| &i.output_name == &surface.output_name),
|
||||
)
|
||||
}
|
||||
|
||||
fn workspace_sidebar_entry(workspace: &Workspace) -> cosmic::Element<Msg> {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ use std::{collections::HashMap, thread};
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum Event {
|
||||
Workspaces(Vec<(wl_output::WlOutput, cctk::workspace::Workspace)>),
|
||||
// XXX Output name rather than `WlOutput`
|
||||
Workspaces(Vec<(Option<String>, cctk::workspace::Workspace)>),
|
||||
WorkspaceCapture(
|
||||
zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
|
||||
image::Handle,
|
||||
|
|
@ -68,6 +69,7 @@ struct AppData {
|
|||
shm_state: ShmState,
|
||||
sender: mpsc::Sender<Event>,
|
||||
frames: HashMap<ObjectId, Frame>,
|
||||
output_names: HashMap<ObjectId, Option<String>>,
|
||||
}
|
||||
|
||||
impl ProvidesRegistryState for AppData {
|
||||
|
|
@ -94,8 +96,10 @@ impl OutputHandler for AppData {
|
|||
&mut self,
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
_output: wl_output::WlOutput,
|
||||
output: wl_output::WlOutput,
|
||||
) {
|
||||
let name = self.output_state.info(&output).unwrap().name;
|
||||
self.output_names.insert(output.id(), name);
|
||||
}
|
||||
|
||||
fn update_output(
|
||||
|
|
@ -110,8 +114,9 @@ impl OutputHandler for AppData {
|
|||
&mut self,
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
_output: wl_output::WlOutput,
|
||||
output: wl_output::WlOutput,
|
||||
) {
|
||||
self.output_names.remove(&output.id());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +162,8 @@ impl WorkspaceHandler for AppData {
|
|||
for group in self.workspace_state.workspace_groups() {
|
||||
for workspace in &group.workspaces {
|
||||
if let Some(output) = group.output.as_ref() {
|
||||
workspaces.push((output.clone(), workspace.clone()));
|
||||
let output_name = self.output_names.get(&output.id()).unwrap().clone();
|
||||
workspaces.push((output_name, workspace.clone()));
|
||||
|
||||
//println!("capture workspace");
|
||||
let frame = self.screencopy_state.screencopy_manager.capture_workspace(
|
||||
|
|
@ -294,6 +300,7 @@ fn start() -> mpsc::Receiver<Event> {
|
|||
shm_state: ShmState::bind(&globals, &qh).unwrap(),
|
||||
sender,
|
||||
frames: HashMap::new(),
|
||||
output_names: HashMap::new(),
|
||||
};
|
||||
|
||||
thread::spawn(move || loop {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue