git.lucas.co / cce-window-manager
window management library
git clone https://git.lucas.co/cce-window-manager.git

commitc3df1ec87e1acf9a184812ef6fc551af457f2cc3
parent8a66d60c60
authorLucas Galante <[email protected]>
date2026-08-10 10:38
refactor: remove the viewport tag actions

View1-4 / SetViewport1-4, their anchor points, action names and the
view/set_viewport dispatchers are gone with the viewport-tag feature.
The camera-sense viewport (the visible screen rect) is untouched.

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/actions.rs  | 46 ----------------------------------------------
 src/api.rs      | 24 ------------------------
 src/bindings.rs |  4 +---
 3 files changed, 1 insertion(+), 73 deletions(-)

diff --git a/src/actions.rs b/src/actions.rs
index 83f2cde..5aec9c8 100644
--- a/src/actions.rs
+++ b/src/actions.rs
@@ -20,11 +20,6 @@ impl Policy for DefaultPolicy {
             Action::PanLeft | Action::PanRight | Action::PanUp | Action::PanDown => {
                 pan_step(ctx, action)
             }
-            Action::View1 | Action::View2 | Action::View3 | Action::View4 => view(ctx, action),
-            Action::SetViewport1
-            | Action::SetViewport2
-            | Action::SetViewport3
-            | Action::SetViewport4 => set_viewport(ctx, action),
             Action::Expose => expose(ctx),
             Action::Close => close(ctx),
             Action::Minimize => minimize(ctx),
@@ -54,16 +49,6 @@ impl Policy for DefaultPolicy {
     }
 }
 
-/// The four fixed viewport anchors shared by View1-4 and SetViewport1-4.
-fn anchor_point(action: Action) -> (f64, f64) {
-    match action {
-        Action::View1 | Action::SetViewport1 => (0.0, 0.0),
-        Action::View2 | Action::SetViewport2 => (2000.0, 0.0),
-        Action::View3 | Action::SetViewport3 => (0.0, 2000.0),
-        _ => (2000.0, 2000.0),
-    }
-}
-
 fn window(ctx: &ActionCtx, id: WindowId) -> Option<&crate::api::ActionWindow> {
     ctx.windows.iter().find(|w| w.id == id)
 }
@@ -111,26 +96,6 @@ fn pan_step(ctx: &ActionCtx, action: Action) -> Vec<Command> {
     vec![Command::PanTo { x, y }]
 }
 
-/// Jump the viewport to one of the four fixed anchors, keeping the zoom.
-fn view(ctx: &ActionCtx, action: Action) -> Vec<Command> {
-    let (tx, ty) = anchor_point(action);
-    let cam = camera::center_on(tx, ty, ctx.viewport_w, ctx.viewport_h, ctx.camera.zoom);
-    vec![Command::SetCamera { camera: cam, overview: None, animate: false }, Command::Relayout]
-}
-
-/// Send the focused window to one of the four fixed anchors (centered on
-/// it). Note the legacy quirk kept as-is: the window extent is output px,
-/// halved without dividing by zoom.
-fn set_viewport(ctx: &ActionCtx, action: Action) -> Vec<Command> {
-    let (tx, ty) = anchor_point(action);
-    let Some(id) = ctx.focused else { return Vec::new() };
-    let Some(win) = window(ctx, id) else { return Vec::new() };
-    vec![
-        Command::MoveWindow { id, x: tx - win.w / 2.0, y: ty - win.h / 2.0 },
-        Command::Relayout,
-    ]
-}
-
 /// Toggle overview. Exit re-centers at zoom 1 — on the hovered window
 /// (focusing it) when there is one, else on the virtual point under the
 /// cursor — in the cursor's output. Enter fits the bounding box of all
@@ -620,17 +585,6 @@ mod tests {
         assert_eq!(x, Some(1024.0));
     }
 
-    #[test]
-    fn set_viewport_needs_focus_and_centers_it() {
-        assert!(dispatch(&ctx(), Action::SetViewport2).is_empty());
-        let mut c = ctx();
-        c.focused = Some(wid(7));
-        c.windows.push(win(7, 0.0, 0.0, 400.0, 300.0));
-        let cmds = dispatch(&c, Action::SetViewport2);
-        assert_eq!(cmds[0], Command::MoveWindow { id: wid(7), x: 1800.0, y: -150.0 });
-        assert_eq!(cmds[1], Command::Relayout);
-    }
-
     #[test]
     fn expose_enter_fits_eligible_windows_only() {
         let mut c = ctx();
diff --git a/src/api.rs b/src/api.rs
index cbab97f..c4f0584 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -69,14 +69,6 @@ pub enum Action {
     LayoutNext,
     ModeNext,
     ModeNextShared,
-    View1,
-    View2,
-    View3,
-    View4,
-    SetViewport1,
-    SetViewport2,
-    SetViewport3,
-    SetViewport4,
     Expose,
     Minimize,
     OverlayLeft,
@@ -122,14 +114,6 @@ impl Action {
             Action::LayoutNext => "layout_next",
             Action::ModeNext => "mode_next",
             Action::ModeNextShared => "mode_next_shared",
-            Action::View1 => "view_1",
-            Action::View2 => "view_2",
-            Action::View3 => "view_3",
-            Action::View4 => "view_4",
-            Action::SetViewport1 => "set_viewport_1",
-            Action::SetViewport2 => "set_viewport_2",
-            Action::SetViewport3 => "set_viewport_3",
-            Action::SetViewport4 => "set_viewport_4",
             Action::Expose => "expose",
             Action::Minimize => "minimize",
             Action::OverlayLeft => "overlay_left",
@@ -175,14 +159,6 @@ impl Action {
             "layout_next" => Action::LayoutNext,
             "mode_next" => Action::ModeNext,
             "mode_next_shared" => Action::ModeNextShared,
-            "view_1" => Action::View1,
-            "view_2" => Action::View2,
-            "view_3" => Action::View3,
-            "view_4" => Action::View4,
-            "set_viewport_1" => Action::SetViewport1,
-            "set_viewport_2" => Action::SetViewport2,
-            "set_viewport_3" => Action::SetViewport3,
-            "set_viewport_4" => Action::SetViewport4,
             "expose" | "toggle_overview" => Action::Expose,
             "minimize" => Action::Minimize,
             "overlay_left" => Action::OverlayLeft,
diff --git a/src/bindings.rs b/src/bindings.rs
index a318ed0..ff52e6a 100644
--- a/src/bindings.rs
+++ b/src/bindings.rs
@@ -198,9 +198,7 @@ mod tests {
             Action::WindowSwitcher, Action::WindowSwitcherPrev,
             Action::Move, Action::Resize, Action::Exit, Action::Reload,
             Action::Fullscreen, Action::LayoutNext, Action::ModeNext,
-            Action::ModeNextShared, Action::View1, Action::View2,
-            Action::View3, Action::View4, Action::SetViewport1,
-            Action::SetViewport2, Action::SetViewport3, Action::SetViewport4,
+            Action::ModeNextShared,
             Action::Expose, Action::Minimize, Action::OverlayLeft,
             Action::OverlayRight, Action::ZoomIn, Action::ZoomOut,
             Action::ZoomReset, Action::PanLeft, Action::PanRight,