git.lucas.co / cce-data-editor
structured data editor
git clone https://git.lucas.co/cce-data-editor.git

commitc1893227ac494c4a15d2d8d2fa096b5cc7d755a0
parent0eb500dda4
authorLucas Galante <lsgalante12@gmail.com>
date2026-10-02 14:55
refactor: refocus cce-relief / cce-ramp with cce_ui::ipc::focus_window

Refocusing an editor this session already spawned launched a whole
`ccectl focus-window <app>` process (resolved from ~/.local/bin, else
PATH) for one line on the control socket. cce-ui's focus_window
(c16ef39) sends that line itself, bounded at a second, on a thread so
the click never waits on the compositor -- as the spawn never did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

 src/main.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 5cad08a..d48b649 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -748,9 +748,10 @@ impl DataEditorApp {
         let home = std::env::var("HOME").unwrap_or_default();
         if let Some(child) = self.bevel_child.as_mut() {
             if matches!(child.try_wait(), Ok(None)) {
-                let ccectl = format!("{home}/.local/bin/ccectl");
-                let ccectl = if std::path::Path::new(&ccectl).exists() { ccectl } else { "ccectl".to_string() };
-                let _ = std::process::Command::new(ccectl).args(["focus-window", "cce-relief"]).spawn();
+                // Off the UI thread: the round trip is bounded, not free.
+                std::thread::spawn(|| {
+                    let _ = cce_ui::ipc::focus_window("cce-relief");
+                });
                 return;
             }
             self.bevel_child = None;
@@ -810,9 +811,10 @@ impl DataEditorApp {
         let home = std::env::var("HOME").unwrap_or_default();
         if let Some(child) = self.ramp_child.as_mut() {
             if matches!(child.try_wait(), Ok(None)) {
-                let ccectl = format!("{home}/.local/bin/ccectl");
-                let ccectl = if std::path::Path::new(&ccectl).exists() { ccectl } else { "ccectl".to_string() };
-                let _ = std::process::Command::new(ccectl).args(["focus-window", "cce-ramp"]).spawn();
+                // Off the UI thread: the round trip is bounded, not free.
+                std::thread::spawn(|| {
+                    let _ = cce_ui::ipc::focus_window("cce-ramp");
+                });
                 return;
             }
             self.ramp_child = None;