mirror of
https://github.com/YaLTeR/niri.git
synced 2024-09-11 20:37:25 +03:00
Make Workspace::id private with a getter
Reduce the chance it gets overwritten.
This commit is contained in:
parent
73d3b7d6db
commit
84130e4e7b
@ -118,7 +118,7 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
.map(|s| s.current_idx())
|
||||
.unwrap_or(self.active_workspace_idx as f64);
|
||||
|
||||
self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id);
|
||||
self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id());
|
||||
|
||||
self.active_workspace_idx = idx;
|
||||
|
||||
@ -469,7 +469,7 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
|
||||
fn previous_workspace_idx(&self) -> Option<usize> {
|
||||
let id = self.previous_workspace_id?;
|
||||
self.workspaces.iter().position(|w| w.id == id)
|
||||
self.workspaces.iter().position(|w| w.id() == id)
|
||||
}
|
||||
|
||||
pub fn switch_workspace(&mut self, idx: usize) {
|
||||
@ -866,7 +866,7 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
gesture.center_idx as f64 + current_pos,
|
||||
);
|
||||
|
||||
self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id);
|
||||
self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id());
|
||||
|
||||
self.active_workspace_idx = new_idx;
|
||||
self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
|
||||
|
@ -79,7 +79,7 @@ pub struct Workspace<W: LayoutElement> {
|
||||
pub options: Rc<Options>,
|
||||
|
||||
/// Unique ID of this workspace.
|
||||
pub id: WorkspaceId,
|
||||
id: WorkspaceId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@ -260,6 +260,10 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(&self) -> WorkspaceId {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) {
|
||||
if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {
|
||||
anim.set_current_time(current_time);
|
||||
|
Loading…
Reference in New Issue
Block a user