HumbleUI / JWM

Cross-platform window management and OS integration library for Java
Apache License 2.0
561 stars 44 forks source link

Get rid of sleep(0.5ms) in X11 event loop #129

Closed tonsky closed 2 years ago

tonsky commented 3 years ago

https://github.com/JetBrains/JWM/blob/c6762d5c61a8cb06dae5023ca43ddd43b87698cf/linux/cc/WindowManagerX11.cc#L195

Problem:

Ideas:

dzaima commented 2 years ago

I have a poll-based event loop here that brings background CPU usage down to a nice 0%, and works on whatever I've thrown at it; if that seems like a good way to go forward, I can PR that.

tonsky commented 2 years ago

I will need some time to restore the context back, will take a look. @Alex2772 what do you think?

Alex2772 commented 2 years ago

IMHO the solution is quite elegant except it's hard to understand the magic of the buffer size.

PR is welcome!

dzaima commented 2 years ago

The pipe should only ever have a maximum of 2 characters in it, so a buffer size of two should be technically fine. Nevertheless I made it somewhat bigger just in case (don't want to use too much stack though); I'll add some comments & PR tomorrow