git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit0ef1ee235ba0bacaac7e537bd16b7140516f61ed
parent60c098626e
authorLucas Galante <[email protected]>
date2026-06-24 22:45
Rename tags to viewport and remove unused tags code

 src/cce_ctl.rs               |  5 ++---
 src/server/config.rs         | 43 +++++++++++----------------------------
 src/server/status_server.rs  | 16 +++++++--------
 src/server/window.rs         |  3 ---
 src/server/window_manager.rs | 48 +++++++++++++-------------------------------
 5 files changed, 36 insertions(+), 79 deletions(-)

diff --git a/src/cce_ctl.rs b/src/cce_ctl.rs
index 70dab6f..568fd4e 100644
--- a/src/cce_ctl.rs
+++ b/src/cce_ctl.rs
@@ -33,7 +33,6 @@ fn usage(name: &str, to_stderr: bool) {
     print("commands:");
     print("  layout <gap|gap_top|gap_left|gap_right|gap_bottom|offset|grid_gap|bar_height|border_width|fullscreen_border_width|border_color> <value>");
     print("  view <1-4>");
-    print("  toggle <1-4>");
     print("  close");
     print("  minimize");
     print("  focus-next");
@@ -51,9 +50,9 @@ fn usage(name: &str, to_stderr: bool) {
     print("  bind <mods> <keysym> <action> [args...]");
     print("  pbind <mods> <button> <action>");
     print("  retile");
-    print("  set-tag <1-4>");
+    print("  set-viewport <1-4>");
     print("  mode <cascade|grid|fullscreen|floating|popup> <app_id> [title]");
-    print("  tag-layout <1-4> <cascade|grid|fullscreen|floating|popup>");
+    print("  viewport-layout <1-4> <cascade|grid|fullscreen|floating|popup>");
     print("  pointer-location");
     print("  pointer-move-to <x> <y>");
     print("  pointer-move-by <dx> <dy>");
diff --git a/src/server/config.rs b/src/server/config.rs
index 98b9497..cfba380 100644
--- a/src/server/config.rs
+++ b/src/server/config.rs
@@ -115,14 +115,10 @@ pub enum Action {
     View2,
     View3,
     View4,
-    Toggle1,
-    Toggle2,
-    Toggle3,
-    Toggle4,
-    SetTag1,
-    SetTag2,
-    SetTag3,
-    SetTag4,
+    SetViewport1,
+    SetViewport2,
+    SetViewport3,
+    SetViewport4,
     Expose,
     Minimize,
     PinnedLeft,
@@ -513,26 +509,11 @@ pub fn parse_action(s: &str) -> Action {
             }
         }
         Action::None
-    } else if s.starts_with("toggle") {
-        let rest = &s[6..];
-        let tag_str = rest
-            .strip_prefix('-')
-            .or_else(|| rest.strip_prefix(' '))
-            .unwrap_or(rest);
-        if let Ok(tag) = tag_str.parse::<i32>() {
-            if tag >= 1 && tag <= 4 {
-                return match tag {
-                    1 => Action::Toggle1,
-                    2 => Action::Toggle2,
-                    3 => Action::Toggle3,
-                    4 => Action::Toggle4,
-                    _ => Action::None,
-                };
-            }
-        }
+    } else if s == "toggle" {
         Action::Toggle
-    } else if s.starts_with("set-tag") {
-        let rest = &s[7..];
+    } else if s.starts_with("set-viewport") || s.starts_with("set-tag") {
+        let is_viewport = s.starts_with("set-viewport");
+        let rest = if is_viewport { &s[12..] } else { &s[7..] };
         let tag_str = rest
             .strip_prefix('-')
             .or_else(|| rest.strip_prefix(' '))
@@ -540,10 +521,10 @@ pub fn parse_action(s: &str) -> Action {
         if let Ok(tag) = tag_str.parse::<i32>() {
             if tag >= 1 && tag <= 4 {
                 return match tag {
-                    1 => Action::SetTag1,
-                    2 => Action::SetTag2,
-                    3 => Action::SetTag3,
-                    4 => Action::SetTag4,
+                    1 => Action::SetViewport1,
+                    2 => Action::SetViewport2,
+                    3 => Action::SetViewport3,
+                    4 => Action::SetViewport4,
                     _ => Action::None,
                 };
             }
diff --git a/src/server/status_server.rs b/src/server/status_server.rs
index 1541db3..091c878 100644
--- a/src/server/status_server.rs
+++ b/src/server/status_server.rs
@@ -2,7 +2,7 @@
 //
 // Runs in a dedicated thread. cce-status-interface connects to
 // /tmp/cce-status-{WAYLAND_DISPLAY}.sock, sends a subscription line
-// ("tags", "layout", or "title"), and receives JSON lines whenever the status changes.
+// ("viewport", "layout", or "title"), and receives JSON lines whenever the status changes.
 //
 // The main loop sends updates through an mpsc channel. The server thread
 // owns the socket and handles all I/O independently of the Wayland event loop.
@@ -14,8 +14,8 @@ use std::sync::mpsc;
 /// A status update sent from the main loop to the server thread.
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub struct StatusUpdate {
-    /// JSON string for tags module subscribers
-    pub tags_json: String,
+    /// JSON string for viewport module subscribers
+    pub viewport_json: String,
     /// Plain text for layout module subscribers
     pub layout_text: String,
     /// Plain text for title module subscribers
@@ -27,7 +27,7 @@ pub struct StatusUpdate {
 /// Subscription types that the status bar script can request.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 enum Subscription {
-    Tags,
+    Viewport,
     Layout,
     Title,
     Modifiers,
@@ -37,7 +37,7 @@ enum Subscription {
 impl Subscription {
     fn from_str(s: &str) -> Self {
         match s.trim() {
-            "tags" => Subscription::Tags,
+            "viewport" => Subscription::Viewport,
             "layout" => Subscription::Layout,
             "title" => Subscription::Title,
             "modifiers" => Subscription::Modifiers,
@@ -228,7 +228,7 @@ fn read_subscription(stream: &UnixStream) -> Subscription {
 
 fn format_for_subscription(sub: Subscription, update: &StatusUpdate) -> String {
     match sub {
-        Subscription::Tags => update.tags_json.clone(),
+        Subscription::Viewport => update.viewport_json.clone(),
         Subscription::Layout => update.layout_text.clone(),
         Subscription::Title => update.title_text.clone(),
         Subscription::Modifiers => update.modifiers_text.clone(),
@@ -241,7 +241,7 @@ pub unsafe fn build_status_update(wm: &crate::window_manager::WindowManager) ->
 
     let text = format!("Zoom: {:.2} | Pan: ({:.0}, {:.0})", wm.desk_zoom, wm.desk_pan_x, wm.desk_pan_y);
     let escaped = text.replace('\\', "\\\\").replace('"', "\\\"");
-    let tags_json = format!("{{\"text\": \"{}\", \"tooltip\": \"Camera State\"}}", escaped);
+    let viewport_json = format!("{{\"text\": \"{}\", \"tooltip\": \"Camera State\"}}", escaped);
 
     let layout_text = if !focused_window.is_null() {
         (*focused_window).tiling_mode.as_str().to_string()
@@ -282,7 +282,7 @@ pub unsafe fn build_status_update(wm: &crate::window_manager::WindowManager) ->
     let modifiers_text = if super_pressed { "super" } else { "none" }.to_string();
 
     StatusUpdate {
-        tags_json,
+        viewport_json,
         layout_text,
         title_text,
         modifiers_text,
diff --git a/src/server/window.rs b/src/server/window.rs
index 7768709..f31702c 100644
--- a/src/server/window.rs
+++ b/src/server/window.rs
@@ -206,7 +206,6 @@ pub struct Window {
     pub popup_tree: *mut ffi::wlr_scene_tree,
     pub capture_scene: *mut ffi::wlr_scene,
     pub capture_source: *mut ffi::wlr_ext_image_capture_source_v1,
-    pub tags: u32,
     pub tiling_mode: crate::tiling::TilingMode,
     pub mode_locked: bool,
     pub is_new: bool,
@@ -363,7 +362,6 @@ impl Window {
             popup_tree,
             capture_scene,
             capture_source: std::ptr::null_mut(),
-            tags: 1,
             tiling_mode: crate::tiling::TilingMode::Floating,
             mode_locked: false,
             is_new: true,
@@ -628,7 +626,6 @@ impl Window {
         if let Some(saved) = (*self.server).wm.match_and_remove_restore_state(&app_id_str, &title_str) {
             log::info!("Restoring saved state for window: app_id={}, title={}. Position: ({}, {}), Size: {}x{}", app_id_str, title_str, saved.virtual_x, saved.virtual_y, saved.width, saved.height);
             self.tiling_mode = saved.tiling_mode;
-            self.tags = saved.tags;
             self.minimized = saved.minimized;
             self.virtual_x = saved.virtual_x;
             self.virtual_y = saved.virtual_y;
diff --git a/src/server/window_manager.rs b/src/server/window_manager.rs
index 7cb72eb..a5302d6 100644
--- a/src/server/window_manager.rs
+++ b/src/server/window_manager.rs
@@ -46,7 +46,6 @@ pub struct SavedWindowState {
     pub app_id: String,
     pub title: String,
     pub tiling_mode: crate::tiling::TilingMode,
-    pub tags: u32,
     pub minimized: bool,
     pub virtual_x: f64,
     pub virtual_y: f64,
@@ -259,7 +258,6 @@ impl WindowManager {
                 app_id,
                 title,
                 tiling_mode: (*w).tiling_mode,
-                tags: (*w).tags,
                 minimized: (*w).minimized,
                 virtual_x: (*w).virtual_x,
                 virtual_y: (*w).virtual_y,
@@ -1150,7 +1148,7 @@ fn get_closest_tag(x: f64, y: f64) -> i32 {
                 };
             }
         }
-        // If the focused window is no longer visible on the active tags, refocus
+        // If the focused window is no longer visible, refocus
         let seats_list = &mut (*self.server).input_manager.seats as *mut ffi::wl_list as *mut WlList;
         let mut curr_seat = (*seats_list).next;
         while curr_seat != seats_list {
@@ -1552,13 +1550,12 @@ fn get_closest_tag(x: f64, y: f64) -> i32 {
                 self.desk_pan_y = target_y - (viewport_h / 2.0) / self.desk_zoom;
                 self.dirty_windowing();
             }
-            Action::Toggle1 | Action::Toggle2 | Action::Toggle3 | Action::Toggle4 => {}
-            Action::SetTag1 | Action::SetTag2 | Action::SetTag3 | Action::SetTag4 => {
+            Action::SetViewport1 | Action::SetViewport2 | Action::SetViewport3 | Action::SetViewport4 => {
                 let (target_x, target_y) = match action {
-                    Action::SetTag1 => (0.0, 0.0),
-                    Action::SetTag2 => (2000.0, 0.0),
-                    Action::SetTag3 => (0.0, 2000.0),
-                    Action::SetTag4 => (2000.0, 2000.0),
+                    Action::SetViewport1 => (0.0, 0.0),
+                    Action::SetViewport2 => (2000.0, 0.0),
+                    Action::SetViewport3 => (0.0, 2000.0),
+                    Action::SetViewport4 => (2000.0, 2000.0),
                     _ => (0.0, 0.0),
                 };
                 if let Some(seat) = self.first_seat() {
@@ -1769,39 +1766,22 @@ fn get_closest_tag(x: f64, y: f64) -> i32 {
                 }
                 "error: invalid tag\n".to_string()
             }
-            "toggle" => {
-                if parts.len() < 2 { return "error: missing tag\n".to_string(); }
-                if let Ok(tag) = parts[1].parse::<i32>() {
-                    if tag >= 1 && tag <= 4 {
-                        let act = match tag {
-                            1 => crate::config::Action::Toggle1,
-                            2 => crate::config::Action::Toggle2,
-                            3 => crate::config::Action::Toggle3,
-                            4 => crate::config::Action::Toggle4,
-                            _ => crate::config::Action::None,
-                        };
-                        self.execute_action(&act, None);
-                        return "ok\n".to_string();
-                    }
-                }
-                "error: invalid tag\n".to_string()
-            }
-            "set-tag" => {
-                if parts.len() < 2 { return "error: missing tag\n".to_string(); }
+            "set-viewport" | "set-tag" => {
+                if parts.len() < 2 { return "error: missing viewport index\n".to_string(); }
                 if let Ok(tag) = parts[1].parse::<i32>() {
                     if tag >= 1 && tag <= 4 {
                         let act = match tag {
-                            1 => crate::config::Action::SetTag1,
-                            2 => crate::config::Action::SetTag2,
-                            3 => crate::config::Action::SetTag3,
-                            4 => crate::config::Action::SetTag4,
+                            1 => crate::config::Action::SetViewport1,
+                            2 => crate::config::Action::SetViewport2,
+                            3 => crate::config::Action::SetViewport3,
+                            4 => crate::config::Action::SetViewport4,
                             _ => crate::config::Action::None,
                         };
                         self.execute_action(&act, None);
                         return "ok\n".to_string();
                     }
                 }
-                "error: invalid tag\n".to_string()
+                "error: invalid viewport index\n".to_string()
             }
             "pan-by" => {
                 if parts.len() < 3 { return "error: missing dx or dy\n".to_string(); }
@@ -2074,7 +2054,7 @@ fn get_closest_tag(x: f64, y: f64) -> i32 {
                 self.dirty_windowing();
                 "ok\n".to_string()
             }
-            "tag-layout" => {
+            "viewport-layout" => {
                 "ok\n".to_string()
             }
             "mode" => {