spacehammer icon indicating copy to clipboard operation
spacehammer copied to clipboard

Modals have some delay

Open ihodes opened this issue 4 years ago • 6 comments

If I hit my keyboard shortcuts quickly enough (which I typically do), there is a <1s delay between hitting e.g. a in the first modal and the app switcher coming up in the next modal. In practice this means I have to wait between hitting keys in the modals of Spacehammer.

ihodes avatar Mar 25 '21 22:03 ihodes

The modules are lazy loaded, and would be reset every-time hammerspoon reloads config. In your personal init.fnl you could try preloading the application switcher module and see if that speeds it up, though it might slow down startup.

jaidetree avatar Mar 26 '21 23:03 jaidetree

Yeah, I don't know if the delay is just visual, or also affects the keyboard latency. For the first thing, you can try lowering the animation duration. In your ~/.spacehammer/config.fnl, right before config at the end, add this:

(set hs.window.animationDuration 0.1)

I don't know, perhaps we should consider setting it as the default value. I think the speed should be prioritized over the aesthetics.

update: Oh wait, what I am saying? This var has nothing to do with the modal animation.

This is what you can do, to improve the animation speed of the modals:

(tset hs.alert.defaultStyle :fadeInDuration 0.1)
(tset hs.alert.defaultStyle :fadeOutDuration 0.1)

@eccentric-j Is there a more elegant way of doing this? We don't have something like clojure.core/assoc, do we? (damn, it's been so long since I the last time I wrote anything in Fennel, I'm feeling out of touch)

agzam avatar Mar 28 '21 20:03 agzam

Unfortunately this doesn't seem to help (at least, noticeably); I still have to wait a beat between a and e.g. e for emacs, otherwise I have to hit e twice. I'll have to see if I can figure out how to preload the app switcher module, poked around a bit but didn't find what I needed.

ihodes avatar Mar 29 '21 03:03 ihodes

Yeah, typing ae quickly enough does sometimes result in keys getting "swallowed". I'm not sure at the moment if we can fix this quickly. Or even if that's Spacehammer's, Hammerspoon's, or OSX's problem. I have blazingly fast keyboard repeat rate, and I would love to be able to utilize that power, I don't want it to stutter when I'm switching between the apps.

agzam avatar Apr 26 '21 19:04 agzam

I suspect this has to do with some setup\teardown time of the https://www.hammerspoon.org/docs/hs.hotkey.modal.html system that powers the modal system.

I'll try creating a state machine that only manages a hs.hotkey.modal and see how fast that operates. If there's no noticeable delay or dropped keys then it's the modal logic, if there is a delay then it's either the state machines (unlikely, they're pretty light-weight), or the hs.hotkey.modal performance itself.

jaidetree avatar Sep 13 '21 12:09 jaidetree

@ihodes Could you please give #139 a shot? Just tested it now and it seems to have fixed that issue.

jaidetree avatar Sep 26 '21 19:09 jaidetree

Closing due to inactivity. Seems fixed.

Grazfather avatar Apr 21 '23 05:04 Grazfather