forge
Explore
Log in

Don't you dare go Hollow

Guard focus ring to darkroom + ctrl-click uses press modifiers

Browse files at this commit

6da98cd907df1a810bbc56fb1ab84f34070a1ccfAhmet Kaan GümüşParent: 93dd61d
  • fix
    • guard focus ring to darkroom + ctrl-click uses press modifiers
Show full message
🐛 fix(ui): guard focus ring to darkroom + ctrl-click uses press modifiers

FocusPanels (F6) called window.focus on the ring's handles even under
OLD_GUI=1, where the legacy tree never mounts them -- an unmounted focus
target kills all key dispatch until a mouse click. focus_surface now
no-ops when !self.darkroom, the single door every route goes through.

ClickEvent::modifiers() answers the mouse-up modifiers, so releasing
ctrl before the button undid a ctrl-held toggle decided on mouse-down
(clip_box/sub_box in bench_stance.rs, timeline.rs's two clip boxes).
Added widgets::press_modifiers, reading ClickEvent::Mouse's down event
instead, at all four sites.

Also: dock_stance.rs's doc comments were swapped between transition_row
and clip_tab -- moved each back to its own fn; the transition steppers'
hitmap labels were the raw element id instead of a phrase, given
"Shorten transition"/"Lengthen transition"; and view.rs's stale comment
referencing the old window.focus(&self.focus_dock) call updated to
name focus_surface.
crates/app/src/tests/view.rsmodified+3 -3
@@ -968,9 +968,9 @@ fn escape_is_the_only_key_a_focused_surface_uses_to_leave_the_ring() {
968968 }
969969
970970 /// [`ActionId::FocusPanels`] is what starts the ring in the first place
971-/// (`Player::act`'s `window.focus(&self.focus_dock)`) -- without a bound key
972-/// reaching it, `next_surface`/`is_focus_cycle_key` above are unreachable
973-/// dead code, exactly the defect this action closes.
971+/// (`Player::act`'s `self.focus_surface(Surface::Dock, ..)`) -- without a
972+/// bound key reaching it, `next_surface`/`is_focus_cycle_key` above are
973+/// unreachable dead code, exactly the defect this action closes.
974974 #[test]
975975 fn focus_panels_is_bound_and_lands_on_the_dock() {
976976 use keymap::{ActionId, Keymap};
crates/app/src/ui/bench_stance.rsmodified+2 -2
@@ -288,7 +288,7 @@ fn clip_box(
288288 // the press so a set-drag has something to move; this is where the
289289 // collapse a plain click promises actually lands.
290290 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
291- if !event.modifiers().control {
291+ if !press_modifiers(event).control {
292292 this.select((lane, idx), cx);
293293 }
294294 }))
@@ -672,7 +672,7 @@ fn sub_box(
672672 // A plain click collapses a multi-pick to this one, exactly as a
673673 // clip's own box does -- see the comment there.
674674 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
675- if !event.modifiers().control {
675+ if !press_modifiers(event).control {
676676 this.select((lane, idx), cx);
677677 }
678678 }))
crates/app/src/ui/dock_stance.rsmodified+11 -11
@@ -1077,13 +1077,6 @@ fn sources_tab(
10771077 })
10781078 }
10791079
1080-/// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever
1081-/// param-row card they open -- [`Player::eq_card`], [`Player::color_card`],
1082-/// [`Player::transform_card`], [`Player::speed_card`] verbatim, the same
1083-/// param-row rendering `inspector.rs`'s selection section already opens
1084-/// these onto. Drag-while-playing and every other gesture on a row is
1085-/// whatever that card already does; nothing about the gesture is reimplemented
1086-/// here.
10871080 /// The transition duration row, in the darkroom's own idiom: the darkroom is
10881081 /// the default surface (`main.rs`'s `OLD_GUI` gate), so a row that only ever
10891082 /// drew in the legacy inspector (`ui::inspector::transition_duration_row`)
@@ -1099,7 +1092,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
10991092 let (label_text, frames, cap) =
11001093 crate::ui::inspector::transition_of(lane.kind, clips.get(idx)?, clips.get(idx + 1))?;
11011094 let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
1102- let step = |id: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Player>| {
1095+ let step = |id: &'static str, label: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Player>| {
11031096 div()
11041097 .id(id)
11051098 .flex()
@@ -1111,7 +1104,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
11111104 .bg(rgb(DARK_RAISED()))
11121105 .cursor_pointer()
11131106 .hover(|s| s.text_color(rgb(INK1())))
1114- .children(hitmap::control(id, id, true))
1107+ .children(hitmap::control(id, label, true))
11151108 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
11161109 this.nudge_transition(lane, idx, by, cx);
11171110 }))
@@ -1133,11 +1126,18 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
11331126 .text_color(rgb(INK2()))
11341127 .child(format!("{label_text} {frames}f (of {cap}f offered)")),
11351128 )
1136- .child(step("transition-minus", "−", -1, cx))
1137- .child(step("transition-plus", "+", 1, cx)),
1129+ .child(step("transition-minus", "Shorten transition", "−", -1, cx))
1130+ .child(step("transition-plus", "Lengthen transition", "+", 1, cx)),
11381131 )
11391132 }
11401133
1134+/// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever
1135+/// param-row card they open -- [`Player::eq_card`], [`Player::color_card`],
1136+/// [`Player::transform_card`], [`Player::speed_card`] verbatim, the same
1137+/// param-row rendering `inspector.rs`'s selection section already opens
1138+/// these onto. Drag-while-playing and every other gesture on a row is
1139+/// whatever that card already does; nothing about the gesture is reimplemented
1140+/// here.
11411141 fn clip_tab(
11421142 player: &Player,
11431143 width: f32,
crates/app/src/ui/stance.rsmodified+10 -0
@@ -99,12 +99,22 @@ impl Player {
9999 /// exactly as the tab's own click does (`dock_stance::dock_tab`'s
100100 /// `on_click`), so the ring and a mouse click can't disagree about
101101 /// which tab was last chosen.
102+ ///
103+ /// The ring is darkroom-only UI -- the legacy tree never mounts
104+ /// `focus_dock`/`focus_bench`/`focus_inspector` (only `track_focus`
105+ /// sites live in this module and `dock_stance.rs`), so under
106+ /// `OLD_GUI=1` a `window.focus` here would land on an unmounted
107+ /// handle and kill the root key listener (`main.rs`'s fallback focus)
108+ /// until the next mouse click. No-op there instead.
102109 pub(crate) fn focus_surface(
103110 &mut self,
104111 surface: Surface,
105112 window: &mut Window,
106113 cx: &mut Context<Self>,
107114 ) {
115+ if !self.darkroom {
116+ return;
117+ }
108118 if let Some(src_active) = surface_wants_src_active(surface) {
109119 self.dock_src_active = src_active;
110120 crate::ui::dock_stance::save(src_active);
crates/app/src/ui/timeline.rsmodified+2 -2
@@ -1390,7 +1390,7 @@ impl Player {
13901390 // starts, so this only fires on a press-release
13911391 // with no drag between.
13921392 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
1393- if !event.modifiers().control {
1393+ if !press_modifiers(event).control {
13941394 this.select((lane, i), cx);
13951395 }
13961396 }))
@@ -1775,7 +1775,7 @@ impl Player {
17751775 // A plain click collapses a multi-pick to this one
17761776 // caption, exactly as a clip's own box does above.
17771777 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
1778- if !event.modifiers().control {
1778+ if !press_modifiers(event).control {
17791779 this.select((lane, i), cx);
17801780 }
17811781 }))
crates/app/src/ui/widgets.rsmodified+12 -0
@@ -9,6 +9,18 @@ pub(crate) fn waveform(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64) -> impl
99 waveform_ink(peaks, from, to, FG_SECONDARY())
1010 }
1111
12+/// `ClickEvent::modifiers()` answers the mouse-*up* modifiers (gpui-0.2.2
13+/// `interactive.rs`), so releasing ctrl before the button lands undoes a
14+/// ctrl-held toggle decided on mouse-down. This reads the *press* modifiers
15+/// instead -- the ones a ctrl-click decision (multi-pick, no collapse) was
16+/// actually made under.
17+pub(crate) fn press_modifiers(event: &ClickEvent) -> gpui::Modifiers {
18+ match event {
19+ ClickEvent::Mouse(m) => m.down.modifiers,
20+ ClickEvent::Keyboard(_) => gpui::Modifiers::default(),
21+ }
22+}
23+
1224 /// As [`waveform`], but in a caller-picked ink rather than the fixed
1325 /// secondary foreground -- the darkroom bench's own audio clips draw their
1426 /// envelope in the source's ink (DESIGN §5), which the legacy timeline never