I am looking for a GUI toolkit that I can use from plain C, that works at least on Linux and that does not force me to use its own eventloop – I want to use libev for the main loop and have it notify the toolkit library when X events come in or so.
I have not found anything like that – do I really have to patch a toolkit library to get what I want?
Unfortunately this demand probably seriously restricts what GUI toolkits you can choose from, since they're all so bad in this regard (among many others). I don't know if this is quite fair as an answer, but I'd like to propose to you a different solution: let the GUI toolkit run whatever event loop it wants to run in its own thread or process. Since GUI libraries are notoriously bad (crashing or exiting without warning), the "own process" version might actually be the best idea -- you could communicate with your UI via a pipe, and roll your own event loop like you want to in the main process. Threads of course have their own benefits: no need to serialize data shared with the GUI, and no need to worry about the case where the user kills the main program without killing the GUI or vice versa (since threads cannot be killed individually).
https://github.com/Immediate-Mode-UI/Nuklear
Nuklear is a GUI toolkit that only creates widgets, buttons, labels and similar but does not use a render backend on its own. You have to provide the render backend for it. You can use Xlib/X11 for the rendering. Xlib does not need a main loop. You can do something like this:
Nuklear has an example header file that provides the functions needed to combine Nuklear and Xlib, that can help you with steps 4 and 6: https://github.com/Immediate-Mode-UI/Nuklear/blob/master/demo/x11/nuklear_xlib.h
Nuklear has this features and disadvantages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With