Repository navigation
cvcGL: SDL3 owns the onscreen window, one input path on every platform - #829
Merged
Merged
Conversation
Keyboard and mouse input reached a document a different way on each
platform: SDL3 wrapped VTK's HWND on Windows, listened on the page in the
browser, and on X11, Wayland and macOS arigl fell back to VTK's key events,
because SDL cannot take a foreign window cleanly there (on X11 its XInput2
selection takes VTK's clicks; on Wayland it opens a separate toplevel).
Now SDL makes the onscreen window and its OpenGL context, VTK renders into
that context, and SDL's events drive VTK's interactor. The camera,
ImGuiOverlay and anything else observing the interactor still see ordinary
VTK events, and SdlInput gets the same events in SDL's names.
src/cvcGL/SdlWindow.{h,cpp} are modelled on VTK's SDL2 pair; VTK has no
SDL3 classes. SdlGLRenderWindow is a vtkOpenGLRenderWindow on an SDL window
(OpenGL, resizable, high pixel density) with a 3.2 core context. It loads
GL through SDL_GL_GetProcAddress and swaps with SDL_GL_SwapWindow. Its size
is the drawable's, in pixels, as in VTK's own windows. Title, position,
cursor show/hide/warp/shape, fullscreen and screen size go through SDL.
SDL's video leaves the process as VTK's windows did: the screensaver,
signal handlers, X11's compositor and the Windows DPI awareness stay as
they were. A window SDL cannot open stays empty and never touches GL.
SdlRenderWindowInteractor drains SDL's queue into VTK events. Keys get X11
keysyms (the unshifted key's) and the character they type as the key code.
Text input becomes Latin-1 CharEvents, clicks land at their pixel with y
up, and wheel steps can be fractional. Resize, expose, enter/leave and
close are handled too. VTK timers run on SDL timers. SDL has one queue per
process, so an event of another cvcGL window is kept for that window's
interactor. Registered sinks see each event of the window first.
ViewportManager makes onscreen windows SDL's when cvcGL has SDL3.
$CVCGL_SDL_WINDOW=0 keeps VTK's own window, and so does SDL failing to
open one. Offscreen windows (snapshots, the terminal scene, the golden
images) stay VTK's.
SdlInput::attach subscribes to the window's interactor instead of wrapping
the Win32 HWND. Under VTK's window it reads VTK's key events, and the
browser keeps its page listener. poll() leaves SDL's queue alone while a
cvcGL SDL window is open, and shutdown() drops pending events.
ariadne_hello attaches its SdlInput to the window, as arigl does.
CameraController recenters the pointer with SetCursorPosition. VTK's own
X11 window has none, so under it the warp still goes through Xlib. The
clipboard is SDL's while SDL's video is up, which covers Wayland.
cvcgl_sdl_attach covers the new window: keysyms and key codes, CharEvents,
clicks, SdlInput's copy of the events, resize, a VTK timer, routing
between two windows, an unattached SdlInput, and the $CVCGL_SDL_WINDOW=0
fallback. On Windows it also sends a key message through SDL's window
procedure.
The browser keeps VTK's canvas window for now. SDL owning the canvas and
its WebGL2 context is the next step.
transfix
force-pushed
the
feat/sdl3-window
branch
from
October 28, 2026 19:40
ee61971 to
d9b237e
Compare
transfix
marked this pull request as ready for review
October 28, 2026 19:41
The package lanes configured cvcGL without SDL3 ("SDL3 not found"), so its
SDL window and SdlInput's window path were compiled nowhere in CI, and
cvcgl_sdl_attach skipped. Install sdl3 next to VTK and imgui, as the
shipped cvcgl recipe has it. A configure that does not find it now fails,
as one without the Ariadne terminal backends does. On Linux the window
opens on Xvfb with Mesa's llvmpipe.
transfix
force-pushed
the
feat/sdl3-window
branch
from
October 28, 2026 19:42
d9b237e to
4e39263
Compare
The test exited 0 when it skipped (no SDL, or SDL opened no window), so ctest printed "Passed" either way, and a CI lane that should exercise cvcGL's SDL window could not be told from one that never opened it. It now exits 77 on a skip, registered as its SKIP_RETURN_CODE, as physics_replay_test does.
transfix
added a commit
that referenced
this pull request
Oct 29, 2026
The project version and the cvcpkg recipe family move to 3.7.4. Every recipe is at cvc_revision 1 already, so none restarts. 3.7.4 carries the whole plant ledger on every plant (#876): plant_sample's vehicle contact and what each plant measures, the dynamic plants' building and vehicle contacts and attitude, nav_stats' vehicle_hits, cvc/nav/plant_ledger.h, and publish_nav_stats writing every item, n/a where a plant does not measure it. demo3's Ledger screen (CVC-DBG/cvcdbg#256) reads it. It also carries SDL3 owning cvcGL's onscreen window (#829), state_exec's state-incr, state-cas and state-swap (#860), and Ariadne's window fitting (#828) and room relay test counting (#867).
This was referenced Nov 3, 2026
Merged
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.
Why
Keyboard and mouse input should reach a document the same way on every platform. Until now SDL3 wrapped VTK's window on Windows, listened on the page in the browser, and on X11, Wayland and macOS arigl fell back to VTK's key events. SDL can't wrap a foreign window cleanly on those: on X11 its XInput2 selection takes VTK's clicks, and on Wayland it opens a separate toplevel.
So SDL3 now owns the onscreen window. SDL creates the window and its OpenGL context, VTK renders into that context, and SDL's events drive VTK's interactor. The camera, ImGuiOverlay and anything else observing the interactor still see ordinary VTK events, and SdlInput gets the same events in SDL's names.
What's here
src/cvcGL/SdlWindow.{h,cpp}, modelled on VTK's old SDL2 pair; VTK has no SDL3 classes.SdlGLRenderWindow, avtkOpenGLRenderWindow:SDL_GL_GetProcAddressand swaps withSDL_GL_SwapWindow;SdlRenderWindowInteractor:CharEvents, clicks at their pixel with y up, fractional wheel steps, resize, expose, enter/leave and close;ViewportManagermakes onscreen windows SDL's when cvcGL has SDL3.$CVCGL_SDL_WINDOW=0keeps VTK's own window, and so does SDL failing to open one (with a message on stderr). Offscreen windows (snapshots, the terminal scene, the golden images) stay VTK's.SdlInput::attachsubscribes to the window's interactor and no longer drains SDL's queue itself. The Win32 HWND wrap is gone. Under VTK's window it uses VTK's key events. AnSdlInputthat is not attached leaves SDL's queue alone while a cvcGL SDL window is open.ariadne_hellonow attaches itsSdlInputto the window, as arigl does.CameraControllerrecenters the pointer throughvtkRenderWindow::SetCursorPosition. VTK's own X11 window has noSetCursorPosition, so under it the warp still goes through Xlib.cvcgl_sdl_attachis rewritten for the new window. It checks keysyms and key codes,CharEvents, clicks, SdlInput's copy of the events, resize, a VTK timer, routing between two windows, an unattachedSdlInput, and the$CVCGL_SDL_WINDOW=0fallback. On Windows it also checks a key message through SDL's window procedure.Tested
cvcgl_sdl_attachandcvcgl_sdl_inputpass.cvcgl_*/arigl_*ctest tests pass, includingcvcgl_imgui_*,cvcgl_ari_goldenandcvcgl_ari_switch. Of the other five:ariglterminal tests skip because this build has no FTXUI;cvcgl_fe_intervalcrashes in LBIE's mesher. It never opens a window, and a master build on the same machine crashes at the same point.ariadne_runtime_test: 181/181.arigl run fem_gallery.ariandariadne_hello hello.ariopen SDL's window, run, and exit 0 when the window is closed.Not done yet (phase 2)