7c53c0f184
The `!darwin` guard on the modifier helpers was too broad: golang.design/x/ hotkey only exposes its Mod*/Key* constants from the darwin&&cgo, linux&&cgo and windows backends, while the `!windows && !cgo` complement (e.g. Linux cross-builds with CGO_ENABLED=0) falls back to a stub with no constants. That made hk.ModCtrl/ModShift/KeyA... undefined and produced editor/vet warnings. Realign the build tags with the upstream matrix and confine every hk.* constant to a tagged file so the shared hotkey.go compiles everywhere. Also fix the Linux mapping (option -> hk.Mod1; hk.ModAlt does not exist on X11).
19 lines
735 B
Go
19 lines
735 B
Go
//go:build linux && cgo
|
|
|
|
package hotkey
|
|
|
|
import hk "golang.design/x/hotkey"
|
|
|
|
// On Linux we map "cmd" to Ctrl so the same config string ("cmd+shift+a")
|
|
// stays meaningful across platforms.
|
|
//
|
|
// The X11 backend exposes modifiers as Mod1..Mod5 rather than named Alt/Option
|
|
// constants; Mod1 is the conventional Alt mask under X11, so "option"/"alt"
|
|
// resolve to hk.Mod1. This file is gated on cgo because the constants only
|
|
// exist in the cgo-backed linux implementation (CGO_ENABLED=0 falls back to a
|
|
// stub with no constants).
|
|
func modCmd() hk.Modifier { return hk.ModCtrl }
|
|
func modCtrl() hk.Modifier { return hk.ModCtrl }
|
|
func modOption() hk.Modifier { return hk.Mod1 }
|
|
func modShift() hk.Modifier { return hk.ModShift }
|