Same pattern as 7530f1a: application.c, actions.c, client.c, and
defaults.c all called the raw backend paint, missing dock dots.
Now all go through wAppIconPaint for consistent indicator rendering.
Audit: every "X11 in src/" hit outside src/backend/x11/ and
src/backend/wayland/ is now either:
- a comment mentioning X11 by name, or
- a backend-neutral macro/type alias (WM_STATE_*, CW*, P*, etc.)
whose numeric value happens to match the X11 protocol value.
Zero <X11/...> includes in shared headers/sources.
Zero X11 type uses (XColor/XContext/XEvent/XFontStruct/XGCValues/
XWindowAttributes/XSetWindowAttributes/XErrorEvent etc.).
Zero X11 symbol references in compiled shared object files
(verified: `nm src/*.o | awk '$1=="U"' | grep '^X[A-Z][a-z]'`
returns empty).
Real architectural fixes:
src/backend/backend_types.h — added the missing backend-neutral
constants/types so shared code never names an X11 macro:
- WM_STATE_WITHDRAWN/NORMAL/ICONIC (ICCCM values 0/1/3).
- WContextID (typedef int) — XContext analogue.
- WMColorRGB (XColor-layout-compatible struct).
- CWX..CWStackMode (ConfigureWindow value-mask bits).
- ForgetGravity..StaticGravity (ICCCM win_gravity values).
- PMinSize..PWinGravity (XSizeHints flags) as WNH_* aliases.
- NoSymbol, NoEventMask, ColormapInstalled/Uninstalled.
- BitmapSuccess..BitmapNoMemory.
All guarded by #ifndef so the X11 backend's <X11/X.h> include
overrides them with the real X11 values when present.
src/screen.h — w_visual is now `void *` (was `Visual *`). Added
w_visual_id / w_visual_class so dialog.c's crash panel can read
visual info without dereferencing a Visual struct. tech_draw_font
is also `void *` with companion tech_draw_font_ascent/descent ints
populated by the backend (X11 from XFontStruct->ascent, Wayland
from a hard-coded bitmap-font metric).
src/WindowMaker.h — XContext fields → WContextID, X11 includes
removed, Time → WMNativeTime.
src/dialog.c — wShowCrashingDialogPanel now uses WMOpenScreen +
WMScreenWidth/Height instead of DefaultScreen()/ScreenOfDisplay()/
WidthOfScreen() so it works in either backend.
Dead-code cleanup found while auditing:
src/event.c — handleUnmapNotify and handleEnterNotify both built
an uninitialized `XEvent ev` and ran it through x11_translate_event
on a peeked queue event. The translation always read stack garbage
(the local was never populated). Replaced with the correct flow:
- unmap handler: skip wUnmanageWindow if a Destroy is already
queued, the Destroy handler will run it next iteration.
- enter handler: skip if a Leave for the same window is queued,
no need to inspect mode/detail (was always reading garbage).
Also dropped the now-unused x11_compat.h / x11_event.h includes
from event.c, dock.c, window.c.
src/misc.c — eatExpose's `XEvent event, foo` were never used; the
function delegates to wm_backend->event_flush_type(WME_EXPOSE).
src/wsmap.c — workspace_map_destroy built an XEvent ClientMessage
but never sent it; the actual notify path is switchpanel_send_enter.
Pass the real root_win argument (was passing literal 0) and drop
the dead XEvent.
src/icon.c — set_dockapp_in_icon's `XWindowAttributes attr` and
cycleColor's `XGCValues gcv` were unused.
src/window.c — windowLanguageClick had a function-signature
mismatch with framewin.h's on_click_language (XEvent* vs WMEvent*).
The framewin code passes a WMEvent. Fixed the parameter type and
its single use of event->xbutton.button.
src/moveres.c — already-disabled `#if 0` block in showPosition
that called XDrawLine / XSetForeground on the root window: removed.
Replaced tech_draw_font->ascent/descent dereferences with the new
flat int fields.
src/xutil.h — removed declarations of FormatXError (moved to X11
backend long ago) and Request/GetSelection (never implemented).
Mass renames in shared src/:
IconicState/NormalState/WithdrawnState → WM_STATE_ICONIC/NORMAL/
WITHDRAWN
IconWindowHint/InputHint/StateHint/IconPixmapHint/IconMaskHint/
IconPositionHint/WindowGroupHint/UrgencyHint
→ WMH_*_HINT
XColor (in struct fields and locals) → WMColorRGB
XContext (in screen.context.{...}) → WContextID
XPoint → WMShortPoint
XRectangle → WMShortRect
XFontStruct * → void *
Backends translate at the boundary:
src/backend/x11/x11_backend.c keeps its native XColor/XContext/
XFontStruct internally and casts to the backend-neutral types
at the public-API surface (memcpy works because WMColorRGB has
XColor's exact layout).
src/backend/wayland/wl_backend.c populates the same fields
directly without any X11 indirection.
Verified:
Default build: `Window Maker 0.96.0` runs.
Shared src/ object files: `nm | grep '^X[A-Z][a-z]'` is empty.
All shared X11 macro names (CW*, P*, ICCCM hint flags) are
defined locally in backend_types.h, no X11 dep needed.
Out of scope (separate refactor): wmaker compositor binary itself
still links libX11 because src/backend/x11/* and the XWayland
integration in src/backend/wayland/wl_backend.c need real X11
types. Both are below the vtable, so shared code is unaffected.
The phase-β sed pass renamed every C 'Window' identifier to
WNativeWindow. That correctly updated typedef uses but also rewrote
the string 'Window Maker', UI labels like 'Window Manager', 'Window
Placement', 'Window Title', 'Window List', 'Window System session',
etc., plus a number of comments referring to 'Window' as English.
Fixed all of those. The C type uses (WNativeWindow rootWin, etc.)
remain unchanged — only English-language occurrences are reverted.
Verified that wmaker now reports 'Window Maker 0.96.0' again and
build is clean across WINGs/, src/, WPrefs.app/.
Sed pass restricted to files outside src/backend/x11 and outside
*_x11.c — i.e. all code that should not depend on X11 typedefs.
Window → WNativeWindow (existing typedef in WMEvent.h)
Atom → WMNativeAtom
Pixmap → WMNativePixmap
Cursor → WMNativeCursor
Drawable → WMDrawable (existing typedef)
KeySym → WMNativeKeysym
Colormap → WMNativeColormap
X11 backend files keep using the original Xlib type names because
they make Xlib API calls that take those types. All typedefs are
ultimately 'unsigned long' so values pass through opaquely between
shared code and the backend.
Public WINGs API affected: WMSelectionCallback, WMSelectionProcs,
and a handful of widget signatures that took Atom/Window arguments
now take WMNativeAtom/WNativeWindow. Source-compatible at the
binary level; consumers must rebuild.
Time and XID typedefs left for a follow-up — both are heavily used
in field/variable names that need careful auditing. Display* and
GC stay in W_Screen for now; phase δ moves them into an X11-only
sub-struct.
Mass rename of X11 enum values used in shared/Wayland code, with the
numeric values preserved so the wire layout of WMEvent fields and
the X11-backend translation tables remain unchanged.
NotifyNormal/Grab/Ungrab/WhileGrabbed → WM_NOTIFY_*
NotifyAncestor/Virtual/Inferior/Nonlinear/
NonlinearVirtual/Pointer/PointerRoot/
DetailNone → WM_NOTIFY_*
PropertyNewValue/Delete → WM_PROPERTY_*
MappingModifier/Keyboard/Pointer → WM_MAPPING_*
VisibilityUnobscured/PartiallyObscured/
FullyObscured → WM_VISIBILITY_*
GrabModeAsync/Sync, GrabSuccess → WM_GRAB_*
RevertToParent/PointerRoot/None → WM_REVERT_TO_*
CurrentTime → WM_CURRENT_TIME
None → WM_NATIVE_NONE
The 'None' rename was done with conservative regex passes restricted
to clear C-context patterns (= None;, , None,, !=None, etc.) so that
'"None"' string literals in defaults and XPM 'c None' colour names
are preserved untouched. Comments containing the English word 'None'
are also left alone. X11 backend files that legitimately use the
X11 macros (Xlib calls returning None, etc.) are unchanged.
Build clean across WINGs, src, WPrefs.app.
Both files implement X11-specific protocols (EWMH _NET_* and XDND).
They were sitting in shared src/ because they predated the backend
split; the only remaining users in shared code were now via
wm_backend-> dispatch.
To get there, four new vtable slots replace the last direct calls
from shared src/:
screen_get_head_usable_area (screen.c was calling wNETWMGetUsableArea)
window_get_icon_image (icon.c was calling get_window_image_from_x11)
netwm_set_frame_extents (window.c, winspector.c were calling wNETFrameExtents)
(window_fetch_name and window_get_icon_name extended to consult EWMH first)
Other changes:
* get_window_image_from_x11 now takes Display* explicitly so the
Wayland backend can pass wl_state.x_display for XWayland clients
instead of relying on a global (which is NULL on Wayland).
* Eight shared .c files lose their now-unused #include "wmspec.h"
or #include "xdnd.h".
* Makefile.am moves wmspec.{c,h} and xdnd.{c,h} into the backend/x11
listing.
* src/Makefile.am drops the obsolete --disable-xdnd Makefile branch
and unconditional sources list still references the new paths.
Final state: every Xlib call in the codebase lives in src/backend/x11/
or src/backend/wayland/. The only remaining "X*(" matches outside
backend/ are six XSetForeground/XDrawLine calls in src/moveres.c
inside an \#if 0 block (dead code; left for now). src/ has zero
_x11_raw references.
- wmspec.c, xdnd.c, xmodifier.c: pure X11 mechanism code now compiled
as part of x11_backend.o (included via #include in x11_backend.c).
Removed from main link (Makefile modified).
- Policy file calls to NETWM/XDND functions replaced with vtable dispatch:
netwm_process_client_message, xdnd_process_client_message,
xdnd_process_selection, xdnd_make_awareness,
netwm_check_client_hint_change, netwm_position_splash,
netwm_check_initial_frame_state
- x11_prop_get_check_property now returns wfree-able memory (callers
use wfree instead of XFree)
RESULT: nm -u *.o | grep ' U X' returns ZERO for all non-backend .o files.
The backend abstraction is architecturally complete.
Add vtable slots: icon_select, icon_change_title, clip_icon_paint,
drawer_icon_paint, balloon_init, do_kaboom, menu_paint_entry,
menu_draw_frame.
Replace policy call sites with vtable dispatch. Make paintEntry and
drawFrame in menu.c non-static as wMenuPaintEntry/wMenuDrawFrame.
X11 backend calls the mechanism functions; Wayland backend is no-op.
wFrameWindowPaint now only reached through X11 backend's frame_paint.
All XDG toplevels support polite close via wlr_xdg_toplevel_send_close.
PropGetProtocols now sets DELETE_WINDOW=1 in the Wayland path so
wManageWindow sets kill_close=0 (prefer polite close over force-kill)
and the MC_CLOSE menu item is enabled for Wayland windows.
wClientSendProtocol dispatches wm_backend->client_close in the Wayland
path instead of returning early; since all atoms are 0 in Wayland, atom
comparison is unreliable, but all callers that reach wClientSendProtocol
are requesting a polite close — the only Wayland-meaningful WM_PROTOCOL.
wManageWindow succeeded log gains a kill_close= field; smoke test check
21 verifies kill_close=0 for each managed Wayland toplevel.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add client_close vtable slot to WMBackend:
- x11: XKillClient + XFlush
- wl: wlr_xdg_toplevel_send_close (politely asks client to close)
- wClientKill: use wm_backend->client_close() for Wayland path
Guard wClientSendProtocol with if (!dpy) return so it is safe to call
on Wayland windows (protocols.DELETE_WINDOW is always 0 for Wayland).
Wire XDG toplevel set_title signal: add title_listener to
wl_toplevel_view; handle_toplevel_title updates wwin->wm_class /
wm_instance when the client changes its title, and calls
wWindowUpdateName (which no-ops on frameless windows but posts
WMNChangedName when a frame is present).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Guard all dpy==NULL / frame==NULL crash sites in the unmanage path:
- wUnmanageWindow (window.c): frame ptr set to NULL-safe expression;
window_unmap, raise_delay timer, and owner border change all
guarded on frame != NULL
- wSelectWindow (actions.c): early return if !wwin->frame
- wNETCleanupFrameExtents (wmspec.c): early return if !dpy
- wClientRestore (client.c): early return if !dpy
Wire handle_toplevel_unmap → context_find → wUnmanageWindow(destroyed=True)
so XDG toplevels are removed from scr->focused_window on client disconnect.
Smoke test: add Phase 40 check — grep "toplevel unmapped".
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>