diff options
| author | FluxTape <fluxtape.contact@gmail.com> | 2024-03-19 14:27:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-19 07:27:52 -0700 |
| commit | 23ac3d73232f307186212293713d6801d37cff2a (patch) | |
| tree | 68d4e721a3c3e88cae2157a27cd28944d1eb3ea4 /src/layout/workspace.rs | |
| parent | c3327d36da25f37e86eb8f89bd74f2a4bc1ea744 (diff) | |
| download | niri-23ac3d73232f307186212293713d6801d37cff2a.tar.gz niri-23ac3d73232f307186212293713d6801d37cff2a.tar.bz2 niri-23ac3d73232f307186212293713d6801d37cff2a.zip | |
Workspace back and forth (#253)
* implement workspace back and forth
* Make our own ID counter instead of SerialCounter, use a newtype
* Rename FocusWorkspaceBackAndForth to FocusWorkspacePrevious
* Add focus-workspace-previous to tests
* Don't special case in switch_workspace_previous
* Minor clean up
* Add switch_workspace_auto_back_and_forth to tests
* Skip animation on switch_workspace_previous
* Preserve previous_workspace_id on workspace movement
* Make Workspace::id private with a getter
Reduce the chance it gets overwritten.
* Add test for workspace ID uniqueness
* Update previous workspace ID upon moving workspace across monitors
---------
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 2c18b40e..e2a95ad4 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -18,6 +18,7 @@ use crate::animation::Animation; use crate::niri_render_elements; use crate::render_helpers::renderer::NiriRenderer; use crate::swipe_tracker::SwipeTracker; +use crate::utils::id::IdCounter; use crate::utils::output_size; /// Amount of touchpad movement to scroll the view for the width of one working area. @@ -76,11 +77,25 @@ pub struct Workspace<W: LayoutElement> { /// Configurable properties of the layout. pub options: Rc<Options>, + + /// Unique ID of this workspace. + id: WorkspaceId, } #[derive(Debug, Clone, PartialEq, Eq)] pub struct OutputId(String); +static WORKSPACE_ID_COUNTER: IdCounter = IdCounter::new(); + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct WorkspaceId(u32); + +impl WorkspaceId { + fn next() -> WorkspaceId { + WorkspaceId(WORKSPACE_ID_COUNTER.next()) + } +} + niri_render_elements! { WorkspaceRenderElement<R> => { Tile = TileRenderElement<R>, @@ -225,6 +240,7 @@ impl<W: LayoutElement> Workspace<W> { view_offset_adj: None, activate_prev_column_on_removal: None, options, + id: WorkspaceId::next(), } } @@ -240,9 +256,14 @@ impl<W: LayoutElement> Workspace<W> { view_offset_adj: None, activate_prev_column_on_removal: None, options, + id: WorkspaceId::next(), } } + 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); |
