Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up window switching timers #3237

Merged
merged 4 commits into from
Mar 6, 2023

Conversation

kjslag
Copy link
Contributor

@kjslag kjslag commented Jun 18, 2022

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.

Copy link

@github-actions github-actions bot left a comment

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

@@ -224,11 +224,11 @@ local function exit(self)
-- if windows[selected]:application():bundleID()~='com.apple.finder' then
-- 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
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
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
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
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
Copy link

github-actions bot commented Jul 1, 2022

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.
@@ -224,11 +224,11 @@ local function exit(self)
-- if windows[selected]:application():bundleID()~='com.apple.finder' then
-- 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()

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