Standard xdg_shell does not allow Wayland clients to position toplevels —
the compositor decides placement. WINGs UI patterns require client-driven
positioning (e.g., a dropdown popup must appear directly below its trigger
button; menu editor items must be placed by the client at specific screen
coordinates).
This protocol lets the client wrap an xdg_toplevel with a wmaker_popup
object and call set_position(x, y) before the surface is mapped. The
compositor honours the requested position when the surface becomes visible
and on subsequent set_position calls.
Files:
- protocols/wmaker-popup-v1.xml: protocol definition
- src/Makefile.am, src/Makefile: server-protocol.h + protocol.c generation
- WINGs/Makefile.am, WINGs/Makefile: client-protocol.h + protocol.c generation
- src/backend/wayland/wl_backend.c: wmaker_popup_manager global, get_popup
handler that wraps an xdg_toplevel; set_position handler that updates
view->popup_x/y and calls wmaker_popup_apply to move the frame_buf
scene tree. Apply runs at toplevel_map time too for pre-map positions.
- WINGs/wclient_wl.c: bind manager in registry, wrap popup toplevels with
wmaker_popup, expose W_WLClientPopupSetPosition.
- WINGs/wview_wl.c: wl_move calls W_WLClientPopupSetPosition for popup
toplevels so WMMoveWidget propagates to the compositor.
- WINGs/wevent_wl.c: wl_move_window also routes to popup positioning.
Phase θ — wrlib's X11 image-conversion path (RConvertImage,
RPutXImage, the X11 RCreateContext, libXpm-based RLoadXPM) is now
opt-out via --disable-x11-wraster, mirroring the WINGs phase η work.
Result: with --disable-x11-backend --disable-x11-wraster the WINGs
runtime libraries have ZERO libX11 transitive deps:
$ ldd WINGs/.libs/libWINGs.so | grep X11
(empty)
$ ldd wrlib/.libs/libwraster.so | grep X11
(empty)
That was the last libX11 transitive dep coming through WINGs — the
goal of the API surgery is now achieved at the library level.
configure.ac:
- New --enable-x11-wraster (default = same as --enable-x11-backend),
AM_CONDITIONAL([USE_X11_WRASTER]), AC_DEFINE([USE_X11_WRASTER]).
Forcing --disable-x11-wraster while --enable-x11-backend is rejected
(X11 backend depends on the X11 conversion path).
- WRASTER_GFXLIBS_NO_XPM: GFXLIBS with -lXpm filtered (libXpm pulls
libX11; load_xpm_normalized.c is the X11-free XPM loader used in
the disabled-X11 build).
- WINGS_PANGO_LIBS_NO_XFT: PANGO_LIBS with -lpangoxft-* and -lXft
filtered (PangoXft depends on libXft -> libX11; pangoft2 path is
the X11-free Pango variant).
wrlib/Makefile.am:
- Split source list: shared / X11-only / Wayland-only.
- X11 sources (context.c, convert.c, convert_x11.c, xpixmap.c,
xutil.c, load_xpm.c) only built when USE_X11_WRASTER.
- New context_wl.c (always built) — Wayland-mode RCreateContextWayland
extracted from context.c.
- New wstubs_no_x11.c (only built when !USE_X11_WRASTER) — empty
stubs for the public wraster API symbols normally exported from
the X11 path (RCreateContext, RDestroyContext, RConvertImage,
RConvertImageMask, RGetClosestXColor, RCreateImageFromDrawable,
RCreateImageFromXImage, RCreateXImage, RGetXImage, RDestroyXImage,
RPutXImage, RGetImageFromXPMData, RLoadXPM).
- @XLIBS@/@LIBXMU@ only added to libwraster_la_LIBADD when
USE_X11_WRASTER; load_xpm.c only built when (USE_XPM and
USE_X11_WRASTER).
- Added --filter USE_X11_WRASTER to the wraster.h generation rule
so the @!USE_X11_WRASTER@ lines (forcing WRASTER_NO_XLIB) are
retained when X11 is disabled.
wrlib/wraster.h.in:
- When USE_X11_WRASTER is undefined at config time, force
WRASTER_NO_XLIB so consumers see only forward-decl'd opaque types
(Display/Visual/XImage/etc.) and never <X11/Xlib.h>.
- Added True/False/None defines to the WRASTER_NO_XLIB block (raster.c
uses them; previously got via Xlib.h).
wrlib/context.c — RCreateContextWayland moved out to context_wl.c.
wrlib/wstubs_no_x11.c — new (157 lines).
wrlib/context_wl.c — new (extracted Wayland branch).
WINGs/Makefile.am:
- libWINGs_la_LIBADD now uses WINGS_PANGO_LIBS, which is @PANGO_LIBS@
when X11 backend enabled, @WINGS_PANGO_LIBS_NO_XFT@ otherwise.
WINGs/widgets.c — WMCreateScreen + WMCreateSimpleApplicationScreen
moved to widgets_x11.c (they use DefaultScreen() and RCreateContext()
which are X11-only). Stubs added in WINGs/wstubs_no_x11.c.
WINGs shared rootWin assignment now reads context->drawable instead
of calling X11 RootWindow() macro directly.
WINGs/WINGs/wnative.h — added X11-numeric constants used by shared
WINGs widget code:
- Button1..Button5 (X.h pointer-button numbers)
- KeyPress..LASTEvent (X.h event-type constants)
- CWBackPixmap..CWCursor (X.h CreateWindow/ChangeWindowAttributes
mask bits)
- WMShortRect (XRectangle layout-compatible struct)
All guarded by #ifndef so X11 headers can override on the X11 build.
WINGs/configuration.c — dropped unused <X11/Xlocale.h> include.
WINGs/wruler.c, wtabview.c, wtext.c — replaced raw XPoint/XRectangle
with WMShortPoint/WMShortRect; replaced lone XSetWindowAttributes
shim with direct view->attribs.cursor access.
src/WindowMaker.h — explicitly include <X11/Xlib.h>, <X11/Xutil.h>,
<X11/Xresource.h>, <X11/Xatom.h>. The wmaker compositor uses these
extensively in its public headers; previously got them transitively
via WINGs.h. After the WINGs surgery WINGs.h no longer pulls Xlib,
so the compositor must include them itself.
Verified:
Default build (--enable-x11-backend, --enable-x11-wraster):
Window Maker 0.96.0 boots, all features intact.
Pure-Wayland build (--disable-x11-backend --disable-x11-wraster):
libwraster.so / libWINGs.so build cleanly, no libX11 in ldd.
(wmaker compositor binary still has X11 deps from src/* code;
out of scope for this commit — that's a compositor-level
refactor.)
Phase η: completes the WINGs API surgery by adding the configure
option that actually excludes the X11 backend from the build.
./configure --enable-wayland-client --disable-x11-backend
→ libWINGs has zero X11 symbol dependencies in its own objects
configure.ac: --enable-x11-backend (default yes) controls the new
USE_X11_BACKEND m4 conditional and #define.
WINGs/Makefile.am: split source list into:
- backend-neutral / shared sources (always)
- if USE_X11_BACKEND: dragsource_x11.c / dragdestination_x11.c /
dragcommon_x11.c / selection_x11.c / wappresource_x11.c /
wballoon_x11.c / wcolor_x11.c / wcolorpanel_x11.c /
wevent_x11.c / wfont_x11.c / widgets_x11.c /
winputmethod_x11.c / wrender_x11.c / wview_x11.c
- else: wstubs_no_x11.c (new)
XLIBS / XFT_LIBS only added to libWINGs_la_LIBADD when X11 backend
is enabled.
WINGs/wstubs_no_x11.c: empty implementations of every public WINGs
API symbol that normally lives in *_x11.c — DnD setup, selection
handlers, IM context, balloons, color/font panels, application icon
hints, atom helpers. Each stub is a no-op (returns success-neutral
value); calling them in pure-Wayland mode is silent rather than an
error, so future Wayland equivalents can drop in transparently.
WINGs/widgets.c: WMCreateScreenWithRContext uses weak references
to the W_*BackendX11 instances so they can resolve to NULL when not
linked. If the caller asked for X11 mode but X11 backend is not
built, falls back to Wayland with a warning.
WINGs/WINGsP.h.in: backend extern decls (W_*BackendX11) marked weak
so links resolve to NULL when X11 backend is excluded.
Verification:
$ ./configure --disable-x11-backend && make
$ for f in WINGs/.libs/*.o; do nm $f | grep '^.*U X[A-Z][a-z]'; done
(empty)
libWINGs.so still pulls libX11 transitively via wrlib (wraster's X11
image-conversion path); that's a separate refactor. At the WINGs
source level the partition is now complete: shared / X11 / Wayland.
The color picker dialog uses XGetImage / XGrabPointer / XShape /
XPutImage / XCopyArea to implement the magnify-glass screen picker.
Wayland intentionally does not allow reading pixels from other
windows (security), so the screen-pick feature has no Wayland
equivalent. The whole file is therefore X11-only.
A future commit will provide a stub that returns a wwarning when
WMShowColorPanel is called in Wayland mode.
Mechanical rename to make architectural intent visible:
dragsource.c → dragsource_x11.c
dragdestination.c → dragdestination_x11.c
selection.c → selection_x11.c
winputmethod.c → winputmethod_x11.c
wballoon.c → wballoon_x11.c
wappresource.c → wappresource_x11.c
Each is essentially a wrapper around X11 features (XDND, X11
selection, XIM, XShape, X11 WM hints) with no Wayland equivalent
yet. These files keep providing their public WINGs API symbols
unchanged, so build+link is identical at this point.
A future commit will add Wayland counterparts (or no-op stubs) and
wire a configure option that conditionally excludes *_x11.c when
the build is Wayland-client-only. Doing this now would force a
choice between linkable but Wayland-broken (no stubs) or partial
double-implementation (some functions stubbed); the right answer
needs vtable dispatchers in shared *.c files for each, which is
the next round of surgery.
dragcommon.c now contains only backend-neutral helpers
(WMCreateDragOperationArray/Item, accessors, W_FreeViewXdndPart).
dragcommon_x11.c is new and owns:
- W_OperationToAction/W_ActionToOperation atom translation
- windowExists / handleNoWindowXError probe
- W_SendDnDClientMessage XSendEvent path
- W_HandleDNDClientMessage XDND wire dispatch
- handleLeaveMessage
These touch scr->xdnd*Atom fields and call XSendEvent / XGetAtomName /
XSetErrorHandler etc. — strictly X11. Wayland DnD will be added later
through wl_data_device.
dragsource.c and dragdestination.c still contain Xlib calls; those
splits come next.
WINGs/widgets.c is now Xlib-call-free. All Xlib code moved to a new
WINGs/widgets_x11.c:
* W_X11PlatformInit (~178 lines): GC creation, modifier-mask probe,
cut-buffer setup, cursor/atom/IM init. Hooked from
W_ViewBackendX11.platform_init exactly as before.
* W_X11OpenDisplay: XOpenDisplay + WMCreateSimpleApplicationScreen.
WMOpenScreen() in widgets.c now calls this for the X11 path.
Dead code removed: the static renderPixmap that nothing called and
that was the last X11-direct-draw path in widgets.c.
X11 includes dropped from widgets.c. Display * typedef still resolves
through WINGsP.h transitively until phase ε removes that.
Build verified clean, wmaker still links and runs.
Task 1 + 2 of the WINGs Wayland-client backend.
Adds optional --enable-wayland-client (default auto) which depends on
wayland-client, xkbcommon, wayland-protocols, and wayland-scanner.
configure.ac probes for these and exposes WAYLAND_CLIENT_CFLAGS/LIBS
plus the protocols data dir and scanner path.
WINGs/Makefile.am wires a wayland-scanner rule that generates
xdg-shell-{protocol,client-protocol}.{c,h} at build time and links
libWINGs against wayland-client + xkbcommon when enabled.
WINGs/wclient_wl.c is the new file. It self-stubs when the feature
is disabled. When enabled it provides:
W_WLClientInit(scrPtr, display)
Connects via wl_display_connect, registers a wl_registry listener,
binds wl_compositor/wl_shm/wl_seat/xdg_wm_base, creates an xkb_context,
and hooks the libwayland event pump into the existing
W_EventBackendWL via W_WL_SetLoopDispatch(). This lets the existing
ring-buffer event mechanism keep working unchanged: the ring is fed
by client-side wl_pointer/wl_keyboard listeners (next task) and
drained by WMNextEvent / WMMaskEvent / waitForEvent.
W_WLClientShutdown(scrPtr)
Tears down all bound globals and disconnects the wl_display.
No surfaces / buffers / input dispatch yet — those come in tasks 3-5.
Build verified clean, wmaker still links and runs as before.
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.