After hard work, I have managed to write a working "widget canvas" for GTK-3.0. The user is able to move native GtkWidgets by dragging them around, pretty much like MDI.

However, moving a widget is slow. As soon as the number of widget increases, I get frametimes whell above 20 ms. After benchmarking, I have found that gtk_container_propagate_draw is a huge bottleneck:

ui/widget_canvas_internal.cpp:operator():73 29046505 ns

ui/line_segment_renderer.cpp:draw_callback:56  33100 ns

operator() basically calls gtk_container_propagate_draw on each child widget. The widgets mainly contains GtkLabels and GtkSliders.

For reference, here is a link to the project:


The widget canvas is found here

The purpose of the widget canvas is to implement a "Node editor", similar to what you find in Blender. Here is a screenshot:


The connections are drawn on top of the other widgets. The widget canvas is much like a GtkLayout, with support for multiple "layers".


Should I try to replace GTK-3.0 with something else, and if so, what? I think it is a good idea to know how good the library is at handling user movable widgets, so porting the UI part would be worth the effort. Target platform is currently GNU/Linux desktop.

  • I tend to recommend Qt, although I have not yet myself tested something similar to what you want to do on Linux. But if something is capable of that, it's Qt.
    – Sebastian
    Dec 25, 2020 at 11:07
  • @Sebastian Using QMdiArea? I see from the docs that QLayout does not have a "draw" callback like GtkContainer, so maybe that could be more efficient. May have a look at Qt later, though its integration with GTK-based desktop environments is not perfect.
    – user877329
    Dec 25, 2020 at 11:58
  • @Sebastian. Hmm Qt appears to allow "layoutless" placement. Maybe I should give it a shot. That is coming to GTK-4.0.
    – user877329
    Dec 25, 2020 at 12:08
  • I can't tell you which Qt library to use in particular, but I know 100% it can do what you want. And I don't see any issues with running it in a GTK environment. You are probably using a bunch of Qt-based apps already without knowing it.
    – Sebastian
    Dec 25, 2020 at 12:29


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.