Skip to main content

Module video_surface

Module video_surface 

Source
Expand description

The native video surface mpv renders into (UR-080 / DR-231).

Linux-gated because the surface is GTK. Everything around it — the render context, its lifetime, frame pacing, the device profile — is not. The native video surface: mpv drawn behind Tauri’s webview, without touching the widget tree.

§Why there is no overlay here

The obvious arrangement — wrap the webview in a GtkOverlay with a GtkGLArea beneath — attaches cleanly and then aborts the process on the first click. tauri-runtime-wry connects a button-press handler to the webview that walks a hard-coded path:

webview.parent()          // "This one should be GtkBox"
       .parent()          // ...and this one the GtkWindow
       .downcast::<gtk::Window>().unwrap()

An overlay makes that chain webview → GtkOverlay → GtkBox, the downcast fails, and because the panic is non-unwinding it takes the app with it. Nothing in configuration avoids it: on Linux the handler is attached unconditionally (the Windows path guards it behind is_decorated()), and the decoration check that would make it inert runs after the unwrap.

So the widget tree is left exactly as Tauri built it. GTK draws a container before its children, so rendering into the vbox’s own draw handler puts the picture underneath the webview for free — the same z-order, no reparenting, one less widget, and nothing a Tauri upgrade can invalidate by assuming its own layout.

TRACES: UR-080 | DR-231, DR-232, DR-233, IR-033

Structs§

SurfaceState 🔒
Everything the draw handler needs, shared with the GTK callbacks.
VideoSurface
A live video surface. Dropping it tears the render context down.

Constants§

GL_TEXTURE 🔒
GL enum for gdk_cairo_draw_from_gl’s source_type. GDK takes the GL constant itself rather than an enum of its own.
LIVE_SURFACE 🔒
The one live surface, on the GTK main thread.

Functions§

attach
Start drawing mpv’s video underneath the webview.
detach
Drop the live surface, if there is one. Idempotent.
draw 🔒
Draw the current frame, if there is one.
init_gl 🔒
Create the GL context and the mpv render context over it.
on_mpv_update 🔒
mpv’s update callback. Runs on an mpv thread, so it does the least possible: flags the state and asks GTK to redraw on the main loop.