diff --git a/internal/gui/app.go b/internal/gui/app.go index 53870fee..886feb1f 100644 --- a/internal/gui/app.go +++ b/internal/gui/app.go @@ -438,6 +438,9 @@ func Run(version string, showMain bool, link string) error { // the quick panel by the icon, or the main window if the user would // rather (Settings → Tray icon) h.tray.OnClick(func() { + if cmdClick() { + return // Command-drag moves the icon; the system handles it + } if runtime.GOOS == "darwin" { go h.flap() } diff --git a/internal/gui/cmdheld_darwin.go b/internal/gui/cmdheld_darwin.go new file mode 100644 index 00000000..f628d014 --- /dev/null +++ b/internal/gui/cmdheld_darwin.go @@ -0,0 +1,19 @@ +//go:build !nogui + +package gui + +/* +#cgo CFLAGS: -x objective-c +#cgo LDFLAGS: -framework Cocoa +#import + +static int commandHeld(void) { + return ([NSEvent modifierFlags] & NSEventModifierFlagCommand) != 0; +} +*/ +import "C" + +// cmdClick says whether Command was held as the icon was clicked: the Mac +// drags a menu bar icon with Command, so the click is the system's, not +// magpie's (BennettChina, #792: Hidden Bar's users move icons so). +func cmdClick() bool { return C.commandHeld() != 0 } diff --git a/internal/gui/cmdheld_other.go b/internal/gui/cmdheld_other.go new file mode 100644 index 00000000..d5ca3b80 --- /dev/null +++ b/internal/gui/cmdheld_other.go @@ -0,0 +1,6 @@ +//go:build !darwin && !nogui + +package gui + +// cmdClick: only the Mac drags its tray icons with a modifier. +func cmdClick() bool { return false }