Skip to content
Merged
32 changes: 31 additions & 1 deletion apps/desktop-gpui/src/picker_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ async fn probe_window_arrangement(
.map(|bounds| (bounds.size().width() as f32, bounds.size().height() as f32));
let before = Some(picked.bounds);

// Start from Focus off whatever the saved settings say: turning Center
// off later under a saved Focus would put back the pre-resize frame.
overlay
.update(cx, |view, _, cx| {
view.set_focus_center(false, cx);
view.set_focus(false, cx)
})
.ok();
sleep(cx, 500).await;

// `window_arrange::RATIOS` lists 16:9 second.
overlay
.update(cx, |view, _, cx| view.choose_window_size(1, cx))
Expand All @@ -229,10 +239,24 @@ async fn probe_window_arrangement(
};
screenshot(output, "window-16x9", cx).await;

// Focus alone records the window where it is: only Center on screen
// moves it.
overlay
.update(cx, |view, _, cx| view.set_focus(true, cx))
.ok();
sleep(cx, 1500).await;
let unmoved = read_window(&picked.id);
let stayed = unmoved.zip(shaped).is_some_and(|(now, then)| {
(now.x - then.x).abs() < 6.
&& (now.y - then.y).abs() < 6.
&& (now.width - then.width).abs() < 6.
&& (now.height - then.height).abs() < 6.
});

overlay
.update(cx, |view, _, cx| view.set_focus_center(true, cx))
.ok();
sleep(cx, 1500).await;
let focused = read_window(&picked.id);
let centred = focused.zip(display_size).is_some_and(|(rect, (width, _))| {
(rect.x + rect.width / 2. - width / 2.).abs() < width * 0.04
Expand All @@ -256,7 +280,10 @@ async fn probe_window_arrangement(
// Dismissed with the window still moved: only the dismissal can put it
// back.
overlay
.update(cx, |view, _, cx| view.set_focus(true, cx))
.update(cx, |view, _, cx| {
view.set_focus_center(true, cx);
view.set_focus(true, cx)
})
.ok();
sleep(cx, 1500).await;
let moved = !near(read_window(&picked.id), before);
Expand All @@ -267,12 +294,15 @@ async fn probe_window_arrangement(
serde_json::json!({
"passed": ratio_ok
&& inside(shaped)
&& stayed
&& centred
&& inside(focused)
&& unfocused_ok
&& restored_ok,
"before": rect_json(before),
"sixteenByNine": rect_json(shaped),
"focusWithoutCenter": rect_json(unmoved),
"focusWithoutCenterStayed": stayed,
"ratioOk": ratio_ok,
"focused": rect_json(focused),
"centred": centred,
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop-gpui/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ pub struct GeneralSettings {
pub recording_countdown: Option<u32>,
pub main_window_recording_start_behaviour: MainWindowStartBehaviour,
pub window_capture_style: WindowCaptureStyle,
pub focus_center: bool,
pub post_studio_recording_behaviour: PostStudioBehaviour,
pub post_screenshot_behaviour: PostScreenshotBehaviour,
pub post_deletion_behaviour: PostDeletionBehaviour,
Expand Down Expand Up @@ -1448,6 +1449,7 @@ impl GeneralSettings {
"mainWindowRecordingStartBehaviour",
),
window_capture_style: enum_at(general, "windowCaptureStyle"),
focus_center: bool_at(general, "focusCenter", false),
post_studio_recording_behaviour: enum_at(general, "postStudioRecordingBehaviour"),
post_screenshot_behaviour: enum_at(general, "postScreenshotBehaviour"),
post_deletion_behaviour: enum_at(general, "postDeletionBehaviour"),
Expand Down
Loading
Loading