Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions packages/rsnap-overlay/src/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ pub struct OverlaySession {
toolbar_left_button_went_down: bool,
toolbar_left_button_went_up: bool,
toolbar_pointer_local: Option<Pos2>,
#[cfg(target_os = "macos")]
toolbar_window_cursor_hittest_enabled: bool,
left_mouse_button_down: bool,
left_mouse_button_down_monitor: Option<MonitorRect>,
left_mouse_button_down_global: Option<GlobalPoint>,
Expand Down Expand Up @@ -753,6 +755,7 @@ impl OverlaySession {
}
}

#[allow(clippy::too_many_lines)]
#[rustfmt::skip]
fn build_base_session_defaults() -> Self {
Self {
Expand Down Expand Up @@ -836,9 +839,11 @@ impl OverlaySession {
frozen_text_annotations: Vec::new(), frozen_text_redo_annotations: Vec::new(),
frozen_text_edit: None, frozen_text_input_generation: 0, frozen_text_recent_input: None,
toolbar_state: FrozenToolbarState::default(),
toolbar_left_button_down: false, toolbar_left_button_went_down: false, toolbar_left_button_went_up: false,
toolbar_pointer_local: None,
left_mouse_button_down: false, left_mouse_button_down_monitor: None, left_mouse_button_down_global: None,
toolbar_left_button_down: false, toolbar_left_button_went_down: false, toolbar_left_button_went_up: false,
toolbar_pointer_local: None,
#[cfg(target_os = "macos")]
toolbar_window_cursor_hittest_enabled: false,
left_mouse_button_down: false, left_mouse_button_down_monitor: None, left_mouse_button_down_global: None,
frozen_brush: FrozenBrushState::default(),
frozen_selection_drag: FrozenSelectionDragState::default(),
frozen_mosaic_drag: FrozenMosaicDragState::default(),
Expand Down Expand Up @@ -1531,6 +1536,8 @@ impl OverlaySession {
tracing::debug!(
monitor_id = monitor.id,
frozen_generation = self.state.frozen_generation,
toolbar_primary_size_points =
?WindowRenderer::frozen_toolbar_primary_size(&self.toolbar_state),
toolbar_size_points =
?WindowRenderer::frozen_toolbar_size(&self.toolbar_state),
default_pos = ?default_pos,
Expand All @@ -1549,12 +1556,14 @@ impl OverlaySession {
Pos2::new(capture_rect_points.x as f32, capture_rect_points.y as f32),
Vec2::new(capture_rect_points.width as f32, capture_rect_points.height as f32),
);
let toolbar_size = WindowRenderer::frozen_toolbar_size(&self.toolbar_state);
let toolbar_primary_size = WindowRenderer::frozen_toolbar_primary_size(&self.toolbar_state);
let toolbar_window_size = self.toolbar_positioning_size();

WindowRenderer::frozen_toolbar_default_pos(
WindowRenderer::frozen_toolbar_default_window_pos(
screen_rect,
capture_rect,
toolbar_size,
toolbar_primary_size,
toolbar_window_size,
self.config.toolbar_placement,
)
}
Expand Down Expand Up @@ -2016,6 +2025,7 @@ impl OverlaySession {
}

/// Handles a winit window event for one of the overlay-owned windows.
#[allow(clippy::too_many_lines)]
pub fn handle_window_event(
&mut self,
window_id: WindowId,
Expand Down Expand Up @@ -2547,20 +2557,22 @@ impl OverlaySession {
self.maybe_log_event_loop_stall(Instant::now());
self.mark_progress(OverlayEventLoopPhase::OverlayRedraw);

// On macOS the frozen toolbar is now rendered in its own native HUD window; keep this
// fullscreen overlay free of toolbar UI so shader-backed blur and monitor-aligned offsets
// do not conflict with native-window positioning.
let draw_toolbar = !cfg!(target_os = "macos")
&& matches!(self.state.mode, OverlayMode::Frozen)
let overlay_screen_rect = self.overlay_window_screen_rect(window_id, overlay_monitor);
#[cfg(target_os = "macos")]
let draw_toolbar = false;
#[cfg(not(target_os = "macos"))]
let draw_toolbar = matches!(self.state.mode, OverlayMode::Frozen)
&& self.toolbar_state.visible
&& self.state.monitor == Some(overlay_monitor)
&& self.frozen_final_capture_ready();
#[cfg(not(target_os = "macos"))]
let toolbar_input =
if draw_toolbar { self.toolbar_pointer_state(overlay_monitor, None) } else { None };
#[cfg(target_os = "macos")]
let toolbar_input = None;

self.log_frozen_overlay_redraw_trace(window_id, overlay_monitor, draw_toolbar);

let overlay_screen_rect = self.overlay_window_screen_rect(window_id, overlay_monitor);
let toolbar_visible_for_badge = if cfg!(target_os = "macos") {
!self.should_hide_toolbar_window(overlay_monitor)
} else {
Expand Down Expand Up @@ -2944,6 +2956,10 @@ impl OverlaySession {
self.pending_toolbar_outer_pos = None;
self.hud_window_visible = false;
self.toolbar_window_visible = false;
#[cfg(target_os = "macos")]
{
self.toolbar_window_cursor_hittest_enabled = false;
}
self.skip_toolbar_focus_on_next_show = false;
self.toolbar_window_warmup_redraws_remaining = 0;
self.loupe_window_visible = false;
Expand Down
10 changes: 10 additions & 0 deletions packages/rsnap-overlay/src/overlay/capture_window_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ impl OverlaySession {
pub(super) fn update_cursor_state(&mut self, monitor: MonitorRect, cursor: GlobalPoint) {
self.cursor_monitor = Some(monitor);
self.state.cursor = Some(cursor);

#[cfg(target_os = "macos")]
self.sync_toolbar_window_cursor_hittest(Some(cursor));
}

#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -42,10 +45,17 @@ impl OverlaySession {
self.reset_loupe_window_warmup_redraws();

if let Some(toolbar_window) = &self.toolbar_window {
#[cfg(target_os = "macos")]
let _ = toolbar_window.window.set_cursor_hittest(false);

toolbar_window.window.set_visible(false);
}

self.toolbar_window_visible = false;
#[cfg(target_os = "macos")]
{
self.toolbar_window_cursor_hittest_enabled = false;
}
self.toolbar_window_warmup_redraws_remaining = 0;

if let Some(preview_window) = &self.scroll_preview_window {
Expand Down
9 changes: 5 additions & 4 deletions packages/rsnap-overlay/src/overlay/config_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::overlay;
use crate::overlay::OverlayWorker;
use crate::overlay::{
Arc, Instant, LOUPE_TILE_CORNER_RADIUS_POINTS, OverlayConfig, OverlayMode, OverlaySession,
WindowRenderer,
};
#[cfg(target_os = "macos")]
use crate::overlay::{MacLiveFrameStream, MacOSHudWindowConfigState, SLOW_OP_WARN_HUD_CONFIG};
Expand Down Expand Up @@ -176,12 +175,14 @@ impl OverlaySession {
}
if let Some(toolbar_window) = self.toolbar_window.as_ref() {
let window = Arc::clone(&toolbar_window.window);
let toolbar_height_points = self
.toolbar_inner_size_points
.map(|(_, height)| height as f32)
.unwrap_or_else(|| overlay::frozen_toolbar_window_startup_size_points().y);

self.configure_hud_window_common(
window.as_ref(),
Some(overlay::frozen_toolbar_corner_radius_points(
WindowRenderer::frozen_toolbar_size(&self.toolbar_state).y,
)),
Some(overlay::frozen_toolbar_corner_radius_points(toolbar_height_points)),
);
}
}
Expand Down
53 changes: 52 additions & 1 deletion packages/rsnap-overlay/src/overlay/input_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::overlay::{
ElementState, FrozenSelectionDragCursorMoveTiming, FrozenTextEditState, FrozenTextInputSource,
FrozenToolbarTool, GlobalPoint, Ime, Key, KeyEvent, LIVE_DRAG_START_THRESHOLD_PX, Modifiers,
MonitorRect, MouseScrollDelta, NamedKey, OverlayControl, OverlayMode, OverlaySession,
PhysicalPosition, PhysicalSize, PngAction, Vec2, WindowId,
PhysicalPosition, PhysicalSize, PngAction, Pos2, Vec2, WindowId, WindowRenderer,
};

impl OverlaySession {
Expand Down Expand Up @@ -59,12 +59,18 @@ impl OverlaySession {
let _ = self.stop_frozen_text_edit_drag();

self.toolbar_state.dragging = false;
self.toolbar_state.drag_start_eligible = false;
self.toolbar_state.drag_offset = Vec2::ZERO;
self.toolbar_state.drag_anchor = None;
} else {
self.toolbar_state.drag_offset = Vec2::ZERO;
self.toolbar_state.dragging = false;
self.toolbar_state.drag_anchor = None;

let current_cursor_local = self.current_toolbar_cursor_local();

self.toolbar_state.drag_start_eligible =
self.resolve_toolbar_drag_start_eligibility(current_cursor_local);
}

#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -111,9 +117,54 @@ impl OverlaySession {
self.toolbar_pointer_local = None;
self.toolbar_state.annotation_size_control_hovered = false;
self.toolbar_state.annotation_size_wheel_accumulator = 0.0;
self.toolbar_state.drag_start_eligible = false;
self.toolbar_state.drag_anchor = None;
}

pub(super) fn resolve_toolbar_drag_start_eligibility(
&self,
current_cursor_local: Option<Pos2>,
) -> bool {
current_cursor_local
.or(self.toolbar_pointer_local)
.is_some_and(|cursor_local| self.toolbar_primary_rect_contains(cursor_local))
}

fn current_toolbar_cursor_local(&mut self) -> Option<Pos2> {
let toolbar_window = self.toolbar_window.as_ref()?;
let outer_position = Self::toolbar_window_outer_position(toolbar_window)?;
#[cfg(target_os = "macos")]
let cursor_global = super::macos_mouse_location()?;
#[cfg(not(target_os = "macos"))]
let cursor_global = self.sample_mouse_location();

Self::toolbar_cursor_local_from_sampled_global(outer_position, Some(cursor_global))
}

fn toolbar_primary_rect_contains(&self, cursor_local: Pos2) -> bool {
WindowRenderer::frozen_toolbar_primary_rect(&self.toolbar_state, Pos2::ZERO)
.contains(cursor_local)
}

pub(super) fn toolbar_cursor_local_position_from_outer(
outer_position: GlobalPoint,
global_cursor: GlobalPoint,
) -> Pos2 {
Pos2::new(
global_cursor.x as f32 - outer_position.x as f32,
global_cursor.y as f32 - outer_position.y as f32,
)
}

pub(super) fn toolbar_cursor_local_from_sampled_global(
outer_position: GlobalPoint,
sampled_cursor: Option<GlobalPoint>,
) -> Option<Pos2> {
sampled_cursor.map(|global_cursor| {
Self::toolbar_cursor_local_position_from_outer(outer_position, global_cursor)
})
}

pub(super) fn handle_modifiers_changed(&mut self, modifiers: &Modifiers) -> OverlayControl {
self.keyboard_modifiers = modifiers.state();

Expand Down
1 change: 1 addition & 0 deletions packages/rsnap-overlay/src/overlay/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ impl WindowRenderer {
}

#[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_lines)]
fn run_egui(
&mut self,
raw_input: egui::RawInput,
Expand Down
Loading
Loading