Find a file
Petros Amoiridis 714481073d
Fix macOS new window stacking (#38683)
Closes #36206 

Disclaimer: I did use AI for help to end up with this proposed solution.
😅

## Observed behavior of native apps on macOS (like Safari)

I first did a quick research on how Safari behaves on macOS, and here's
what I have found:

1. Safari seems to position new windows with an offset based on the
currently active window
2. It keeps opening new windows with an offset until the new window
cannot fit the display bounds horizontally, vertically or both.
3. When it cannot fit horizontally, the new window opens at x=0
(y=active window's y)
4. When it cannot fit vertically, the new window opens at y=0 (x=active
window's x)
5. When it cannot fit both horizontally and vertically, the new window
opens at x=0 and y=0 (top left).
6. At any moment if I activate a different Safari window, the next new
window is offset off of that
7. If I resize the active window and open a new window, the new window
has the same size as the active window

So, I implemented the changes based on those observations.

I am not sure if touching `gpui/src/window.rs` is the way to go. I am
open to feedback and direction here.

I am also not sure if making my changes platform (macOS) specific, is
the right thing to do. I reckoned that Linux and Windows have different
default behaviors, and the original issue mentioned macOS. But,
likewise, I am open to take a different approach.

## Tests

I haven't included tests for such change, as it seems to me a bit
difficult to properly test this, other than just doing a manual
integration test. But if you would want them for such a change, happy to
try including them.

## Alternative approach

I also did some research on macOS native APIs that we could use instead
of trying to make the calculations ourselves, and I found
`NSWindow.cascadeTopLeftFromPoint` which seems to be doing exactly what
we want, and more. It probably takes more things into consideration and
thus it is more robust. We could go down that road, and add it to
`gpui/src/platform/mac/window.rs` and then use it for new window
creation. Again, if that's what you would do yourselves, let me know and
I can either change the implementation here, or open a new pull request
and let you decide which one would you would like to pursue.

## Video showing the behavior


https://github.com/user-attachments/assets/f802a864-7504-47ee-8c6b-8d9b55474899

🙇‍♂️

Release Notes:

- Improved macOS new window stacking
2025-11-06 01:22:49 +00:00
.cargo ci: Update typos versions and fix new occurrences (#40784) 2025-10-21 10:43:22 +00:00
.cloudflare docs: Document context servers (#21170) 2024-11-25 11:05:14 -05:00
.config ci: Run slow tests first (#40769) 2025-10-21 09:58:26 +02:00
.github Re-enable preview auto-release (#41952) 2025-11-04 19:26:33 -07:00
.zed Remove agent1 code (#40495) 2025-10-17 18:49:11 +02:00
assets Revert "editor: Add action to move between snippet tabstop positions" (#42008) 2025-11-05 11:16:39 -05:00
ci Move Nightly release to gh-workflow (#41349) 2025-10-28 13:57:23 -06:00
crates Fix macOS new window stacking (#38683) 2025-11-06 01:22:49 +00:00
docs Update Windows docs (#41423) 2025-11-05 21:23:48 +00:00
extensions Fix path for vscode-html-language-server when found on PATH (#40832) 2025-10-22 22:44:25 -04:00
legal Fix the markdown table (#38729) 2025-09-23 16:49:45 +00:00
nix remote: Support building x86_64-linux-musl proxy in nix-darwin (#41291) 2025-10-28 06:58:09 +01:00
script Fetch (just) enough refs in script/cherry-pick (#41949) 2025-11-04 17:09:43 -07:00
tooling Re-enable preview auto-release (#41952) 2025-11-04 19:26:33 -07:00
.clinerules Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
.cursorrules Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
.git-blame-ignore-revs Add PR 15352 to .git-blame-ignore-revs (#30870) 2025-05-17 11:35:58 +00:00
.gitattributes windows: Make sure zed.sh using the correct line ending (#37650) 2025-09-05 16:25:55 +00:00
.gitignore Add linux_repo_snapshot got .gitignore (#40802) 2025-10-21 15:31:40 +00:00
.mailmap Update .mailmap (#30874) 2025-05-17 12:34:42 +00:00
.prettierrc ci: Add check for formatting default.json (#30034) 2025-05-06 18:55:26 +00:00
.rules Fix small spelling mistakes (#38284) 2025-09-16 21:58:40 +00:00
.windsurfrules Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
Cargo.lock Fix LSP spawning by resetting exception ports in child processes (#40716) 2025-11-05 22:05:34 +00:00
Cargo.toml Improve compare_perf.yml, cherry_pick.yml (#41606) 2025-11-04 11:29:35 -07:00
CLAUDE.md Initial .rules file for agent with symlinks for other rules file paths (#29014) 2025-04-17 23:41:23 +00:00
clippy.toml Fix shell welcome prompt showing up in Zed's stdout (#41311) 2025-10-27 20:04:36 +00:00
CODE_OF_CONDUCT.md Remove community content from docs and point to zed.dev (#19895) 2024-10-29 09:44:58 -04:00
compose.yml Remove PostgREST (#41299) 2025-10-27 13:27:59 -04:00
CONTRIBUTING.md Mention pure style changes in the contributing docs (#39096) 2025-09-29 11:02:47 +00:00
debug.plist WIP 2023-12-14 09:25:14 -07:00
default.nix Fix nix build (#26270) 2025-03-10 01:06:11 -07:00
docker-compose.sql collab: Setup database for LLM service (#15882) 2024-08-06 17:18:08 -04:00
Dockerfile-collab Bump Rust to 1.90 (#38436) 2025-09-22 14:36:10 -07:00
Dockerfile-collab.dockerignore ci: Move collab to Dockerfile-collab (#18515) 2024-09-30 16:14:26 -04:00
Dockerfile-cross.dockerignore Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
Dockerfile-distros Support More Linux (#18480) 2024-09-30 17:46:21 -04:00
Dockerfile-distros.dockerignore Support More Linux (#18480) 2024-09-30 17:46:21 -04:00
flake.lock Bump Rust to 1.90 (#38436) 2025-09-22 14:36:10 -07:00
flake.nix nix: Add job names and garnix substitutor (#31625) 2025-05-28 13:32:12 -07:00
GEMINI.md Add missing GEMINI.md rule file for gemini-cli (#38885) 2025-10-02 09:47:29 -04:00
LICENSE-AGPL Update license year (#24191) 2025-02-04 09:02:59 -05:00
LICENSE-APACHE Update license year (#24191) 2025-02-04 09:02:59 -05:00
LICENSE-GPL Licenses: change license fields in Cargo.toml to AGPL-3.0-or-later. (#5535) 2024-01-27 13:51:16 +01:00
livekit.yaml Add LiveKit server to Docker Compose (#7907) 2024-02-16 10:49:48 -05:00
lychee.toml ci: Check for broken links (#30844) 2025-06-06 09:39:35 +00:00
Procfile Update instructions for local collaboration (#35689) 2025-08-06 11:10:28 -07:00
Procfile.web Remove PostgREST (#41299) 2025-10-27 13:27:59 -04:00
README.md Restore Oxford comma in README (#40518) 2025-10-17 17:28:19 +00:00
renovate.json Remove workspace-hack (#40216) 2025-10-17 18:58:14 +00:00
REVIEWERS.conl Add Ben K to gpui PR reviewers (#41919) 2025-11-04 17:06:16 +00:00
rust-toolchain.toml Bump Rust to 1.90 (#38436) 2025-09-22 14:36:10 -07:00
shell.nix Fix nix build (#26270) 2025-03-10 01:06:11 -07:00
typos.toml project panel: Make updates asynchronous (#38881) 2025-10-02 11:40:09 +05:30

Zed

Zed CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager.

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.