From ebd40fdc6402968677f7162778500d7b4052e8fb Mon Sep 17 00:00:00 2001 From: Nikhil Anu <39329699+nikhilanu@users.noreply.github.com> Date: Mon, 26 Oct 2026 19:06:14 +0000 Subject: [PATCH] fix(desktop-gpui): stop the recording controls' transparent margin from swallowing clicks on macOS macOS hit-tests the whole frame of a transparent window, so the 320x150 controls window blocked clicks in the empty space above its 40px bar. On macOS the window now opens at the bar's height and resizes to its content, growing upward only while the issue banner is shown. Other platforms are unchanged. Fixes #3357 --- apps/desktop-gpui/src/app_windows.rs | 12 ++++++-- apps/desktop-gpui/src/controls_window.rs | 37 +++++++++++++++++++----- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rs index aafc67eb919..5a8b7dcea23 100644 --- a/apps/desktop-gpui/src/app_windows.rs +++ b/apps/desktop-gpui/src/app_windows.rs @@ -44,6 +44,14 @@ pub const CONTROLS_HEIGHT: f32 = 150.; const CONTROLS_BOTTOM_OFFSET: f64 = 120.; const TARGET_CONTROLS_OFFSET_Y: f64 = 48.; +fn controls_height() -> f32 { + if crate::controls_window::FIT_WINDOW_TO_CONTENT { + crate::controls_window::CONTROLS_BAR_HEIGHT + crate::controls_window::CONTROLS_PADDING * 2. + } else { + CONTROLS_HEIGHT + } +} + #[cfg(any(target_os = "macos", test))] mod editor_placement; @@ -6666,7 +6674,7 @@ fn controls_origin(config: &StartConfig) -> (f64, f64) { use cap_recording::sources::screen_capture::ScreenCaptureTarget; let width = CONTROLS_WIDTH as f64; - let height = CONTROLS_HEIGHT as f64; + let height = controls_height() as f64; if let ScreenCaptureTarget::Window { id } = &config.target && let Some(window) = scap_targets::Window::from_id(id) @@ -6705,7 +6713,7 @@ fn open_controls( let (x, y) = controls_origin(config); let bounds = Bounds { origin: point(px(x as f32), px(y as f32)), - size: size(px(CONTROLS_WIDTH), px(CONTROLS_HEIGHT)), + size: size(px(CONTROLS_WIDTH), px(controls_height())), }; let display = config .target diff --git a/apps/desktop-gpui/src/controls_window.rs b/apps/desktop-gpui/src/controls_window.rs index 4aca069a69d..fd1ebb9aed6 100644 --- a/apps/desktop-gpui/src/controls_window.rs +++ b/apps/desktop-gpui/src/controls_window.rs @@ -1,6 +1,6 @@ //! The in-progress recording bar -- `in-progress-recording.tsx`, natively. //! -//! A 320x150 transparent panel whose visible content is a 40px card hugging the +//! A transparent panel whose visible content is a 40px card hugging the //! bottom: stop button with the elapsed timer on the left, mic indicator and //! action buttons on the right, a drag handle on the trailing edge. The window //! itself is a non-activating panel at the maximum window level (see @@ -12,7 +12,7 @@ use std::time::Duration; use gpui::{ AppContext as _, Context, Entity, FontWeight, InteractiveElement as _, IntoElement, MouseButton, ParentElement as _, Render, SharedString, StatefulInteractiveElement as _, Styled, - Window, div, prelude::FluentBuilder as _, px, svg, + Window, div, prelude::FluentBuilder as _, px, size, svg, }; use crate::i18n::tr; @@ -25,6 +25,11 @@ use crate::{ ui, }; +pub const CONTROLS_PADDING: f32 = 12.; +pub const CONTROLS_BAR_HEIGHT: f32 = 40.; + +pub const FIT_WINDOW_TO_CONTENT: bool = cfg!(target_os = "macos"); + pub struct ControlsWindow { session: Entity, theme: Theme, @@ -391,7 +396,7 @@ impl ControlsWindow { }; div() - .h(px(40.)) + .h(px(CONTROLS_BAR_HEIGHT)) .flex_shrink_0() .w_full() .flex() @@ -518,12 +523,11 @@ impl Render for ControlsWindow { .then(|| tr::controls::low_storage().to_owned()) }); - div() - .size_full() + let content = div() .flex() .flex_col() .justify_end() - .p(px(12.)) + .p(px(CONTROLS_PADDING)) .font_family(crate::theme::UI_FONT) .locale_font() // `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`). @@ -554,7 +558,26 @@ impl Render for ControlsWindow { .child(recording_issue_text(issue)), ) }) - .child(self.render_bar(cx)) + .child(self.render_bar(cx)); + + if !FIT_WINDOW_TO_CONTENT { + return content.size_full(); + } + + // Transparent areas still take clicks on macOS, so the window hugs its content (#3357). + div() + .size_full() + .relative() + .child(content.absolute().left_0().right_0().bottom_0()) + .on_children_prepainted(|bounds, window, _| { + let Some(content) = bounds.first() else { + return; + }; + let height = content.size.height.ceil(); + if (window.viewport_size().height - height).abs() >= px(1.) { + window.resize(size(px(crate::app_windows::CONTROLS_WIDTH), height)); + } + }) } }