A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
linux: auto-close the island reliably on Wayland layer-shell
German353633a9898a
diff --git a/windows/src-tauri/src/lib.rs b/windows/src-tauri/src/lib.rsindex 714103e5..3018d8c2 100644--- a/windows/src-tauri/src/lib.rs+++ b/windows/src-tauri/src/lib.rs@@ -96,6 +96,7 @@ fn set_collapsed(app: AppHandle, shared: State<Shared>, collapsed: bool) {// The wake strip must always take the mouse, and a resize invalidates the flag.island::refresh_click_through(&app, &shared.gate);shared.gate.set_active(!collapsed);+ platform::set_pointer_watch(!collapsed);}/// The front end pushes the island shape; Rust decides click-through from it.diff --git a/windows/src-tauri/src/platform/linux.rs b/windows/src-tauri/src/platform/linux.rsindex e748a336..d8271840 100644--- a/windows/src-tauri/src/platform/linux.rs+++ b/windows/src-tauri/src/platform/linux.rs@@ -259,10 +259,84 @@ pub fn make_non_activating(win: &WebviewWindow) {}gtk::glib::Propagation::Proceed});+ ISLAND_GTK.with(|cell| *cell.borrow_mut() = Some(gw.clone()));+ watch_pointer_leave(win);LAYER_SURFACE.store(true, Ordering::Relaxed);crate::log::line("island is a layer-shell overlay");}+thread_local! {+ /// The island's GTK window, for the pointer watch (GTK main thread only).+ static ISLAND_GTK: std::cell::RefCell<Option<gtk::ApplicationWindow>> =+ const { std::cell::RefCell::new(None) };+}++/// Reports the pointer leaving the island, which the page cannot see by itself.+///+/// On a layer surface WebKitGTK does not send `mouseout` when the pointer leaves+/// for good, and GTK's leave-notify fires spuriously while the pointer is still+/// over the island (each followed by a re-enter), so neither tells "really+/// gone". GDK's pointer focus does: it follows the compositor's wl_pointer+/// enter/leave. It is read every 100 ms while the island is shown; both edges go+/// to the page as `pointer-inside`, and leaving also emits the far-away cursor+/// the page uses. While the island is hidden the timer is removed altogether+/// (set_pointer_watch), so a hidden island costs nothing.+static POINTER_WIN: std::sync::OnceLock<WebviewWindow> = std::sync::OnceLock::new();+static WATCH_WANTED: AtomicBool = AtomicBool::new(true);+static WATCH_RUNNING: AtomicBool = AtomicBool::new(false);++fn watch_pointer_leave(win: &WebviewWindow) {+ let _ = POINTER_WIN.set(win.clone());+ start_pointer_watch();+}++/// Starts or parks the pointer watch. Called with the island's collapsed state;+/// safe from any thread (the timer itself lives on the GTK main loop).+pub fn set_pointer_watch(active: bool) {+ WATCH_WANTED.store(active, Ordering::Relaxed);+ if active {+ gtk::glib::MainContext::default().invoke(start_pointer_watch);+ }+}++/// Main thread only.+fn start_pointer_watch() {+ if !WATCH_WANTED.load(Ordering::Relaxed) || WATCH_RUNNING.swap(true, Ordering::Relaxed) {+ return;+ }+ use tauri::Emitter;+ let Some(win) = POINTER_WIN.get().cloned() else {+ WATCH_RUNNING.store(false, Ordering::Relaxed);+ return;+ };+ let inside = std::cell::Cell::new(false);+ gtk::glib::timeout_add_local(std::time::Duration::from_millis(100), move || {+ if !WATCH_WANTED.load(Ordering::Relaxed) {+ WATCH_RUNNING.store(false, Ordering::Relaxed);+ return gtk::glib::ControlFlow::Break;+ }+ let now_inside = ISLAND_GTK+ .with(|cell| {+ let gw = cell.borrow().clone()?;+ let ours = gw.window()?;+ let pointer = gtk::gdk::Display::default()?.default_seat()?.pointer()?;+ let (under, _, _) = pointer.window_at_position();+ Some(under?.toplevel() == ours.toplevel())+ })+ .unwrap_or(false);+ if inside.replace(now_inside) != now_inside {+ // The page gates its own (late, sometimes stale) mouse events on+ // this state, so a mousemove queued before the pointer left cannot+ // pull the island back to "inside".+ let _ = win.emit("pointer-inside", now_inside);+ if !now_inside {+ let _ = win.emit("cursor", crate::island::CursorPayload { x: -10_000.0, y: -10_000.0 });+ }+ }+ gtk::glib::ControlFlow::Continue+ });+}+/// Temporarily allow keyboard focus so a text field inside the island can be/// typed in.pub fn set_activating(win: &WebviewWindow, activating: bool) {diff --git a/windows/src-tauri/src/platform/windows.rs b/windows/src-tauri/src/platform/windows.rsindex 6e1200a8..714586e2 100644--- a/windows/src-tauri/src/platform/windows.rs+++ b/windows/src-tauri/src/platform/windows.rs@@ -233,3 +233,6 @@ pub fn set_activating(win: &WebviewWindow, activating: bool) {/// Click-through here is the poll's WS_EX_TRANSPARENT toggle, not a region.pub fn set_input_region(_win: &WebviewWindow, _rect: Option<(f64, f64, f64, f64)>) {}++/// The cursor poll already parks itself with the island (island.rs): nothing to do.+pub fn set_pointer_watch(_active: bool) {}diff --git a/windows/src/island/island.ts b/windows/src/island/island.tsindex 7fdb6180..96efccce 100644--- a/windows/src/island/island.ts+++ b/windows/src/island/island.ts@@ -569,8 +569,24 @@ export class Island {});}+ /**+ * Pointer on/off the island as the compositor sees it (Linux only). Null+ * until the first report, so a platform that never sends it is not gated.+ */+ private pointerInside: boolean | null = null;++ setPointerInside(inside: boolean) {+ this.pointerInside = inside;+ }+/** Cursor in window-logical coordinates. */onCursor(x: number, y: number) {+ // WebKitGTK can deliver a mousemove after the pointer has left the layer+ // surface; trusting it re-enters the island and the auto-close never runs.+ if (this.pointerInside === false) {+ x = -10_000;+ y = -10_000;+ }State.mouse = { x, y };const rect = this.islandRect();State.mouseInIsland = { x: x - rect.x, y: y - rect.y };diff --git a/windows/src/main.ts b/windows/src/main.tsindex f65d5e75..d71525e6 100644--- a/windows/src/main.ts+++ b/windows/src/main.ts@@ -25,6 +25,7 @@ async function main() {if (boot && !boot.cursorPoll) island.followPageCursor();await onEvent<{ x: number; y: number }>("cursor", ({ x, y }) => island.onCursor(x, y));+ await onEvent<boolean>("pointer-inside", (inside) => island.setPointerInside(inside));/** Pause has to reach Rust too, or the pollers keep calling out. */const setPaused = (on: boolean) => {