zed
zed copied to clipboard
Wayland: Improve first click detection
Release Notes:
- N/A
This changes the first click detection in Wayland by requiring first click after the keyboard loses focus, and after a wl_pointer
enters a window that has keyboard focus
On Linux, this isn't expected behaviour. I thought there was a bug with Zed. In case there's a reason to keep it on macOS, it could be feature gated.
EDIT: It seems like the value of first_mouse
is wrong on Wayland. The documentation states this:
https://github.com/zed-industries/zed/blob/89039f6f34910fadce76c73258b731f0a016ccd6/crates/gpui/src/interactive.rs#L104-L105
But the Wayland client code checks only if it's the first mouse click after re-entering the window, not if it focused the window.
Hmm, I opened this because even if focus on the window, the window first expects a click before expanding a directory. I think I will keep this open
EDIT: It seems like the value of
first_mouse
is wrong on Wayland. The documentation states this:https://github.com/zed-industries/zed/blob/89039f6f34910fadce76c73258b731f0a016ccd6/crates/gpui/src/interactive.rs#L104-L105
But the Wayland client code checks only if it's the first mouse click after re-entering the window, not if it focused the window.
Will change this pr to handle this instead
Edit: Now the behavior should be the same as vscode, if you alt-tab
it will not be considered first-click.
We talked about this on discord before, and @mikayla-maki mentioned this is intentional:
I personally never noticed that this is also the behavior on vscode. I don't know the reason for it though.
Edit: I'm not saying that I like this behavior. I don't know where this comes from, and I also thought it's a bug and wish this was at least configurable.
We talked about this on discord before, and @mikayla-maki mentioned this is intentional:
I personally never noticed that this is also the behavior on vscode. I don't know the reason for it though.
Edit: I'm not saying that I like this behavior. I don't know where this comes from, and I also thought it's a bug and wish this was at least configurable.
I'll close this patch then, one thing that might be annoying is even if we alt-tab
to the window, making it focused, it expects a click.
We talked about this on discord before, and @mikayla-maki mentioned this is intentional:
I personally never noticed that this is also the behavior on vscode. I don't know the reason for it though.
Edit: I'm not saying that I like this behavior. I don't know where this comes from, and I also thought it's a bug and wish this was at least configurable.
The issue here is that the first_mouse
field indicates whether the window was focused due to that specific mouse click. However, the Wayland client incorrectly checks if it is the first wl_pointer::Event::Button
after a wl_pointer::Event::Enter
.
This means that if you move your mouse pointer outside Zed's window (without the need to unfocus the window) you'll have to click at least once before being able to open files in the project panel.
@apricotbucket28 yeah, this certainly doesn't seem quite right! Also what @XDeme1 mentioned about alt tabbing into the window and still requiring an extra click doesn't seem to be intended.
@XDeme1 I wouldn't close this. At least wait for some input from mikayla or other zed maintainers.
I still think it should also be an option to let me open files on the first click, even on an unfocused window. Would be nice to find out where this behavior (or the intended version of it) even came from.
The PR that introduced first_mouse
was also about handling the first mouse click https://github.com/zed-industries/zed/pull/9553 (focusing clicks on macOS were completely ignored)
VSCode does seem to ignore focusing clicks (only) on the project panel, but I don't really get why. If I select a file on Dolphin and click on a Firefox tab without focusing, it'll switch to that tab nonetheless.
- Thanks for fixing the bug! We should definitely merge that.
- I found the project panel opening a file when focusing the window to be confusing, and considered that corroborated by VSCode’s behavior. I’d suggest leaving it like that, and maybe opening another PR to add a setting or otherwise discuss the issue.
Thanks for fixing the bug! We should definitely merge that.
- I found the project panel opening a file when focusing the window to be confusing, and considered that corroborated by VSCode’s behavior. I’d suggest leaving it like that, and maybe opening another PR to add a setting or otherwise discuss the issue.
I've opened #11396 to discuss a creation of an option to allow users to override this behavior of clicking again to open files/directory.
This patch right now Fixes the issues mentioned by @apricotbucket28, and allow users to open files/directories if they alt tabbed. The only problem right now is if they alt tab with the mouse on top of the window, it considers a first_click
.
Edit: I've fixed the bug I mentioned, now I believe the project panel is behaving exactly like in VScode.
Thank you!