YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(windows): make the native overlay pill draggable
Louis Beaumont54d150b8ddb8
diff --git a/crates/screenpipe-overlay-win/src/layout.rs b/crates/screenpipe-overlay-win/src/layout.rsindex 43937f202..68f01aff5 100644--- a/crates/screenpipe-overlay-win/src/layout.rs+++ b/crates/screenpipe-overlay-win/src/layout.rs@@ -121,6 +121,20 @@ impl Layout {}}+ /// True when a press here may become a pill drag once the pointer travels+ /// past the threshold. The whole pill stack drags — chip, dock, health+ /// banner, disclosure — even when the press lands on a button: travel+ /// cancels the click and moves the pill instead, exactly the+ /// `DraggableHostingView` contract on macOS. Attachments (transcript,+ /// notification) are separate panels there and do not drag the pill, so+ /// they do not here either.+ pub fn press_can_drag(&self, px: f32, py: f32) -> bool {+ [Some(self.primary), self.disclosure]+ .into_iter()+ .flatten()+ .any(|r| r.inset(-2.0, -2.0).contains(px, py))+ }+/// True when the point is over any painted surface — what decides whether/// the window keeps the pointer or lets it fall through to the desktop.pub fn is_opaque_at(&self, px: f32, py: f32) -> bool {@@ -583,6 +597,55 @@ mod tests {assert_eq!(l.window.w, BASE_TRANSCRIPT_W + SHADOW_PAD * 2.0);}+ #[test]+ fn every_face_of_the_pill_stack_can_start_a_drag() {+ // Resting chip.+ let l = compute(&OverlayState::default());+ let p = l.primary;+ assert!(l.press_can_drag(p.x + p.w / 2.0, p.y + p.h / 2.0));++ // Hovered, the dock tiles the primary with buttons — a press on a+ // button must still be draggable, or the pill cannot be dragged at all:+ // hovering is a precondition for pressing.+ let l = compute(&hovered());+ for (control, r) in &l.dock_cells {+ assert!(+ l.press_can_drag(r.x + r.w / 2.0, r.y + r.h / 2.0),+ "press on {control:?} must be drag-eligible"+ );+ }+ let d = l.disclosure.expect("hovered pill shows the disclosure");+ assert!(l.press_can_drag(d.x + d.w / 2.0, d.y + d.h / 2.0));++ // The health banner replaces the pill and drags like it.+ let l = compute(&OverlayState {+ health: Health::Failure,+ ..Default::default()+ });+ let p = l.primary;+ assert!(l.press_can_drag(p.x + p.w / 2.0, p.y + p.h / 2.0));+ }++ #[test]+ fn attachments_do_not_drag_the_pill() {+ let mut s = hovered();+ s.notification = parse(r#"{"id":"m","title":"meeting started"}"#).ok();+ s.meeting_active = true;+ s.transcript_pinned = true;+ s.transcript = vec![TranscriptItem {+ speaker: "louis".into(),+ text: "hello".into(),+ device_type: "input".into(),+ }];+ let l = compute(&s);+ let n = l.notification.expect("notification block");+ assert!(!l.press_can_drag(n.x + n.w / 2.0, n.y + n.h / 2.0));+ let t = l.transcript.expect("transcript block");+ assert!(!l.press_can_drag(t.x + t.w / 2.0, t.y + t.h / 2.0));+ // The shadow ring is not a grab handle either.+ assert!(!l.press_can_drag(0.5, 0.5));+ }+#[test]fn clicks_outside_every_surface_fall_through_to_the_desktop() {let l = compute(&OverlayState::default());diff --git a/crates/screenpipe-overlay-win/src/window.rs b/crates/screenpipe-overlay-win/src/window.rsindex 2048d5f0b..f3aaf2fdc 100644--- a/crates/screenpipe-overlay-win/src/window.rs+++ b/crates/screenpipe-overlay-win/src/window.rs@@ -203,6 +203,11 @@ struct Ctx {/// changes. The cursor only decides the monitor while the user is dragging.work_area: RECT,press_origin: Option<(f32, f32)>,+ /// The press landed on the pill stack, so travel past `DRAG_THRESHOLD`+ /// becomes a drag even when it began on a dock button — the macOS+ /// `DraggableHostingView` contract. Kept out of `OverlayState` because no+ /// caller and no painter needs it.+ press_can_drag: bool,dragging: bool,drag_offset: (i32, i32),animating: bool,@@ -267,6 +272,7 @@ fn run_message_loop(// appears; after this the pill stays on its own monitor.work_area: monitor_work_area_at_cursor(),press_origin: None,+ press_can_drag: false,dragging: false,drag_offset: (0, 0),animating: false,@@ -721,11 +727,15 @@ extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM)if let Some((ox, oy)) = ctx.press_origin {if !ctx.dragging- && ctx.state.pressed_control == Some(Control::Pill)+ && ctx.press_can_drag&& ((x - ox).powi(2) + (y - oy).powi(2)).sqrt() > DRAG_THRESHOLD{ctx.dragging = true;ctx.state.dragging = true;+ // The press will not become a click any more; release+ // the button visual so it does not ride along lit.+ ctx.state.pressed_control = None;+ repaint(hwnd);}if ctx.dragging {let scale = dpi_scale(hwnd);@@ -788,6 +798,7 @@ extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM)let (x, y) = mouse_dip(hwnd, lparam);if let Some(ctx) = ctx_of(hwnd) {ctx.press_origin = Some((x, y));+ ctx.press_can_drag = ctx.layout.press_can_drag(x, y);ctx.state.pressed_control = ctx.layout.hit_test(x, y);SetCapture(hwnd);repaint(hwnd);@@ -832,6 +843,7 @@ extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM)}}ctx.press_origin = None;+ ctx.press_can_drag = false;ctx.state.pressed_control = None;}arm_dismiss_timer(hwnd);