scopehal-apps icon indicating copy to clipboard operation
scopehal-apps copied to clipboard

Migrate from GLFW to SDL

Open azonenberg opened this issue 1 year ago • 8 comments

GLFW has a bunch of bugs related to mouse handling on Linux causing false mouse-up events when a new platform window is created.

There may be ugly hacks we can do on the backend, but SDL doesn't have this issue so that's probably the best path forward. We only make 20ish GLFW API calls so the port shouldn't be too difficult.

See: https://github.com/ocornut/imgui/issues/7922

azonenberg avatar Nov 02 '24 23:11 azonenberg

Hate to say it (actually I kinda enjoy it, sorry 🤣), but didn't I propose also switching to SDL2 already when we switched to imgui? It's a much newer and better backend than glfw.

But glad you're finally convinced. It'd open up some more interesting ports as well.

(also offering dev time here to actually make it happen)

Johnsel avatar Nov 03 '24 01:11 Johnsel

Tagging just for posterity: it appears https://github.com/ocornut/imgui/issues/7733 (a minor annoyance that had been plaguing us for a while) is rooted in the same bug and can also be fixed by leaving GLFW.

azonenberg avatar Nov 03 '24 12:11 azonenberg

FYI if there are hacks to do on the GLFW backend its worth adding them imho. All backends have hacks/quirks, as the windowing emulation of multi-viewports is generally a bit out of the typical expected scope of SDL/GLFW. I would just need to understand exactly what’s the low level issue (perhaps that info is already detailed in existing high-level issues).

ocornut avatar Nov 03 '24 13:11 ocornut

FYI if there are hacks to do on the GLFW backend its worth adding them imho. All backends have hacks/quirks, as the windowing emulation of multi-viewports is generally a bit out of the typical expected scope of SDL/GLFW. I would just need to understand exactly what’s the low level issue (perhaps that info is already detailed in existing high-level issues).

It appears the root cause is https://github.com/glfw/glfw/issues/1562#issuecomment-827366508.

If you can add a workaround on the ImGui side, that would be great.

azonenberg avatar Nov 03 '24 14:11 azonenberg

I posted a tentative workaround here: https://github.com/ocornut/imgui/issues/7733#issuecomment-2454518221 Would be nice if you can also test it on your end.

ocornut avatar Nov 04 '24 19:11 ocornut

Keeping this open as a potential future trajectory for the project, but no longer a v0.2 priority now that there is an imgui workaround for the specific GLFW issues in play.

azonenberg avatar Nov 05 '24 03:11 azonenberg

Another potential reason to migrate: contains built in file chooser functionality (SDL_ShowOpenFileDialog) which would let us drop a couple of dependencies

azonenberg avatar May 02 '25 17:05 azonenberg

GLFW does not make it easy to integrate with platform-specific functionality. Switching to SDL3 or another toolkit that integrates better would also allow us to correctly fix #890 on macOS.

d235j avatar Sep 09 '25 15:09 d235j