Repository navigation
cvcGL: Cmd as the shortcut key in a browser on a Mac (stacked on #1536) - #1539
Merged
Merged
Conversation
ImGui 1.92.9 with ConfigMacOSXBehaviors (its default on Apple) swaps Cmd and Ctrl in AddKeyEvent, so a host sends Cmd as ImGuiMod_Super. The overlay sent VTK's control flag as ImGuiMod_Ctrl, which became Super: - VTK's own window: its Cocoa view sets the one control flag for Cmd or Ctrl (vtkCocoaGLView.mm). Cmd+Z did not undo and typed a "z", since ImGui drops characters only under its own Ctrl. Under Mac behaviours the flag (and its Control_L/R) now goes in as Super. - cvcGL's SDL3 window dropped the GUI key. SdlRenderWindowInteractor's GetSuperKey() now carries SDL_KMOD_GUI, and the overlay hands ImGui Ctrl and Super as they are, as imgui_impl_sdl3 does. cvcgl_imgui_overlay_keys drives a real overlay through a VTK interactor with Mac behaviours forced on and off, with no window and no GL. cvcgl_sdl_attach checks the GUI key on SDL's window and through the overlay. ARIADNE.md says what pick mods mean on a Mac.
On Windows imgui is linked into cvcGL and into each test, each with its own current context. cvcgl_imgui_overlay_keys and cvcgl_sdl_attach set only cvcGL's (ImGuiBackend::setImGuiContext), so their own ImGui calls asserted on "No current context" (exit 0xc0000409 on package-windows). They now set both, as cvcgl_imgui_touch_scroll does.
A wasm build has no __APPLE__, so ImGui's Mac behaviours were off in every browser, a Mac's included: Ctrl was the shortcut key and the menus said "Ctrl+". ImGuiOverlay now reads the page's platform (navigator.userAgentData.platform, else navigator.platform) and turns them on for a Mac, iPhone or iPad; ?mackeys=1|0 overrules it. SDL hands the browser's Meta over as Super, and leaves Cmd+V's keydown to the browser, so the paste event the clipboard reads still comes. A Mac sends no key-up for a key let go while Cmd is down (Chrome and Safari; Cocoa unless the app asks, as SDL does). Left down, Cmd+Z's Z repeated the undo for as long as Cmd was held, until the field was empty. Under Mac behaviours a press under Cmd is now a tap, and Cmd's release lets go of any key still down. arigl_web_mac_keys.mjs runs arigl-web in headless Chrome told it is on a Mac (DevTools' user-agent override): Cmd+Z, Ctrl+Z, Cmd held with no key-up for Z, Cmd+V's paste, and Ctrl again under ?mackeys=0. CI's arigl-web job runs it, and now also when the overlay changes. cvcgl_imgui_key_names checks the platform names, and cvcgl_imgui_overlay_keys the missing key-up.
transfix
force-pushed
the
feat/ari-web-mac-cmd
branch
from
November 25, 2026 20:05
0bb103e to
0f11405
Compare
# Conflicts: # .github/workflows/ci.yml
This was referenced Nov 26, 2026
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.
Stacked on #1536. The first commit (625a796) is #1536's own. This PR's change is the second commit, 0bb103e. The base is master so that ci.yml runs. Merge #1536 first. Don't merge this one without Joe's OK.
In a browser on a Mac, arigl-web now uses Cmd as the shortcut key: Cmd+Z, C, V, X and A in a field, and "Cmd+" in the menus, as a native Mac build does. Until now Ctrl was the shortcut key in every browser, a Mac's included.
Why it was Ctrl
ImGui turns its Mac behaviours (
io.ConfigMacOSXBehaviors) on from__APPLE__, and a wasm build has no__APPLE__. So Ctrl was the shortcut key in every browser, andImGuiBackend'smod()labels said "Ctrl+".The change (
src/cvcGL/ImGuiOverlay.cpp)navigator.userAgentData.platform, elsenavigator.platform. On a Mac, iPhone or iPad (isApplePlatformName, inImGuiKeyNames.h) it turns the Mac behaviours on.?mackeys=1or?mackeys=0overrules the detection. A host can still set the flag itself after the overlay is made.cvcGL: Cmd is the shortcut key (the page's platform 'macOS').Emscripten_HandleKeycancels every keydown that hasctrlKey, but not one withmetaKey. So Cmd+V's keydown is left to the browser, and thepasteevent thatClipboard.cppreads still arrives. The browser test checks this.CVCGL_SDL_WINDOW=0) reads onlyctrlKey, so on a Mac Ctrl stays the shortcut key there, under cvcGL: Cmd+Z, C, V, X and A in an ImGui field on a Mac (the overlay's modifier keys) #1536's rule for a window with one control flag.Tests
src/arigl/web/test/arigl_web_mac_keys.mjsruns arigl-web in headless Chrome. DevTools'Emulation.setUserAgentOverridemakes the page see a Mac'snavigator.platform(MacIntel) anduserAgentData.platform(macOS). It checks:pasteediting command stands in for the Mac key binding), and the field takes the text.?mackeys=0, Ctrl is the shortcut key again: Cmd+Z does nothing and Ctrl+Z undoes.arigl-webjob runs the new test. Its path filter now also coversImGuiOverlay.cpp,ImGuiKeyNames.handSdlWindow.cpp; before this, an overlay change didn't trigger the browser job.cvcgl_imgui_key_nameschecks which platform names count as Apple's.cvcgl_imgui_overlay_keyschecks the missing key-up under VTK's window with Mac behaviours on: one undo with Cmd held, a second Z undoing again, and Cmd's release letting go of a key held from before it.Local results. Linux, with a single-threaded arigl-web built by the recipe's
build-wasm.shfrom cvcpkg's emsdk and wasm deps, and Chrome 152 headless:arigl_web_mac_keys.mjs: 12 of 12.arigl_web_clipboard.mjs: 10 of 10.arigl_web_smoke.mjs: 25 of 25.''). The three native key-up checks fail too.cvcgl_imgui_*,cvcgl_sdl_*,cvcgl_camera_sdl_fly,cvcgl_ariadne_pick,cvcgl_ariadne_node_pickandcvcgl_tf_editorset, under cvcpkg's Xvfb.Not verified: a real Mac. Everything above is Chrome on Linux told it runs on a Mac, with the missing key-ups simulated.
macOS lanes: CI/CD run 45585022967 on
ci/full/ari-web-mac-cmd. The tap changes native Mac behaviour too.A separate bug, not fixed here
On a page that isn't on a Mac, SDL cancels Ctrl+V's keydown because
ctrlKeymakes it a "nav key". So the browser never fires itspasteevent, and Ctrl+V pastes nothing from the system clipboard into an arigl-web field.A probe on this build showed it: the keydown was cancelled, no paste event came, and the field stayed
ab.arigl_web_clipboard.mjs's Ctrl+V step passes anyway because it dispatches the paste event itself, before the keys. ARIADNE.md §5.28's "Ctrl+V works as it always did, through the page's paste event" is untrue under SDL's window.