Repository navigation
Catch Cmd+W on macOS before the input method swallows it - #260
Merged
Merged
Conversation
Cocoa hands Cmd+W to Qt through keyDown:, and QNSView tries it as a shortcut only while no input method composition is pending. With a pinyin or other IME mid-composition the chord goes to the input method instead and the window stays open. A native Close is a menu key equivalent and wins ahead of that; a local NSEvent monitor on the composition window restores the same order and relays the chord to the host, which asks the window to leave the way the QML Shortcut does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release Notes
Why
#214 fixed the shortcut context, and offscreen the close chord works from every app context, with the app menu, a tooltip, a focused compose field or the calendar up (new tests cover the first two). What remained is a path below Qt: Cocoa delivers Cmd+W through
keyDown:, andQNSView handleKeyEvent:only tries the key as a shortcut whenm_composingTextis empty. During an IME composition the chord is handed to the input method and either dropped or delivered as plain text, so the QMLShortcutnever fires. A native app's Close is a menu key equivalent and is handled before the input method.What changed
window_macos.mm: a localNSEventmonitor takes Cmd+W (Command only, watched window is key) off the stream and calls the host; other platforms keep a no-op stub.ApplicationHostgainsrequestClose()/closeRequested();Main.qmlrelays it tomailApp.requestClose(), so the window still hides through the host and the process stays alive for the Dock.HostFixtureexposescloseRequested;tst_standalone_compositioncovers the host relay plus the open-menu and visible-tooltip cases.No visual change, so no screenshots.
Verification
QT_QPA_PLATFORM=offscreen ctest --test-dir app/build7/7,python3 app/tests/test_qml_inventory.py,bash tests/test_source.sh,python3 tests/test_qml_names.py.window_macos.mmhas not been compiled. Please runmake app-runon macOS, type a few uncommitted pinyin letters in the search field, press Cmd+W, and confirm the window hides.🤖 Generated with Claude Code