Key changes in wl_backend.c:
- wl_atom_intern: call XInternAtom on XWayland display (was returning 0)
- Add wl_or_view struct to track override_redirect XWayland surfaces
- handle_xwayland_new_surface: composite OR surfaces via scene graph
- frame_create_toplevel/child: create real X11 windows on XWayland
- frame_destroy/configure: delegate to Xlib
- window_map/unmap/move/resize: fall through to Xlib for frame windows
- stacking_raise/lower: update scene graph + Xlib fallback
- event_flush/sync: call XFlush/XSync on XWayland display
- window_set_border/border_width/clear: delegate to Xlib
- window_get_rect: query XWayland geometry for non-toplevel windows
Note: frame creation via XWayland is a temporary bridge. The correct
architectural approach is native scene-buffer rendering with pixman.
Add wm_shm_surface: a compositor-owned pixel buffer that bridges pixman
software rendering to the wlroots scene graph.
The struct embeds a wlr_buffer (wl_container_of compatible) so wlroots
can reference-count and GPU-upload the pixel data on demand via the
wlr_buffer_impl vtable (begin_data_ptr_access / end_data_ptr_access /
destroy). A pixman_image_t wrapping the same malloc memory provides the
drawing API.
Four entry points:
wm_shm_surface_create — alloc + wlr_buffer_init + pixman_image_create
wm_shm_surface_fill — pixman_image_composite32(PIXMAN_OP_SRC, ...)
wm_shm_surface_commit — wlr_scene_buffer_create / set_position
wm_shm_surface_destroy — scene node + wlr_buffer_drop (async free)
A 64×64 steel-blue (0xFF4080C0) test surface is committed to the root
scene node at (16,16) inside wl_screen_create_internals, proving the
pixman → wlr_scene_buffer upload pipeline works end-to-end.
Build fixes:
- Add pixman-1 to PKG_CHECK_MODULES in configure.ac so -lpixman-1
appears in WLROOTS_LIBS (linker was missing the symbol).
- Add -I$(srcdir)/backend/wayland to AM_CPPFLAGS in Makefile.am so
generated Wayland protocol headers are found during compilation.
Smoke test: PASS (all existing checks continue to pass; Phase 29 log
line "Phase 29 test surface committed" confirms the pipeline fires).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add three display-lifecycle slots to WMBackend:
display_open(name) — open/init display connection, return Display*
(NULL for Wayland; compositor init side-effect)
display_close() — tear down display connection
display_screen_count() — number of logical screens
x11_backend: implement with XOpenDisplay (including close-on-exec fcntl),
XCloseDisplay, ScreenCount(dpy); remove fcntl/FD_CLOEXEC from main.c.
wl_backend: implement display_open() with full wlroots headless compositor
init — wl_display_create, wlr_headless_backend_create, wlr_renderer_autocreate,
wlr_backend_start. display_close() tears down in reverse order.
Compositor state held in a file-static struct. Adds -DWLR_USE_UNSTABLE
to WLROOTS_CFLAGS in configure.ac.
main.c: move backend selection before display_open() (was in StartUp()),
call wm_backend->display_open() instead of XOpenDisplay(); guard all
X11-specific post-open code (visual-id, DisplayName, wXModifierInitialize)
in if(dpy != NULL).
startup.c: replace ScreenCount(dpy) with wm_backend->display_screen_count();
remove now-redundant backend-selection block (owned by main.c).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add --enable-wayland-backend configure option (default: auto).
Requires wlroots >= 0.15, wayland-server, xkbcommon via pkg-config.
Detected at build time on this system: wlroots 0.15.1.
New files:
src/backend/wayland/wl_backend.h — declares extern const WMBackend wl_backend
src/backend/wayland/wl_backend.c — complete stub vtable (108 slots)
All stubs return safe zero/null/false values. Every slot matches the
exact WMBackend function-pointer signature; zero compiler warnings.
Build system compiles the Wayland backend files conditionally when
USE_WAYLAND_BACKEND is set; WLROOTS_CFLAGS/LIBS wired into AM_CFLAGS
and wmaker_LDADD.
Subsequent phases will replace stubs with real wlroots implementations.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>