Closed seanliang closed 1 year ago
As a record, I just tested the example on my M2 MacBook Air, it works on macOS 12.6
Now I am upgrading my system and let's see what happens in macOS13.
After upgrade to macOS 13, the example still works for me. Please provide more information regarding why it stuck for you.
Close due to no response.
Sorry for the late response. Here is the files I tested.
go.mod
module test
go 1.18
require (
golang.design/x/hotkey v0.4.0
golang.design/x/mainthread v0.3.0
)
main.go
package main
import (
"golang.design/x/hotkey"
"golang.design/x/mainthread"
)
func main() {
mainthread.Init(fn)
}
func fn() {
hk := hotkey.New([]hotkey.Modifier{hotkey.ModCtrl, hotkey.ModShift}, hotkey.KeyS)
println("start of registration")
err := hk.Register()
if err != nil {
panic("hotkey registration failed")
}
println("hotkey registered")
<-hk.Keydown()
println("hotkey ctrl+s is triggered")
}
running these commands in terminal:
test % go clean --cache
test % go build
test % ./test
start of registration
^C
As you can see from the log, the program is stuck on hk.Register()
.
When I debug in VSCode, it just stop on the line hotkey_darwin.go#54
which statement is ret := C.registerHotKey(C.int(mod), C.int(hk.key), C.uintptr_t(h), &hk.hkref)
.
I'm not familiar with cgo, if I step into it, it says Could not load source '_cgo_gotypes.go': Unsupported command: cannot process "source" request.
, not sure how to go deeper.
What happens if you do this?
- "golang.design/x/mainthread"
+ "golang.design/x/hotkey/mainthread"
Great. It solves the problem. Thanks a lot!
I didn't aware that there were two packages named 'mainthread', the first one is imported by VSCode automatically and it works under x86_64 arch.
The program is just stuck on
err := hk.Register()
, no error raised. But if I downgrade to version 0.2.1, it works.Affected Versions: 0.3.0, 0.4.0 OS: macOS 13.0 CPU: M1 Pro