Skip to content

Commit a4ac2ec

Browse files
synleclaude
andcommitted
feat: smart shrink all windows during Tile Snap drag
Previously only oversized windows (≥85% of display) were shrunk when dragging. Now all windows are resized to 60% of the smallest display (or app min size if larger) centered on cursor when a title-bar drag is confirmed. Gives a consistent drag experience and makes snap zones visible around the window. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ddc8c4b commit a4ac2ec

2 files changed

Lines changed: 37 additions & 42 deletions

File tree

src-tauri/src/tiling/macos.rs

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,10 +2028,10 @@ fn handle_snap_event(ctx: &SnapContext, event_type: u64, cursor: CGPoint) {
20282028
);
20292029
}
20302030

2031-
// If the window is oversized (e.g. coming from
2032-
// maximize/fullscreen), shrink it to smart size
2033-
// centered on the cursor so the user can see snap
2034-
// zones while dragging.
2031+
// Shrink the window to smart size (60% of smallest
2032+
// display, or app min if larger) centered on the
2033+
// cursor. This gives a consistent drag experience
2034+
// and makes snap zones visible around the window.
20352035
if let Some((sw, sh)) = state.drag_start_window_size {
20362036
let start_rect = Rect {
20372037
x: sx,
@@ -2043,45 +2043,40 @@ fn handle_snap_event(ctx: &SnapContext, event_type: u64, cursor: CGPoint) {
20432043
&start_rect,
20442044
&state.displays,
20452045
);
2046-
if is_rect_oversized(
2047-
&start_rect,
2048-
&state.displays[di],
2049-
) {
2050-
let app_min = unsafe {
2051-
get_focused_window()
2052-
.and_then(|w| get_window_min_size(&w))
2053-
};
2054-
let smart =
2055-
calculate_smart_restore_rect_at_cursor(
2056-
&state.displays,
2057-
di,
2058-
cursor.x,
2059-
cursor.y,
2060-
app_min,
2061-
);
2062-
unsafe {
2063-
if let Some(w) = get_focused_window() {
2064-
set_window_rect(&w, &smart);
2065-
}
2066-
}
2067-
state.drag_start_window_pos =
2068-
Some((smart.x, smart.y));
2069-
state.drag_start_window_size =
2070-
Some((smart.width, smart.height));
2071-
if let Some(dbg_state) =
2072-
ctx.app.try_state::<crate::AppState>()
2073-
{
2074-
crate::config::write_debug_log(
2075-
&dbg_state,
2076-
&format!(
2077-
"tile_snap: smart shrink — oversized window shrunk to \
2078-
({:.0},{:.0} {:.0}x{:.0}), app_min={:?}",
2079-
smart.x, smart.y, smart.width,
2080-
smart.height, app_min,
2081-
),
2082-
);
2046+
let app_min = unsafe {
2047+
get_focused_window()
2048+
.and_then(|w| get_window_min_size(&w))
2049+
};
2050+
let smart =
2051+
calculate_smart_restore_rect_at_cursor(
2052+
&state.displays,
2053+
di,
2054+
cursor.x,
2055+
cursor.y,
2056+
app_min,
2057+
);
2058+
unsafe {
2059+
if let Some(w) = get_focused_window() {
2060+
set_window_rect(&w, &smart);
20832061
}
20842062
}
2063+
state.drag_start_window_pos =
2064+
Some((smart.x, smart.y));
2065+
state.drag_start_window_size =
2066+
Some((smart.width, smart.height));
2067+
if let Some(dbg_state) =
2068+
ctx.app.try_state::<crate::AppState>()
2069+
{
2070+
crate::config::write_debug_log(
2071+
&dbg_state,
2072+
&format!(
2073+
"tile_snap: smart shrink — window shrunk to \
2074+
({:.0},{:.0} {:.0}x{:.0}), app_min={:?}",
2075+
smart.x, smart.y, smart.width,
2076+
smart.height, app_min,
2077+
),
2078+
);
2079+
}
20852080
}
20862081

20872082
// Now show drop zone indicators

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/nicoverbruggen/tauri-v2-docs/refs/heads/main/schemas/config.schema.json",
33
"productName": "Display DJ",
4-
"version": "6.3.5",
4+
"version": "6.3.6",
55
"identifier": "com.synle.display-dj",
66
"build": {
77
"beforeDevCommand": "npm run dev",

0 commit comments

Comments
 (0)