Description
The Linux C code event loop only returns after the hotkey was pressed. The hotkey can not be canceled while waitHotkey waits for a new hotkey. hk.Unregister() can be successfully called, but the hotkey is only unregistered after it was triggered.
Steps to reproduce
- Register a simple hotkey on Linux
- Unregister the hotkey
Notes
hk := h.New([]h.Modifier{h.ModCtrl}, h.KeyM)
hk.Register()
go func() {
time.Sleep(time.Second * 1)
fmt.Println("Hotkey will be unregistered")
hk.Unregister()
fmt.Println("Hotkey unregistered")
hk.Register()
fmt.Println("Registered again")
}()
<-hk.Keydown()
This code blocks. I would expect the chan to be closed and the program to exit.
|
while(1) { |
|
XNextEvent(d, &ev); |
|
switch(ev.type) { |
|
case KeyPress: |
|
hotkeyDown(hkhandle); |
|
continue; |
|
case KeyRelease: |
|
hotkeyUp(hkhandle); |
|
XUngrabKey(d, keycode, mod, DefaultRootWindow(d)); |
|
XCloseDisplay(d); |
|
return 0; |
|
} |
|
} |
|
} |
I would expect that the above loop checks, if the hotkey was unregistered.
XNextEvent also blocks until the next event, but that should be fine as long as a lot of events are triggered. Else something like
XPending could be used to check, if new events can be processed.
Description
The Linux C code event loop only returns after the hotkey was pressed. The hotkey can not be canceled while
waitHotkeywaits for a new hotkey.hk.Unregister()can be successfully called, but the hotkey is only unregistered after it was triggered.Steps to reproduce
Notes
This code blocks. I would expect the
chanto be closed and the program to exit.hotkey/hotkey_linux.c
Lines 64 to 77 in a5dde31
I would expect that the above loop checks, if the hotkey was unregistered.
XNextEventalso blocks until the next event, but that should be fine as long as a lot of events are triggered. Else something likeXPendingcould be used to check, if new events can be processed.