webview_gtk.h
The Linux webview backend (GTK3 + WebKitGTK).
#include <sonore/webview_gtk.h>- 2types
- 8other declarations
- Guides: The web editor
On this page
Design notes
Mirrors webview_win32.h: a child window the host embeds, a webview inside it, the window.sonore bridge injected before page script, and a ~30 Hz timer pushing parameters and meters into the page.
Linux specifics that shape this file:
- CLAP's X11 embedding hands us a raw X window id, and GTK plugs into it through gtk_plug_new(). A GtkPlug is the standard XEmbed client: it is what makes the plugin's widgets live inside the host's window rather than floating.
- WebKitGTK ships as webkit2gtk-4.1 (libsoup3) on current distros and 4.0 (libsoup2) on older ones, and the two CANNOT be loaded into one process together. Rather than link either, everything is resolved with dlopen at runtime, newest first: a plugin binary then runs on both, and a host that already pulled in the other version does not crash us. Linking directly is how a plugin ends up refusing to load on half the distros in the world.
- Same reason GTK itself is dlopened: hosts vary in what they already have.
When nothing can be loaded the plugin says so instead of showing a blank box.
Types 2
No comment on this one in the header yet; the source says the rest.
A webview inside a GtkPlug, embedded in the host's X11 window.
Same contract as the Win32 backend: create() works immediately, everything else tolerates not being ready, and destroy() is safe at any point.
Functions 2
- fn
template <typename Fn> inline void bind(void* lib, const char* name, Fn* out, Api* api)Load a symbol, recording the first miss so the failure names itself.gtk::bind · webview_gtk.h:100 - fn
inline Api& api()Resolve GTK + WebKit once per process.gtk::api · webview_gtk.h:111
Aliases 2
Constants 4
- const
constexpr int kInjectAtDocumentStart = 0Injection time for a user script: at document START, so the bridge exists before any page script runs (mirrors AddScriptToExecuteOnDocumentCreated).gtk::kInjectAtDocumentStart · webview_gtk.h:190 - const
constexpr int kInjectTopFrameOnly = 1WEBKIT_USER_CONTENT_INJECT_TOP_FRAME: the page's own document, not every frame in it (0 is ALL_FRAMES).gtk::kInjectTopFrameOnly · webview_gtk.h:193 - const
constexpr int kPolicyNewWindowAction = 1gtk::kPolicyNewWindowAction · webview_gtk.h:196