Open Kentzo opened 2 months ago
FWIW I see something similar but only seems to be when Terminal.app is frontmost app.
I tried to debug this by adding an observer for NSWindow.didMoveNotification
/ NSWindow.didResizeNotification
in MenuHeaderView.viewDidMoveToWindow
:
Looks like when you release the Option key, the window gets incorrectly resized, here is the backtrace:
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x0000000100f293d8 in closure #2 in MenuHeaderView.viewDidMoveToWindow() at Maccy/Maccy/Menu/MenuHeader/MenuHeaderView.swift:62
#1 0x0000000100f2932c in thunk for @escaping @callee_guaranteed @Sendable (@in_guaranteed Notification) -> () ()
#2 0x000000018818f130 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#3 0x00000001882233d8 in ___CFXRegistrationPost_block_invoke ()
#4 0x0000000188223320 in _CFXRegistrationPost ()
#5 0x000000018815d678 in _CFXNotificationPost ()
#6 0x000000018927a4e4 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#7 0x000000018ba3c0c8 in -[NSWindow _setFrameCommon:display:fromServer:] ()
#8 0x000000018c0f8804 in -[NSPopupMenuWindow setFrame:display:animate:] ()
#9 0x000000018c0f8178 in -[NSPopupMenuWindow updateWindowFrameTo:withAnimation:] ()
#10 0x000000018bff2828 in -[NSContextMenuImpl _menuBackingViewDidChangeIntrinsicSizeWithAnimation:] ()
#11 0x000000018bff2454 in -[NSContextMenuImpl _commitWindowSizeChangesForWidth:height:animated:] ()
#12 0x000000018bff2294 in -[NSContextMenuImpl endGroupingUpdates] ()
#13 0x000000018c20fd60 in -[NSCocoaMenuImpl _updateModifierFlagsTo:groupingUpdates:] ()
#14 0x000000018c0381dc in -[NSMenuTrackingSession _modifierFlagsChanged:] ()
#15 0x000000018c037cb4 in -[NSMenuTrackingSession handleEvent:] ()
#16 0x000000018c037150 in -[NSMenuTrackingSession startRunningMenuEventLoop:] ()
#17 0x000000018c76a8e4 in -[NSContextMenuTrackingSession startMonitoringEventsInMode:] ()
#18 0x000000018bff0310 in +[NSContextMenuImpl presentPopup:fromView:withContext:animated:] ()
#19 0x000000018c218b40 in _NSPopUpMenu ()
#20 0x000000018c21d398 in -[NSCocoaMenuImpl _popUpMenuPositioningItem:atCocoaIndex:atLocation:inView:withPrivateFlags:appearance:] ()
#21 0x000000018c093a80 in -[NSMenu popUpMenuPositioningItem:atLocation:inView:appearance:] ()
#22 0x0000000100f3be40 in Menu.popUpMenu(at:ofType:) at Maccy/Maccy/Menu/Menu.swift:92
#23 0x0000000100ee334c in closure #1 in closure #1 in MenuController.popUp() at Maccy/Maccy/Menu/MenuController.swift:29
#24 0x0000000100ee3ca4 in MenuController.linkingMenuToStatusItem(_:) at Maccy/Maccy/Menu/MenuController.swift:79
#25 0x0000000100ee3190 in closure #1 in MenuController.popUp() at Maccy/Maccy/Menu/MenuController.swift:28
#26 0x0000000100ee3e68 in MenuController.withFocus(_:) at Maccy/Maccy/Menu/MenuController.swift:120
#27 0x0000000100ee3024 in MenuController.popUp() at Maccy/Maccy/Menu/MenuController.swift:23
#28 0x0000000100f52ab0 in Maccy.popUp() at Maccy/Maccy/Maccy.swift:99
#29 0x0000000100f66fc0 in implicit closure #2 in implicit closure #1 in AppDelegate.applicationDidFinishLaunching(_:) at Maccy/Maccy/AppDelegate.swift:31
#30 0x0000000100f7f91c in thunk for @escaping @callee_guaranteed () -> () ()
#31 0x0000000100f7f564 in thunk for @escaping @callee_guaranteed () -> (@out ()) ()
#32 0x0000000100f7e580 in static KeyboardShortcuts.handleOnKeyDown(_:) at KeyboardShortcuts/Sources/KeyboardShortcuts/KeyboardShortcuts.swift:82
#33 0x0000000100f7df40 in implicit closure #1 in static KeyboardShortcuts.register(_:) at KeyboardShortcuts/Sources/KeyboardShortcuts/KeyboardShortcuts.swift:26
#34 0x0000000100f78634 in static CarbonKeyboardShortcuts.handleEvent(_:) at KeyboardShortcuts/Sources/KeyboardShortcuts/CarbonKeyboardShortcuts.swift:142
#35 0x0000000100f782f4 in carbonKeyboardShortcutsEventHandler(eventHandlerCall:event:userData:) at KeyboardShortcuts/Sources/KeyboardShortcuts/CarbonKeyboardShortcuts.swift:4
#36 0x0000000100f79130 in @objc carbonKeyboardShortcutsEventHandler(eventHandlerCall:event:userData:) ()
#37 0x0000000192914444 in DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) ()
#38 0x0000000192913844 in SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) ()
#39 0x0000000192929cd8 in SendEventToEventTarget ()
#40 0x000000018c1ec6c8 in -[NSApplication(NSEventRouting) sendEvent:] ()
#41 0x000000018be3a89c in -[NSApplication _handleEvent:] ()
#42 0x000000018b9eb0c0 in -[NSApplication run] ()
#43 0x000000018b9c22e0 in NSApplicationMain ()
#44 0x0000000100f6b034 in main at Maccy/Maccy/AppDelegate.swift:9
#45 0x0000000187d320e0 in start ()
Don't know if it's a bug or a misuse yet.
Removing https://github.com/p0deje/Maccy/blob/211f327ba5d1bcbbae34df976719626c664a2907/Maccy/Menu/Menu.swift#L91 fixes the issue, although the window appears not centered on the active screen but slightly off.
I was able to consistently reproduce inside a clean VM (using VirtualBuddy) with just Maccy installed.
I have this fixed in 2.0, but it's going to be a couple of weeks until I release the first alpha. In 2.0, Maccy uses NSPanel instead of NSMenu which makes window manipulation much easier than it currently is.
It appears that post-popup adjustment of window position is the true culprit here https://github.com/p0deje/Maccy/blob/211f327ba5d1bcbbae34df976719626c664a2907/Maccy/Menu/Menu.swift#L429
Personally I prefer the window to appear slightly off rather than jump around.
Before Submitting Your Bug Report
Maccy Version (see 'About' window)
0.31.0
macOS Version
14.4.1
Maccy Settings
Description
See the attached video:
https://github.com/p0deje/Maccy/assets/88809/fdd4de5c-b9f2-49d3-8057-50893f13ba69
Refs #631
Steps to Reproduce
One way to reproduce it is to summon the popup window then press ⌥. Another way is to summon the popup window and then release the shortcut keys such that the ⌥ is released the last.