forge
Explore
Log in

Don't you dare go Hollow

Make WorkspaceId inner field private

Browse files at this commit

446a9f1e06a9218c16c3d839083fcd4d3ac91181Ivan MolodetskikhParent: 52265e2
src/ipc/server.rsmodified+5 -5
@@ -378,7 +378,7 @@ fn make_ipc_window(mapped: &Mapped, workspace_id: Option<WorkspaceId>) -> niri_i
378 id: mapped.id().get(),378 id: mapped.id().get(),
379 title: role.title.clone(),379 title: role.title.clone(),
380 app_id: role.app_id.clone(),380 app_id: role.app_id.clone(),
381- workspace_id: workspace_id.map(|id| u64::from(id.0)),381+ workspace_id: workspace_id.map(|id| id.get()),
382 is_focused: mapped.is_focused(),382 is_focused: mapped.is_focused(),
383 }383 }
384 })384 })
@@ -424,13 +424,13 @@ impl State {
424 424
425 let mut events = Vec::new();425 let mut events = Vec::new();
426 let layout = &self.niri.layout;426 let layout = &self.niri.layout;
427- let focused_ws_id = layout.active_workspace().map(|ws| u64::from(ws.id().0));427+ let focused_ws_id = layout.active_workspace().map(|ws| ws.id().get());
428 428
429 // Check for workspace changes.429 // Check for workspace changes.
430 let mut seen = HashSet::new();430 let mut seen = HashSet::new();
431 let mut need_workspaces_changed = false;431 let mut need_workspaces_changed = false;
432 for (mon, ws_idx, ws) in layout.workspaces() {432 for (mon, ws_idx, ws) in layout.workspaces() {
433- let id = u64::from(ws.id().0);433+ let id = ws.id().get();
434 seen.insert(id);434 seen.insert(id);
435 435
436 let Some(ipc_ws) = state.workspaces.get(&id) else {436 let Some(ipc_ws) = state.workspaces.get(&id) else {
@@ -482,7 +482,7 @@ impl State {
482 let workspaces = layout482 let workspaces = layout
483 .workspaces()483 .workspaces()
484 .map(|(mon, ws_idx, ws)| {484 .map(|(mon, ws_idx, ws)| {
485- let id = u64::from(ws.id().0);485+ let id = ws.id().get();
486 Workspace {486 Workspace {
487 id,487 id,
488 idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX),488 idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX),
@@ -534,7 +534,7 @@ impl State {
534 return;534 return;
535 };535 };
536 536
537- let workspace_id = Some(u64::from(ws_id.0));537+ let workspace_id = Some(ws_id.get());
538 let mut changed = ipc_win.workspace_id != workspace_id;538 let mut changed = ipc_win.workspace_id != workspace_id;
539 539
540 let wl_surface = mapped.toplevel().wl_surface();540 let wl_surface = mapped.toplevel().wl_surface();
src/layout/workspace.rsmodified+5 -1
@@ -123,12 +123,16 @@ pub struct OutputId(String);
123 static WORKSPACE_ID_COUNTER: IdCounter = IdCounter::new();123 static WORKSPACE_ID_COUNTER: IdCounter = IdCounter::new();
124 124
125 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]125 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
126-pub struct WorkspaceId(pub u32);126+pub struct WorkspaceId(u32);
127 127
128 impl WorkspaceId {128 impl WorkspaceId {
129 fn next() -> WorkspaceId {129 fn next() -> WorkspaceId {
130 WorkspaceId(WORKSPACE_ID_COUNTER.next())130 WorkspaceId(WORKSPACE_ID_COUNTER.next())
131 }131 }
132+
133+ pub fn get(self) -> u64 {
134+ u64::from(self.0)
135+ }
132 }136 }
133 137
134 niri_render_elements! {138 niri_render_elements! {