zed icon indicating copy to clipboard operation
zed copied to clipboard

Enable unfocused windows to update their status based on whether they are clickable or not

Open Kalmaegi opened this issue 1 year ago • 3 comments

  • Fixed #9784 By removing the interception of the MouseMove event, zed can update the corresponding Hover even when it is inactive

Kalmaegi avatar Apr 06 '24 09:04 Kalmaegi

Thanks for the pull request, @weartist!

I genuinely don't remember why we were ignoring move events if the window was not the active one. I think we were trying to replicate the behavior on macOS? e.g.

https://github.com/zed-industries/zed/assets/482957/10e0a960-b5cc-4e33-bc14-7b4a8cc21912

However, after https://github.com/zed-industries/zed/pull/9553, I guess we'll be able to receive clicks even when the window is not focused. Interestingly, it seems like something that not all elements opt into doing though...

So my only concern with these changes is the sheer amount of move events all windows will receive even when not focused. Like, is each window going to observe a mouse event at all times when the mouse moves now? Can we double check what impact that has on the CPU? Thanks! 🙏

as-cii avatar Apr 16 '24 08:04 as-cii

Thanks for the pull request, @weartist!

I genuinely don't remember why we were ignoring move events if the window was not the active one. I think we were trying to replicate the behavior on macOS? e.g.

Export-1713255079552.mp4 However, after #9553, I guess we'll be able to receive clicks even when the window is not focused. Interestingly, it seems like something that not all elements opt into doing though...

So my only concern with these changes is the sheer amount of move events all windows will receive even when not focused. Like, is each window going to observe a mouse event at all times when the mouse moves now? Can we double check what impact that has on the CPU? Thanks! 🙏

Your concern is right, and the good news is that we only have one window at most that can receive the event, and need that window to be the topmost window of the current mouse position. So I guess it shouldn't have much of an impact on CPU usage, because if the event is received by our window, then the window is currently in a state where it should be received, later I can test it with instrument

Kalmaegi avatar Apr 16 '24 10:04 Kalmaegi

Providing a time profile parsing file, I opened three ZED windows during testing, one of which contained ZED's source code project, and the other two were slightly smaller, I'm a beginner for time profile, and if someone can have a better way or find someting, I think it would be great

revceive_move_event.trace.zip

image

Kalmaegi avatar Apr 17 '24 07:04 Kalmaegi

I just confirmed that the move event will only be dispatched on one window, so I think we're good. Thanks @weartist!

as-cii avatar Apr 24 '24 08:04 as-cii