714481073d4d68b7bd2e452fbcf688100723e837
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
Zed
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:
- Web (tracking issue)
Developing Zed
- Building Zed for macOS
- Building Zed for Linux
- Building Zed for Windows
- Running Collaboration Locally
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 specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor 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 theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Description
Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Readme
586 MiB
Languages
Rust
94.7%
JSON-with-Comments
3.1%
Inno Setup
0.6%
Scheme
0.5%
Shell
0.3%
Other
0.4%