Fix bidirectional clipboard support in Emscripten builds:

SDL2 prevents the default action for Ctrl/Cmd key events on Emscripten,
which stops browsers from emitting the native paste event.

Intercept Ctrl/Cmd+V before SDL2 consumes it, allow the browser paste
event to update the internal clipboard, and replay the keydown so the
application executes its normal paste command.

Also refresh the clipboard through the asynchronous Clipboard API when
opening a context menu, enabling paste actions triggered without a
keyboard shortcut.

Export Emscripten's ccall runtime method so the browser clipboard helper
can reliably invoke its C++ callbacks in optimized builds, and disable
clang-format for the header containing embedded JavaScript.
This commit is contained in:
Martín Lucas Golini
2026-08-10 00:32:01 -03:00
parent 357f00c8ed
commit d31e880cc3
3 changed files with 37 additions and 2 deletions

View File

@@ -659,7 +659,7 @@ function build_link_configuration( package_name, use_ee_icon )
add_cross_config_links()
configuration "emscripten"
linkoptions { "-s TOTAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1 -s USE_SDL=2 -s ENVIRONMENT=worker,web" }
linkoptions { "-s TOTAL_MEMORY=536870912 -s ALLOW_MEMORY_GROWTH=1 -s USE_SDL=2 -s ENVIRONMENT=worker,web -s EXPORTED_RUNTIME_METHODS=ccall" }
buildoptions { "-s USE_SDL=2" }
buildoptions { "-s USE_PTHREADS=1" }
linkoptions { "-s USE_PTHREADS=1 -sPTHREAD_POOL_SIZE=8" }