mrkite / TerraFirma

Mapping for Terraria
http://seancode.com/terrafirma
BSD 2-Clause "Simplified" License
278 stars 61 forks source link

speed up mouse move #24

Closed flying-sheep closed 9 years ago

flying-sheep commented 9 years ago

improves or even fixes #23

I’m not sure if this is a good approach or even works as intended, but it dramatically increases responsiveness for me. Also it probably leaks all those MouseEvents because I can’t C++.

I call the idea “Sith threads”:

Two there should be; no more, no less. One to embody power, the other to crave it

One thread is running, the other queued. If the mouse is moved, the queued one is replaced by a new one. Once the running one is finished it will replace itself with the queued one.

This has an advantage over the “don’t run if last run is less than 100ms in the past” approach commonly used to “debounce” javascript, because this way after stopping the mouse, the correct update (the one triggered by the last event) will happen.

flying-sheep commented 9 years ago

your fix is still laggier than mine. let’s combine them.

should i do another PR or will you include it?

mrkite commented 9 years ago

Is it? I'm not seeing any lag at all on Windows 10 or Ubuntu.

flying-sheep commented 9 years ago

for me it still needs some fractions of a second after stopping the mouse until the statusbar arrives at its destination.

heavy mouse movement makes that half a second or so, which is annoying.