implement specifying wallpaper by workspace number
This commit is contained in:
parent
a41da912d7
commit
442f2410c3
8 changed files with 28 additions and 6 deletions
|
@ -187,6 +187,7 @@ impl ConnectionTask {
|
||||||
.send(WorkspaceVisible {
|
.send(WorkspaceVisible {
|
||||||
output: workspace.output,
|
output: workspace.output,
|
||||||
workspace_name: workspace.workspace_name,
|
workspace_name: workspace.workspace_name,
|
||||||
|
workspace_number: workspace.workspace_number,
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -202,6 +203,7 @@ impl ConnectionTask {
|
||||||
.send(WorkspaceVisible {
|
.send(WorkspaceVisible {
|
||||||
output: workspace.output,
|
output: workspace.output,
|
||||||
workspace_name: workspace.workspace_name,
|
workspace_name: workspace.workspace_name,
|
||||||
|
workspace_number: workspace.workspace_number
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -214,6 +216,7 @@ impl ConnectionTask {
|
||||||
pub struct WorkspaceVisible {
|
pub struct WorkspaceVisible {
|
||||||
pub output: String,
|
pub output: String,
|
||||||
pub workspace_name: String,
|
pub workspace_name: String,
|
||||||
|
pub workspace_number: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
|
|
@ -70,6 +70,7 @@ impl CompositorInterface for HyprlandConnectionTask {
|
||||||
output: active_monitor.clone(),
|
output: active_monitor.clone(),
|
||||||
workspace_name: String::from_utf8(event_data.to_vec())
|
workspace_name: String::from_utf8(event_data.to_vec())
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
workspace_number: -1,
|
||||||
});
|
});
|
||||||
} else if event_name == b"focusedmon" {
|
} else if event_name == b"focusedmon" {
|
||||||
let comma_pos = event_data.iter()
|
let comma_pos = event_data.iter()
|
||||||
|
@ -135,6 +136,7 @@ fn current_state() -> CurrentState {
|
||||||
visible_workspaces.push(WorkspaceVisible {
|
visible_workspaces.push(WorkspaceVisible {
|
||||||
output: monitor.name,
|
output: monitor.name,
|
||||||
workspace_name: monitor.active_workspace.name,
|
workspace_name: monitor.active_workspace.name,
|
||||||
|
workspace_number: -1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
CurrentState { active_monitor, visible_workspaces }
|
CurrentState { active_monitor, visible_workspaces }
|
||||||
|
|
|
@ -21,6 +21,7 @@ impl CompositorInterface for NiriConnectionTask {
|
||||||
output: workspace.output.unwrap_or_default(),
|
output: workspace.output.unwrap_or_default(),
|
||||||
workspace_name: workspace.name
|
workspace_name: workspace.name
|
||||||
.unwrap_or_else(|| format!("{}", workspace.idx)),
|
.unwrap_or_else(|| format!("{}", workspace.idx)),
|
||||||
|
workspace_number: workspace.idx.into(),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -52,8 +53,9 @@ fn find_workspace(workspaces: &[Workspace], id: u64) -> WorkspaceVisible {
|
||||||
.unwrap_or_else(|| panic!("Unknown niri workspace id {id}"));
|
.unwrap_or_else(|| panic!("Unknown niri workspace id {id}"));
|
||||||
let workspace_name = workspace.name.clone()
|
let workspace_name = workspace.name.clone()
|
||||||
.unwrap_or_else(|| format!("{}", workspace.idx));
|
.unwrap_or_else(|| format!("{}", workspace.idx));
|
||||||
|
let workspace_number: i32 = workspace.idx.into();
|
||||||
let output = workspace.output.clone().unwrap_or_default();
|
let output = workspace.output.clone().unwrap_or_default();
|
||||||
WorkspaceVisible { output, workspace_name }
|
WorkspaceVisible { output, workspace_name, workspace_number }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_event_stream() -> impl FnMut() -> Result<Event, io::Error> {
|
fn request_event_stream() -> impl FnMut() -> Result<Event, io::Error> {
|
||||||
|
|
|
@ -21,6 +21,7 @@ impl CompositorInterface for NiriConnectionTask {
|
||||||
output: workspace.output.unwrap_or_default(),
|
output: workspace.output.unwrap_or_default(),
|
||||||
workspace_name: workspace.name
|
workspace_name: workspace.name
|
||||||
.unwrap_or_else(|| format!("{}", workspace.idx)),
|
.unwrap_or_else(|| format!("{}", workspace.idx)),
|
||||||
|
workspace_number: workspace.idx.into(),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -52,8 +53,9 @@ fn find_workspace(workspaces: &[Workspace], id: u64) -> WorkspaceVisible {
|
||||||
.unwrap_or_else(|| panic!("Unknown niri workspace id {id}"));
|
.unwrap_or_else(|| panic!("Unknown niri workspace id {id}"));
|
||||||
let workspace_name = workspace.name.clone()
|
let workspace_name = workspace.name.clone()
|
||||||
.unwrap_or_else(|| format!("{}", workspace.idx));
|
.unwrap_or_else(|| format!("{}", workspace.idx));
|
||||||
|
let workspace_number: i32 = workspace.idx.into();
|
||||||
let output = workspace.output.clone().unwrap_or_default();
|
let output = workspace.output.clone().unwrap_or_default();
|
||||||
WorkspaceVisible { output, workspace_name }
|
WorkspaceVisible { output, workspace_name, workspace_number }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_event_stream() -> impl FnMut() -> Result<Event, io::Error> {
|
fn request_event_stream() -> impl FnMut() -> Result<Event, io::Error> {
|
||||||
|
|
|
@ -25,6 +25,7 @@ impl CompositorInterface for SwayConnectionTask {
|
||||||
.map(|workspace| WorkspaceVisible {
|
.map(|workspace| WorkspaceVisible {
|
||||||
output: workspace.output,
|
output: workspace.output,
|
||||||
workspace_name: workspace.name,
|
workspace_name: workspace.name,
|
||||||
|
workspace_number: workspace.num,
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -42,6 +43,7 @@ impl CompositorInterface for SwayConnectionTask {
|
||||||
event_sender.send(WorkspaceVisible {
|
event_sender.send(WorkspaceVisible {
|
||||||
output: current_workspace.output.unwrap(),
|
output: current_workspace.output.unwrap(),
|
||||||
workspace_name: current_workspace.name.unwrap(),
|
workspace_name: current_workspace.name.unwrap(),
|
||||||
|
workspace_number: current_workspace.num.unwrap(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ pub enum ColorTransform {
|
||||||
pub struct WallpaperFile {
|
pub struct WallpaperFile {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub workspace: String,
|
pub workspace: String,
|
||||||
|
pub workspace_number: i32,
|
||||||
pub canon_path: PathBuf,
|
pub canon_path: PathBuf,
|
||||||
pub canon_modified: u128,
|
pub canon_modified: u128,
|
||||||
}
|
}
|
||||||
|
@ -49,6 +50,7 @@ pub fn output_wallpaper_files(
|
||||||
}
|
}
|
||||||
let workspace = path.file_stem().unwrap()
|
let workspace = path.file_stem().unwrap()
|
||||||
.to_string_lossy().into_owned();
|
.to_string_lossy().into_owned();
|
||||||
|
let workspace_number: i32 = workspace.parse().unwrap_or_default();
|
||||||
let canon_path = match path.canonicalize() {
|
let canon_path = match path.canonicalize() {
|
||||||
Ok(canon_path) => canon_path,
|
Ok(canon_path) => canon_path,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -66,7 +68,7 @@ pub fn output_wallpaper_files(
|
||||||
let canon_modified = canon_metadata.modified().unwrap()
|
let canon_modified = canon_metadata.modified().unwrap()
|
||||||
.duration_since(UNIX_EPOCH).unwrap()
|
.duration_since(UNIX_EPOCH).unwrap()
|
||||||
.as_nanos();
|
.as_nanos();
|
||||||
ret.push(WallpaperFile { path, workspace, canon_path, canon_modified });
|
ret.push(WallpaperFile { path, workspace, workspace_number, canon_path, canon_modified });
|
||||||
}
|
}
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,7 +290,7 @@ fn handle_sway_event(
|
||||||
if let Some(affected_bg_layer) = state.background_layers.iter_mut()
|
if let Some(affected_bg_layer) = state.background_layers.iter_mut()
|
||||||
.find(|bg_layer| bg_layer.output_name == workspace.output)
|
.find(|bg_layer| bg_layer.output_name == workspace.output)
|
||||||
{
|
{
|
||||||
affected_bg_layer.draw_workspace_bg(&workspace.workspace_name);
|
affected_bg_layer.draw_workspace_bg(&workspace.workspace_name, workspace.workspace_number);
|
||||||
} else {
|
} else {
|
||||||
error!(
|
error!(
|
||||||
"Workspace '{}' is on an unknown output '{}', \
|
"Workspace '{}' is on an unknown output '{}', \
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl Drop for BackgroundLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BackgroundLayer {
|
impl BackgroundLayer {
|
||||||
pub fn draw_workspace_bg(&mut self, workspace_name: &str) {
|
pub fn draw_workspace_bg(&mut self, workspace_name: &str, workspace_number: i32) {
|
||||||
if !self.configured {
|
if !self.configured {
|
||||||
error!("Cannot draw wallpaper image on the not yet configured \
|
error!("Cannot draw wallpaper image on the not yet configured \
|
||||||
layer for output: {}", self.output_name);
|
layer for output: {}", self.output_name);
|
||||||
|
@ -94,6 +94,9 @@ impl BackgroundLayer {
|
||||||
|
|
||||||
let Some(workspace_bg) = self.workspace_backgrounds.iter()
|
let Some(workspace_bg) = self.workspace_backgrounds.iter()
|
||||||
.find(|workspace_bg| workspace_bg.workspace_name == workspace_name)
|
.find(|workspace_bg| workspace_bg.workspace_name == workspace_name)
|
||||||
|
.or_else(|| self.workspace_backgrounds.iter()
|
||||||
|
.find(|workspace_bg| workspace_bg.workspace_number == workspace_number)
|
||||||
|
)
|
||||||
.or_else(|| self.workspace_backgrounds.iter()
|
.or_else(|| self.workspace_backgrounds.iter()
|
||||||
.find(|workspace_bg| workspace_bg.workspace_name == "_default")
|
.find(|workspace_bg| workspace_bg.workspace_name == "_default")
|
||||||
)
|
)
|
||||||
|
@ -147,6 +150,7 @@ impl BackgroundLayer {
|
||||||
|
|
||||||
struct WorkspaceBackground {
|
struct WorkspaceBackground {
|
||||||
workspace_name: String,
|
workspace_name: String,
|
||||||
|
workspace_number: i32,
|
||||||
wallpaper: Rc<RefCell<Wallpaper>>,
|
wallpaper: Rc<RefCell<Wallpaper>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +313,8 @@ impl DmabufHandler for State {
|
||||||
if let Some(queued) = queued_weak.upgrade() {
|
if let Some(queued) = queued_weak.upgrade() {
|
||||||
if Rc::ptr_eq(&queued, wallpaper) {
|
if Rc::ptr_eq(&queued, wallpaper) {
|
||||||
let name = workspace_bg.workspace_name.clone();
|
let name = workspace_bg.workspace_name.clone();
|
||||||
bg_layer.draw_workspace_bg(&name);
|
let number = workspace_bg.workspace_number;
|
||||||
|
bg_layer.draw_workspace_bg(&name, number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1004,6 +1009,7 @@ fn load_wallpapers(
|
||||||
) {
|
) {
|
||||||
workspace_backgrounds.push(WorkspaceBackground {
|
workspace_backgrounds.push(WorkspaceBackground {
|
||||||
workspace_name: wallpaper_file.workspace,
|
workspace_name: wallpaper_file.workspace,
|
||||||
|
workspace_number: wallpaper_file.workspace_number,
|
||||||
wallpaper,
|
wallpaper,
|
||||||
});
|
});
|
||||||
reused_count += 1;
|
reused_count += 1;
|
||||||
|
@ -1019,6 +1025,7 @@ fn load_wallpapers(
|
||||||
) {
|
) {
|
||||||
workspace_backgrounds.push(WorkspaceBackground {
|
workspace_backgrounds.push(WorkspaceBackground {
|
||||||
workspace_name: wallpaper_file.workspace,
|
workspace_name: wallpaper_file.workspace,
|
||||||
|
workspace_number: wallpaper_file.workspace_number,
|
||||||
wallpaper,
|
wallpaper,
|
||||||
});
|
});
|
||||||
reused_count += 1;
|
reused_count += 1;
|
||||||
|
@ -1058,6 +1065,7 @@ fn load_wallpapers(
|
||||||
);
|
);
|
||||||
workspace_backgrounds.push(WorkspaceBackground {
|
workspace_backgrounds.push(WorkspaceBackground {
|
||||||
workspace_name: wallpaper_file.workspace,
|
workspace_name: wallpaper_file.workspace,
|
||||||
|
workspace_number: wallpaper_file.workspace_number,
|
||||||
wallpaper,
|
wallpaper,
|
||||||
});
|
});
|
||||||
loaded_count += 1;
|
loaded_count += 1;
|
||||||
|
@ -1108,6 +1116,7 @@ fn load_wallpapers(
|
||||||
);
|
);
|
||||||
workspace_backgrounds.push(WorkspaceBackground {
|
workspace_backgrounds.push(WorkspaceBackground {
|
||||||
workspace_name: wallpaper_file.workspace,
|
workspace_name: wallpaper_file.workspace,
|
||||||
|
workspace_number: wallpaper_file.workspace_number,
|
||||||
wallpaper: Rc::new(RefCell::new(Wallpaper {
|
wallpaper: Rc::new(RefCell::new(Wallpaper {
|
||||||
wl_buffer: Some(wl_buffer),
|
wl_buffer: Some(wl_buffer),
|
||||||
// active_count: 0,
|
// active_count: 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue