You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Linux CEF 146 native-windowed embedding support
CEF 146 on Ubuntu 24 (GNOME/Wayland) requires several coordinated fixes
to embed the browser in a native X11 window without a separate GUI toolkit
in user code. This commit implements all of them.
Embedding / window management
- WindowInfo.SetAsChild() on Linux now substitutes the X11 root window as
CEF's parent to avoid the Xwayland cross-client MatchError, and stores
the real parent XID in _linux_embed_info for deferred reparenting.
- _linux_schedule_xembed() polls until Chrome's window is IsViewable, then
XUnmapWindow + 100 ms GLib timer + XReparentWindow into the real parent.
Called from CreateBrowserSync() on both the direct and pending-browser
paths so the reparent always fires regardless of when Initialize() returns.
- When CreateBrowserSync() is called with no parent on Linux, the library
now auto-creates a GTK toplevel, embeds the browser, and registers
configure-event (resize) and delete-event (close) handlers — making
hello_world.py fully platform-agnostic.
Platform init helpers (window_utils_linux.pyx)
- _linux_gtk_init(): sets GDK_BACKEND=x11 before gtk_init() so GDK opens
an X11/Xwayland display connection regardless of the desktop session.
- _linux_apply_initialize_defaults(): auto-applies CEF 146 switches
(ozone-platform=x11, disable-zygote, disable-gpu, disable-features=…)
so apps don't need to set them manually.
- _linux_setup_profile(): pre-seeds Chrome profile files to prevent the
kProfileCreationFlow keepalive from blocking OnContextInitialized.
- _linux_message_loop(): runs gtk_main() with a 10 ms GLib timer driving
CefDoMessageLoopWork(), satisfying CEF's Ozone X11 GLib-loop requirement.
Subprocess fixes
- Strip --pseudonymization-salt-handle from argv in subprocess/main.cpp
(Chrome 130+ passes it to non-zygote subprocesses without pre-populating
GlobalDescriptors[7], causing an immediate crash).
- Strip both --pseudonymization-salt-handle and --change-stack-guard-on-fork
in OnBeforeChildProcessLaunch via _StripPseudonymizationSaltHandle().
- subprocess/CMakeLists.txt: add BROWSER_PROCESS define and set
BUILD_RPATH/INSTALL_RPATH=$ORIGIN so the subprocess finds libcef.so
from its installed directory on nosuid filesystems (VMware HGFS).
Other fixes
- cefpython3/__init__.py: set GDK_BACKEND=x11 at import time, before
libcef.so is loaded, as the earliest safe point.
- x11.cpp: add null guards in SetX11WindowBounds/SetX11WindowTitle;
document the XEMBED side-effect of CefBrowser_GetGtkWindow().
- cef_command_line.pxd: expose Reset, GetProgram/SetProgram, GetSwitches,
GetArguments, AppendArgument needed by _StripPseudonymizationSaltHandle.
- linux.pxd: expose g_main_context_iteration for GLib pump in Initialize.
- tools/build.py: fix CEF glob for numbered dirs, write dev .pth file,
pass PYTHONPATH when running unittests.
- examples/hello_world.py: remove all Linux-specific GTK/env boilerplate;
now identical in structure to the Windows/Mac usage pattern.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments