YaLTeR / niri

A scrollable-tiling Wayland compositor.
https://matrix.to/#/#niri:matrix.org
GNU General Public License v3.0
4.14k stars 123 forks source link

Implement Cursor Hiding While Typing & Cursor Inactive Timeout (#284) #709

Closed yzy-1 closed 1 month ago

yzy-1 commented 1 month ago

This pull request addresses the discussion on #284 regarding cursor management in niri. Specifically, I have implemented the second solution: hiding the cursor while typing.

The implementation of cursor timeout (solution 1) would require active polling to check the remaining time, which is not straightforward given our current design where all cursor-related updates are triggered by events. Implementing this approach would involve finding a suitable place in the codebase to handle the periodic checks, which I found challenging due to the existing event-driven architecture.

In contrast, hiding the cursor while typing (solution 2) can be seamlessly integrated as it aligns with the existing event-driven model. This implementation is more straightforward and reduces potential complexity.

Please review the changes and let me know if any further adjustments are needed.

yzy-1 commented 1 month ago

Sounds similar enough to the idle notifier code. That one's refreshed on every input event, but the cursor one could be refreshed on every pointer event instead.

Thanks for the feedback. You're right that it does have similarities with the idle notifier code. However, I believe cursor hiding should occur after a period of inactivity, which means there would be no corresponding pointer event (or even input::State::process_input_event will not be called) during that time.

I tried to implement this here, but the effect is that the cursor wouldn't hide until an input event occurred (like key press or something), essentially making the timeout ineffective.

yzy-1 commented 1 month ago

I check cursor timeout in function refresh_pointer_outputs and now it succeeds and works perfectly fine.

yzy-1 commented 1 month ago

OK. I resolved them all.

YaLTeR commented 1 month ago

I did some fixes, and I also had to reimplement the inactivity hiding as a timer after all, since otherwise it would fire late due to refresh() simply not being called when nothing is happening. Please test that this still works for you; otherwise it's good to merge.

yzy-1 commented 1 month ago

It worked perfectly! Thank you!

YaLTeR commented 1 month ago

Thanks