Skip to content

Commit

Permalink
Make WorkspaceId inner field private
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Sep 2, 2024
1 parent 52265e2 commit 446a9f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/ipc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ fn make_ipc_window(mapped: &Mapped, workspace_id: Option<WorkspaceId>) -> niri_i
id: mapped.id().get(),
title: role.title.clone(),
app_id: role.app_id.clone(),
workspace_id: workspace_id.map(|id| u64::from(id.0)),
workspace_id: workspace_id.map(|id| id.get()),
is_focused: mapped.is_focused(),
}
})
Expand Down Expand Up @@ -424,13 +424,13 @@ impl State {

let mut events = Vec::new();
let layout = &self.niri.layout;
let focused_ws_id = layout.active_workspace().map(|ws| u64::from(ws.id().0));
let focused_ws_id = layout.active_workspace().map(|ws| ws.id().get());

// Check for workspace changes.
let mut seen = HashSet::new();
let mut need_workspaces_changed = false;
for (mon, ws_idx, ws) in layout.workspaces() {
let id = u64::from(ws.id().0);
let id = ws.id().get();
seen.insert(id);

let Some(ipc_ws) = state.workspaces.get(&id) else {
Expand Down Expand Up @@ -482,7 +482,7 @@ impl State {
let workspaces = layout
.workspaces()
.map(|(mon, ws_idx, ws)| {
let id = u64::from(ws.id().0);
let id = ws.id().get();
Workspace {
id,
idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX),
Expand Down Expand Up @@ -534,7 +534,7 @@ impl State {
return;
};

let workspace_id = Some(u64::from(ws_id.0));
let workspace_id = Some(ws_id.get());
let mut changed = ipc_win.workspace_id != workspace_id;

let wl_surface = mapped.toplevel().wl_surface();
Expand Down
6 changes: 5 additions & 1 deletion src/layout/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ pub struct OutputId(String);
static WORKSPACE_ID_COUNTER: IdCounter = IdCounter::new();

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WorkspaceId(pub u32);
pub struct WorkspaceId(u32);

impl WorkspaceId {
fn next() -> WorkspaceId {
WorkspaceId(WORKSPACE_ID_COUNTER.next())
}

pub fn get(self) -> u64 {
u64::from(self.0)
}
}

niri_render_elements! {
Expand Down

0 comments on commit 446a9f1

Please sign in to comment.