Hi everyone,
I’ve been working on a GTK4 backend for HighGUI and wanted to get some feedback before turning this into a formal PR, mainly around scope and whether some of the changes cross lines that shouldn’t be crossed.
the basic part is straightforward. detect gtk4 with pkg config add HAVE_GTK4 register a GTK4 backend and add a new window_gtk4.cpp that implements things natively using gtk4 apis drawing area snapshot gdktexture event controllers etc. that part feels pretty mechanical and similar to how gtk3 or qt were added in the past just without reusing any old gtk code
Here are where things get opinionated and require some input from people working on opencv: i also changed cvWaitKey so that it first goes through getCurrentUIBackend()->waitKeyEx() and only falls back to the old per-backend functions if no backend is active. this is what allows the gtk4 backend to own its event loop without adding a separate cvWaitKey_GTK4 path
inside window_gtk4.cpp i ended up routing the legacy C API entry points like cvNamedWindow cvShowImage cvDestroyWindow etc directly to the gtk4 backend instead of relying on the old gtk code. this avoids touching window_gtk.cpp at all for gtk4 but it does mean gtk4 implements those symbols itself
the gtk4 backend pumps the glib main context inside waitKeyEx using g_main_context_iteration to preserve the usual highgui blocking behavior
none of this changes behavior for existing backends but it does change how gtk4 integrates with the highgui dispatch logic so i wanted to check if this direction is acceptable or if some of these things should be done differently before submitting anything upstream. Thanks for reading