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

Hsearch call chooser:hide() block me 3 seconds #2449

Open
Sean10 opened this issue Sep 4, 2020 · 1 comment
Open

Hsearch call chooser:hide() block me 3 seconds #2449

Sean10 opened this issue Sep 4, 2020 · 1 comment

Comments

@Sean10
Copy link

Sean10 commented Sep 4, 2020

When i open the hammerspoon console, hide()/show() has no blocked time. When i switch to other program, i press option+g show the chooser which has no blocked time.When i need to press option+g again to hide it , there is always 3 seconds which i have to wait. I add print to find which function cause the block, i found the obj.chooser:hide() cause the stuck. But i don't know how to debug objective-c, is there anyone has the same situation like me ?

environment: 10.12.6
spoon: HSearch.spoon
line: 224-254.

@latenitefilms I have updated the code and log, could you give me any suggestion?

function obj:toggleShow()
    if #obj.sources_overview == 0 then
        -- If it's the first time HSearch shows itself, then load all sources from files
        obj:loadSources()
        -- Show sources overview, so users know what to do next.
        obj.chooser:choices(obj.sources_overview)
    end
    if obj.chooser:isVisible() then
        print(1)
        -- hs.timer.doAfter(0, function() obj.chooser:hide() end)
        obj.chooser:hide()
        print(2)
        obj.trigger:disable()
        print(3)
        for _,val in pairs(obj.hotkeys) do
            for i=1,#val do
                print(5)
                val[i]:disable()
            end
        end
    else
        if obj.trigger == nil then
            obj.trigger = hs.hotkey.bind("", "tab", nil, function() obj:switchSource() end)
        else
            obj.trigger:enable()
        end
        for key,val in pairs(obj.hotkeys) do
            if key == obj.source_kw then
                for i=1,#val do
                    val[i]:enable()
                end
            end
        end
        obj.chooser:show()
    end
end

normal

when I open the console, i get the log below.

2020-09-05 00:18:08: 00:18:08     hotkey: Enabled hotkey TAB
2020-09-05 00:18:09: 1
2020-09-05 00:18:09: 00:18:09     hotkey: Disabled hotkey TAB
2020-09-05 00:18:09: 2
2020-09-05 00:18:09: 3
2020-09-05 00:18:09: 5

blocked

But when i work on chrome/vscode forefround, i get the blocked log below.

2020-09-05 00:18:14: 00:18:14     hotkey: Enabled hotkey TAB
2020-09-05 00:18:16: 1
2020-09-05 00:18:18: 00:18:18     hotkey: Disabled hotkey TAB
2020-09-05 00:18:18: 2
2020-09-05 00:18:18: 3
2020-09-05 00:18:18: 5
@latenitefilms
Copy link
Contributor

Can you share your code?

You could try wrapping the chooser:hide() in a hs.timer.doAfter(0, function() chooser:hide() end)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants