Haiku backend in GTK/GDK?

I read some discussions in the forum about GTK. But I could not get the feeling if there is some fundamental reason there is not yet an Haiku backend for GDK. I have skimmed over the source files for other backends (Wayland, Quartz, Broadway) which are already implemented and does not seems an impossible project. Did somebody already tried?. (Personally, the main motivation would be to have Inkscape available in Haiku).

2 Likes

It’s possible and there isn’t any technical limitation for this other than the language used and its likely to be an out-of-tree implementation due to the Haiku API being only accessible via C++ whereas GTK/GDK appears to accept C-based implementations. (Parts of the Quartz implementation are in Objective-C).

It’s unlikely that it will be ever upstreamed if someone does this anyway, but then again that could change.

I see no problem that it will be not upstream.

One of problems in porting GTK3 it that it display window border themselves, but Haiku display window border in app_server. Default GTK3 theme also use window semi-transparency that is not supported by app_server.

GTK3 uses the system window borders on Windows and macOS though, so there’s some way to get that behavior.

Yes, seems that on Mac the borders look ok. Maybe I will give a look.

One thing to be aware of when doing these things is that in Haiku a window is always a separate thread running its own event loop. If GTK expects all callbacks to happen in the main thread instead, you need to somehow forward events between the two threads.

Drawing strategy can also be a concern, normally in Haiku there is no buffering, apps draw directly to the framebuffer and need to be able to redraw any part at any time on request from the app_server. If that doesn’t work for GTK, you will need to have it draw offscreen to a BBitmap and have code to copy data from that BBitmap to the display. It has been done (for example in WebKit and in the LibreOffice native backend, and I guess probably in the Qt backend as well).

So, nothing impossible, it’s just quite some work and there are these caveats to know about.

2 Likes