Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The window jumps when the Option (⌥) is pressed #777

Closed
2 tasks done
Kentzo opened this issue May 7, 2024 · 9 comments
Closed
2 tasks done

The window jumps when the Option (⌥) is pressed #777

Kentzo opened this issue May 7, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@Kentzo
Copy link

Kentzo commented May 7, 2024

Before Submitting Your Bug Report

  • I have verified that there isn't already an issue reporting the same bug to prevent duplication.
  • I have seen the FAQ.

Maccy Version (see 'About' window)

0.31.0

macOS Version

14.4.1

Maccy Settings

{
    "KeyboardShortcuts_delete" = "{\\"carbonModifiers\\":2048,\\"carbonKeyCode\\":51}";
    "KeyboardShortcuts_pin" = "{\\"carbonModifiers\\":2048,\\"carbonKeyCode\\":35}";
    "KeyboardShortcuts_popup" = "{\\"carbonModifiers\\":2304,\\"carbonKeyCode\\":8}";
    "LaunchAtLogin__hasMigrated" = 1;
    "NSStatusItem Visible Item-0" = 0;
    "NSWindow Frame SUStatusFrame" = "1080 961 400 134 0 0 2560 1415 ";
    "NSWindow Frame SUUpdateAlert" = "970 762 620 398 0 0 2560 1415 ";
    "NSWindow Frame com.sindresorhus.Preferences.FrameAutosaveName" = "1039 469 542 435 0 0 2560 1415 ";
    "NSWindow Frame com.sindresorhus.Settings.FrameAutosaveName" = "993 667 442 322 0 0 2560 1415 ";
    SUEnableAutomaticChecks = 0;
    SUHasLaunchedBefore = 1;
    SULastCheckTime = "2024-05-07 17:12:09 +0000";
    SUSendProfileInfo = 0;
    WebKitDefaultFontSize = 13;
    WebKitJavaScriptEnabled = 0;
    WebKitPluginsEnabled = 0;
    WebKitStandardFont = "-apple-system-font";
    WebKitUserStyleSheetEnabledPreferenceKey = 1;
    WebKitUserStyleSheetLocationPreferenceKey = "/Applications/Maccy.app/Contents/Frameworks/Sparkle.framework/Resources/ReleaseNotesColorStyle.css";
    avoidTakingFocus = 1;
    clearOnQuit = 0;
    enabledPasteboardTypes =     (
        "public.html",
        "public.utf8-plain-text",
        "public.rtf"
    );
    hideFooter = 1;
    hideTitle = 1;
    historySize = 999;
    ignoredPasteboardTypes =     (
        "com.typeit4me.clipping",
        "Pasteboard generator type",
        "net.antelle.keeweb",
        "de.petermaurer.TransientPasteboardType",
        "com.agilebits.onepassword"
    );
    imageMaxHeight = 16;
    maxMenuItemLength = 80;
    maxMenuItems = 16;
    migrations =     {
        "2020-04-25-allow-custom-ignored-types" = 1;
        "2020-06-19-use-keyboardshortcuts" = 1;
        "2020-09-01-ignore-keeweb" = 1;
        "2021-02-20-allow-to-customize-supported-types" = 1;
        "2021-06-28-add-title-to-history-item" = 1;
        "2021-10-16-remove-dynamic-pasteboard-types" = 1;
        "2022-08-01-rename-suppress-clear-alert" = 1;
        "2022-11-14-add-html-rtf-to-supported-types" = 1;
        "2023-01-22-add-regexp-search-mode" = 1;
    };
    pasteByDefault = 0;
    playSounds = 0;
    popupPosition = center;
    previewDelay = 99000;
    searchMode = fuzzy;
    showInStatusBar = 0;
}

Description

See the attached video:

Window.Jumping.Issue.mp4

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.

@Kentzo Kentzo added the bug Something isn't working label May 7, 2024
@afragen
Copy link

afragen commented Jun 5, 2024

FWIW I see something similar but only seems to be when Terminal.app is frontmost app.

@Kentzo
Copy link
Author

Kentzo commented Jul 11, 2024

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.

@Kentzo
Copy link
Author

Kentzo commented Jul 11, 2024

Removing

prepareForPopup(location: locationType)
fixes the issue, although the window appears not centered on the active screen but slightly off.

@Kentzo
Copy link
Author

Kentzo commented Jul 11, 2024

Tracked it to

item.keyEquivalent = String(hotKey)

@Kentzo
Copy link
Author

Kentzo commented Jul 18, 2024

I was able to consistently reproduce inside a clean VM (using VirtualBuddy) with just Maccy installed.

@p0deje
Copy link
Owner

p0deje commented Jul 18, 2024

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.

@Kentzo
Copy link
Author

Kentzo commented Jul 19, 2024

It appears that post-popup adjustment of window position is the true culprit here

menuWindow?.setFrameTopLeftPoint(point)

Personally I prefer the window to appear slightly off rather than jump around.

@Kentzo
Copy link
Author

Kentzo commented Jul 31, 2024

@p0deje
Copy link
Owner

p0deje commented Sep 16, 2024

Fixed in 2.0

@p0deje p0deje closed this as completed Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants