mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 04:44:30 +00:00
ca9cee85e1
Closes #17870 Context: On Linux, when creating a new window, bounds are either pulled from existing workspace data (serialized in an SQLite DB) or fall back to some default constants if no data exists. These bounds include the full dimensions of the window (width and height), which already account for insets. However, properties like `inset` (Wayland) or `last_insets` (X11) exist only at the platform level and are not part of the window bounds themselves. During rendering, we call `set_client_inset`, which updates the inset values and also adjusts the window bounds, increasing their dimensions. In Zed's case, the inset is 10px, which adds 20px to both the width and height (10px from each side). Problem: When quitting, the full window bounds (which already account for inset) are saved to the DB. On reopening, these saved bounds are used to create the window. `set_client_inset` runs again and inflates the dimensions even more. Solution: Store window bounds *without* the inset-inflated dimensions. On the next session, `set_client_inset` will take care of applying the inset, resulting window dimensions matching the previous session. This fix is in the PR. Alternative Solution: Another option is to save the inset explicitly in the DB and apply it during window creation. But this means storing more data, and the inset would need to be platform-agnostic, which adds complexity. Doesn’t seem worth it for no real gain. X11 Before: ```sh saving window bounds with width: 1136, height: 784 tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.37s Running `target/debug/zed` saving window bounds with width: 1156, height: 804 <---- +20px tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s Running `target/debug/zed` saving window bounds with width: 1176, height: 824 <---- +20px tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.36s Running `target/debug/zed` saving window bounds with width: 1196, height: 844 <---- +20px ``` X11 After: ```sh Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s Running `target/debug/zed` saving window bounds with width: 1116, height: 764 tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s Running `target/debug/zed` saving window bounds with width: 1116, height: 764 <---- same tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s Running `target/debug/zed` saving window bounds with width: 1116, height: 764 <---- same ``` On Wayland, saving occurs only when you actually resize the window (on X11, saving happens both on init and while dragging the window). To trigger saving, I manually resized the window by ~1px to make it print. Wayland Before: ```sh Finished `dev` profile [unoptimized + debuginfo] target(s) in 1m 36s Running `target/debug/zed` saving window bounds with width: 945, height: 577 tims@orange ~/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.77s Running `target/debug/zed` saving window bounds with width: 966, height: 597 <--- +20px on both (1px increase in width is me resizing) tims@orange ~/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.87s Running `target/debug/zed` saving window bounds with width: 987, height: 618 <--- +20px on both (1px increase in width and height is me resizing) tims@orange ~/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s Running `target/debug/zed` saving window bounds with width: 1006, height: 638 <--- +20px on both (1px decrease in width is me resizing) ``` Wayland After: ```sh Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.82s Running `target/debug/zed` saving window bounds with width: 925, height: 558 tims@orange ~/zed (fix-window-growing-larger)> cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.84s Running `target/debug/zed` saving window bounds with width: 925, height: 557 <--- same (1px decrease in height is me resizing) saving window bounds with width: 925, height: 558 ``` Release Notes: - Fix non-maximized zed windows growing larger across sessions on Linux --------- Co-authored-by: mgsloan@gmail.com <michael@zed.dev> |
||
---|---|---|
.. | ||
app | ||
elements | ||
keymap | ||
platform | ||
text_system | ||
window | ||
action.rs | ||
app.rs | ||
arena.rs | ||
asset_cache.rs | ||
assets.rs | ||
bounds_tree.rs | ||
color.rs | ||
element.rs | ||
executor.rs | ||
geometry.rs | ||
global.rs | ||
gpui.rs | ||
input.rs | ||
interactive.rs | ||
key_dispatch.rs | ||
keymap.rs | ||
platform.rs | ||
prelude.rs | ||
scene.rs | ||
shared_string.rs | ||
shared_uri.rs | ||
style.rs | ||
styled.rs | ||
subscription.rs | ||
svg_renderer.rs | ||
taffy.rs | ||
test.rs | ||
text_system.rs | ||
util.rs | ||
view.rs | ||
window.rs |