gui: a Command-click on the Mac's menu bar icon is left to the system, which drags the icon with it (#792, BennettChina) — Hidden Bar's users move icons with Command-drag, and magpie's icon opened its panel instead. The tray's click handler now reads the held modifiers ([NSEvent modifierFlags]) and does nothing when Command is down; other systems are unchanged. go vet, builds (darwin with the GUI, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./internal/gui/ under a temp HOME pass; the drag itself wasn't exercised here (it would move icons in the owner's live menu bar).
This commit is contained in:
1 parent
28a830fc5c
commit
3cdb7fb3a5
3 files changed
+28
No files matched your search
@@ -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()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//go:build !nogui
|
||||
|
||||
package gui
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -x objective-c
|
||||
#cgo LDFLAGS: -framework Cocoa
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
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 }
|
||||
@@ -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 }
|
||||
Reference in new issue
Block a user