Skip to content

Speed up window switching timers - #3237

Merged
cmsj merged 4 commits into
Hammerspoon:masterfrom
kjslag:fasterWindowSwitching
Mar 6, 2023
Merged

Speed up window switching timers#3237
cmsj merged 4 commits into
Hammerspoon:masterfrom
kjslag:fasterWindowSwitching

Conversation

@kjslag

@kjslag kjslag commented Jun 18, 2022

Copy link
Copy Markdown
Contributor

Window switching with hs.window.switcher is noticeably slower than the default cmd-tab. This small patch decreases various timers to make the speed feel the same. Note: I decreased a timer that's supposed to prevent an el cap bug, but I couldn't test if this reintroduces the el cap issue.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: pr-fix, pr-change, pr-feature, pr-maintenance

Comment thread extensions/window/window_switcher.lua Outdated
-- windows[selected]:focus()
-- else
timer.doAfter(0.15,function()windows[selected]:focus()end) -- el cap bugs out (desktop "floats" on top) if done directly
timer.doAfter(0.01,function()windows[selected]:focus()end) -- el cap bugs out (desktop "floats" on top) if done directly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW El Capitan is no longer supported by Hammerspoon, so we could see what happens if we remove the timer.doAfter() wrapper and just directly call windows[selected]:focus()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested. Directly calling it seems to work well for me. Should I change it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for not replying - yeah I think we should change it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I just committed the change

@cmsj cmsj added the pr-change Pull Request changing behaviour label Jul 1, 2022
@github-actions

github-actions Bot commented Jul 1, 2022

Copy link
Copy Markdown

View Test Results

342 tests   288 ✔️  1h 3m 2s ⏱️
    2 suites    52 💤
    1 files        2

For more details on these failures, see this check.

Results for commit d70796d.

El Capitan is no longer supported by Hammerspoon, so we no longer need the timer delay workaround.
Comment thread extensions/window/window_switcher.lua Outdated
-- windows[selected]:focus()
-- else
timer.doAfter(0.15,function()windows[selected]:focus()end) -- el cap bugs out (desktop "floats" on top) if done directly
function()windows[selected]:focus()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(E011) expected identifier near '('

@cmsj
cmsj merged commit e0e8d95 into Hammerspoon:master Mar 6, 2023
@cmsj cmsj changed the title speedup window switching timers Speed up window switching timers Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-change Pull Request changing behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants