Commit Graph

48 Commits

Author SHA1 Message Date
Levi Neely f772c79ff5 wayland: Phase 73 — frame NULL guards in wmspec.c and winmenu.c
Guard wNETFrameExtents (returns early when !dpy || !frame), so it
does not try to set X11 properties or dereference titlebar/resizebar
for Wayland windows.

Guard OpenWindowMenu, execWindowOptionCommand, and updateOptionsMenu
in winmenu.c so that the window menu and its KeepOnTop/KeepAtBottom
stacking callbacks do not crash when wwin->frame is NULL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:56:44 +01:00
Levi Neely b1cc22ed54 wayland: Phase 72 — frame NULL guards in event.c and moveres.c
Guard all keyboard shortcut handlers in event.c that dereference
wwin->frame->core for stacking operations (WKBD_KEEP_ON_TOP,
WKBD_KEEP_AT_BOTTOM, WKBD_RAISE, WKBD_LOWER, WKBD_RAISELOWER,
WKBD_WINDOWMENU, WKBD_XKB_TOGGLE) so they skip cleanly when a
Wayland window is focused.

Add early-return guards to wKeyboardMoveResizeWindow,
wMouseMoveWindow, and wMouseResizeWindow in moveres.c so that
Wayland windows (frame==NULL) do not crash if those entry points
are reached.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:55:05 +01:00
Levi Neely 341413b7e3 wayland: Phase 71b — additional frame NULL guards in actions.c
Guard the remaining wwin->frame dereferences that are reachable for
Wayland windows:
- wSetFocusTo: skip ChangeStackingLevel for fullscreen if !frame
- set_window_coords: fall back to client size when frame is NULL
  (called by find_Maximus_geometry on neighbour windows)
- wFullscreenMonitorsWindow: early return if !frame
- wMakeWindowVisible: skip wRaiseFrame if !frame

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:51:50 +01:00
Levi Neely 7734929cd5 wayland: Phase 71 — early-return guards in major action functions
Add if (!wwin->frame) return guards to wShadeWindow, wUnshadeWindow,
wMaximizeWindow, wUnmaximizeWindow, wFullscreenWindow, wIconifyWindow,
and wDeiconifyWindow so that Wayland-managed windows (frame==NULL) do
not crash when these actions are triggered via menu or keyboard shortcut.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:50:02 +01:00
Levi Neely c2c4f699f3 wayland: Phase 70 — apply WIN_WORKSPACE macro to all frame->workspace reads
Mechanically replace all remaining wwin->frame->workspace reads (41
occurrences across 9 source files) with the WIN_WORKSPACE(w) macro
introduced in Phase 69.  Write sites (inside if-dpy or if-frame guards)
retain direct frame->workspace assignments as they cannot reach Wayland.

Also fixes two sed-introduced malformations:
  - actions.c: tmp->WIN_WORKSPACE(prev) → WIN_WORKSPACE(tmp->prev)
  - placement.c: ((WIcon*)parent)->WIN_WORKSPACE(owner) → correct form

Files changed: actions.c cycling.c event.c moveres.c placement.c
               switchpanel.c window.c wmspec.c workspace.c

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:46:35 +01:00
Levi Neely 36aa1c5725 wayland: Phase 69 — WIN_WORKSPACE macro; safe workspace reads without frame
Add WIN_WORKSPACE(w) macro to window.h that returns frame->workspace
when the window has a frame (X11 path) or wwin->workspace when it does
not (Wayland path, set in Phase 67).

Replace all unsafe frame->workspace reads with WIN_WORKSPACE() in:
  - window.c:   wWindowObscuresWindow (workspace comparison + geometry),
                wWindowFocusPrev/Next (same-workspace filter),
                wWindowSaveState (state serialization)
  - session.c:  session save (workspace name lookup)
  - switchmenu.c: all five switch-menu workspace comparisons/lookups

Also guard wWindowObscuresWindow's frame->core width/height reads with
a ternary that falls back to client.{width,height} for frameless windows.

This eliminates the last class of NULL frame->workspace dereferences
reachable from workspace-switch, focus-cycle, session-save, and
switch-menu code paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:43:09 +01:00
Levi Neely 2c55725bb6 wayland: Phase 68 — placement.c: safe overlap calculation without frame
Guard all frame->core and frame->workspace dereferences in placement.c
against NULL frame pointers (Wayland windows have no WFrameWindow):

- calcSumOfCoveredAreas: skip windows without frame (no stacking level
  or geometry available via frame; Wayland window client geometry is
  tracked separately in wwin->client.* and wwin->frame_x/y).

- window_overlaps: add early-return path for frameless windows that uses
  wwin->client.{width,height} and wwin->frame_x/y for the overlap test,
  bypassing the frame->core stacking level check.

- getPlaceOrigin (icon-placement helper): guard frame->workspace reads
  for WCLASS_MINIWINDOW and WCLASS_WINDOW parent types using logical-OR
  with the wwin->workspace fallback.

Together these prevent NULL dereferences when smart/auto/cascade
placement iterates the managed-window list and encounters Wayland
windows alongside X11 windows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:40:44 +01:00
Levi Neely e60dff8ffd wayland: Phase 67 — WWindow.workspace; safe workspace switching without frame
Add int workspace to WWindow so Wayland-managed windows (which have no
WFrameWindow and therefore no frame->workspace slot) can track their
workspace assignment.  Set wwin->workspace = workspace in the Wayland
branch of wManageWindow alongside the existing geometry recording.

Guard wWorkspaceForceChange against NULL frame dereferences: introduce a
tmp_workspace local that falls back to tmp->workspace when frame is NULL,
and protect the omnipresent workspace assignment the same way.  Also add
a NULL guard for tmp->icon->core in the miniwindow-unmap path.

This prevents NULL dereferences if workspace switching is triggered
(e.g., via a root-menu action) while Wayland windows are managed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:38:07 +01:00
Levi Neely a2571be53e wayland: Phase 66 — XDG popup initial configure for context menus
Handle WLR_XDG_SURFACE_ROLE_POPUP surfaces in handle_xdg_new_surface by
scheduling the initial configure event.  XDG popups (context menus,
autocomplete dropdowns, tooltips) need a compositor configure before they
can commit their first buffer; without it they stall indefinitely.

Popups are not managed by the policy layer — they are self-contained
transient surfaces positioned relative to their parent by the positioner.
We schedule configure and log the event without creating a wl_toplevel_view.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:33:22 +01:00
Levi Neely 9bdf3c058b wayland: Phase 65 — prop_get_transient_for via xdg_toplevel->parent
Implement prop_get_transient_for for the Wayland backend by walking the
xdg_surface->toplevel->parent pointer and looking up the corresponding
wl_toplevel_view to return its synthetic WNativeWindow ID.

This ensures dialog windows and other transient toplevels that set a
parent via set_parent() are correctly identified as transients by the
policy layer (wManageWindow sets transient_for / no_miniaturizable /
no_miniaturize_button correctly).

Add a helper wl_find_view_by_xdg_surface() for surface-based lookups.
Smoke test gains a header comment noting Phase 65 is a build-only check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:29:28 +01:00
Levi Neely cc846daeca wayland: Phase 64 — zxdg_decoration_manager_v1; CSD negotiation
Advertise the XDG decoration manager protocol so clients that support
server-side decoration negotiation can communicate with the compositor.
Since the Wayland path has no X11 frame rendering, respond to all
new_toplevel_decoration events with CLIENT_SIDE mode, directing clients
to draw their own title bars and borders.

Smoke test gains two new checks: compositor logs "xdg-decoration-manager
created" at startup, and weston-info reports zxdg_decoration_manager_v1
in the global registry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:26:52 +01:00
Levi Neely 36b024d849 wayland: Phase 63 — DELETE_WINDOW=1 for Wayland; wClientSendProtocol dispatches client_close
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>
2026-03-28 09:24:22 +01:00
Levi Neely 6764c14863 wayland: Phase 62 — mapped flag, focus lifecycle, and keyboard clear-focus
Three related fixes to make the WM focus lifecycle work end-to-end in
the Wayland path:

1. window.c: set wwin->flags.mapped=1 for Wayland windows (the
   wWindowMap call in wManageWindow is guarded by if(wwin->frame)
   which is NULL in Wayland, leaving mapped=0 and causing wSetFocusTo
   to take the no-focus branch immediately).

2. screen.c: call screen_create_internals in the Wayland goto path;
   this was skipped by goto screen_done but is needed to set
   auto_focus=1 and clear initial keyboard focus via wlr_seat.

3. wl_backend.c: implement wl_screen_create_internals (sets
   no_focus_win=WNATIVE_NONE, auto_focus=1, clears seat focus);
   wl_focus_set now calls wlr_seat_keyboard_clear_focus and logs
   "focus_clear" when win==WNATIVE_NONE; remove the redundant direct
   wl_focus_set call from handle_toplevel_map since wManageWindow now
   handles focus via wSetFocusTo.

Smoke test: add check 20 verifying "focus_clear" is logged after the
last managed window unmaps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 09:11:56 +01:00
Levi Neely 04f8a46ae5 wayland: Phase 61 — allocate workspace 0 in Wayland screen init
wScreenInit skips wWorkspaceNew (which calls wDockCreate, an X11
operation) via goto screen_done.  This left workspace_count=0, causing
a divide-by-zero in wManageWindow when a window carries saved state
(workspace % scr->workspace_count).  Allocate a minimal WWorkspace
directly before the goto so the Wayland path always has exactly one
workspace.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 08:57:52 +01:00
Levi Neely 3c428e25d9 wayland: Phase 60 — guard wsmap X11/rcontext paths; icon name from XDG title
wWorkspaceMapUpdate calls XGetImage(dpy) and RCreateImageFromXImage
(scr->rcontext) directly; both are NULL in the Wayland path.  Add
early-return guards so enabling the workspace pager in Wayland mode
does not crash.

set_workspace_map_background_image calls RConvertImageMask(scr->rcontext)
for pixmap textures; guard that path with the same rcontext check.

wl_window_get_icon_name was a stub returning False.  Implement it to
return the XDG toplevel title so window icon labels are populated on
the Wayland path (Wayland has no separate WM_ICON_NAME concept).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 08:52:35 +01:00
Levi Neely e82bb279ab wayland: Phase 59 — guard SetupEnvironment rcontext NULL deref
scr->rcontext is NULL in the Wayland path (RContextCreate is only
called under dpy).  SetupEnvironment() is reachable via shell command
launch and RelaunchWindow; wrap the WRASTER_COLOR_RESOLUTION putenv
in a scr->rcontext NULL-check to prevent a crash.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:46:06 +01:00
Levi Neely b3acfb2366 wayland: Phase 58 — stacking Z-order in toplevel_list; query returns success
Implement stacking_raise/lower by moving views to the head/tail of
wl_state.toplevel_list.  stacking_restack reorders the list to match a
given array (inserts from last to first so head = highest Z-order).

stacking_query now returns 1 with the list of synthetic IDs (head-to-tail
= top-to-bottom Z-order).  RemakeStackList finds no WM_CTX_STACK frames
for synthetic IDs (as expected — no frame windows on Wayland), so
window_count stays 0, but the change from returning 0→1 eliminates the
"could not get window list" log warning on every stacking operation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:35:59 +01:00
Levi Neely 2c6e24dfb0 wayland: Phase 57 — icccm_set/get/free_command store WM_COMMAND in view
Add wm_command/wm_command_n fields to wl_toplevel_view.
wl_icccm_set_command stores a deep copy of argv in the view struct;
wl_icccm_get_command returns a NULL-terminated heap copy (caller frees
each string plus the array via wl_icccm_free_command).
handle_toplevel_destroy frees the stored command on cleanup.

Update getCommandForWindow in misc.c: when dpy is NULL (Wayland path),
call wm_backend->icccm_get_command instead of returning NULL immediately.
This allows fixLeaderProperties and session.c to retrieve the command
string for Wayland-managed windows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:34:12 +01:00
Levi Neely e727bdbad0 wayland: Phase 56 — prop_set/get_wm_state persists WM state in view struct
Add wm_state/wm_state_n fields to wl_toplevel_view.  prop_set_wm_state now
stores the 10-long WM state array (workspace, miniaturized, shaded, hidden,
geometry, shortcut slots) in the view; prop_get_wm_state returns a heap
copy so wWindowGetSavedState works correctly when a Wayland client
reconnects.  handle_toplevel_destroy frees the stored state on cleanup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:28:59 +01:00
Levi Neely 49246f80ca wayland: Phase 55 — window_get_rect returns real geometry; window_move tracks position
Add x,y position fields to wl_toplevel_view.  wl_window_move now records
the WM-assigned position in the view struct instead of discarding it.

wl_window_get_rect previously returned 0 (invalid) for all synthetic IDs,
causing wIconifyWindow and similar callers to treat every Wayland window as
destroyed.  Now returns 1 with real surface dimensions (from wlr_surface
current.width/height) for valid toplevel views, 1 with output dimensions
for other virtual windows, and 0 only for WNATIVE_NONE.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:25:55 +01:00
Levi Neely 54c1a3a181 wayland: Phase 54 — virtual pointer position tracking
Add pointer_x/pointer_y fields to wl_compositor_state, initialised to
screen centre (960,540) in wl_display_open.  pointer_warp/warp_to now
update the tracked position (clamped to output bounds); pointer_query and
pointer_query_full return the tracked coordinates instead of hardcoded 0,0.

Also fix the smoke test to ensure XDG_RUNTIME_DIR is set before launching
wmaker (the fix from Phase 53 was already applied; this commits it
permanently).  Adds a Phase 54 check verifying the "virtual pointer
initialised at" log line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:23:48 +01:00
Levi Neely ec98ed3d21 wayland: Phase 53 — headless pointer device; seat advertises pointer capability
Add a headless pointer input device (WLR_INPUT_DEVICE_POINTER) to the
Wayland seat alongside the existing keyboard device.  wlr_seat now
advertises both WL_SEAT_CAPABILITY_KEYBOARD and WL_SEAT_CAPABILITY_POINTER
to clients that bind wl_seat.

Also fix the smoke test to set XDG_RUNTIME_DIR when it is unset so
wl_display_add_socket_auto() can always create the compositor socket.

Smoke test gains a Phase 53 check: weston-info must show 'pointer' in the
wl_seat capabilities output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:19:01 +01:00
Levi Neely c03581c81f wayland: Phase 52b — guard wWindowSynthConfigureNotify frame titlebar access
Add wwin->frame NULL check before accessing wwin->frame->titlebar in
wWindowSynthConfigureNotify so frameless Wayland windows do not
dereference a NULL frame pointer when a synthetic configure notify
is sent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:12:50 +01:00
Levi Neely 8f0c54240e wayland: Phase 52 — guard wWindowMap/Unmap and misc X11 paths for NULL frame
Add if (wwin->frame) guards to wWindowMap and wWindowUnmap so that
frameless Wayland windows do not dereference wwin->frame->core->window.
Guard getCommandForWindow in misc.c against NULL dpy to prevent
XGetCommand crash when the PID-based haveCommand path fires.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:09:20 +01:00
Levi Neely c36bd7384e wayland: Phase 51 — multi-client: two simultaneous toplevels managed cleanly
Run two weston-simple-shm processes in parallel during the smoke test
and verify that all three toplevels (one from the single-client section
plus two from the parallel section) are managed and unmanaged without
crashing the compositor.  The synthetic-ID counter, focus chain, and
wUnmanageWindow path all survive the multi-client scenario.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:06:26 +01:00
Levi Neely 14da9a65ae wayland: Phase 50 — client_get_pid via wl_client_get_credentials; misc guards
Implement wl_client_get_pid using wl_resource_get_client +
wl_client_get_credentials so the WM can retrieve the OS PID of
Wayland clients.  Guard getCommandForWindow in misc.c against NULL
dpy to prevent XGetCommand crash when the real PID path fires.
Guard wWindowChangeWorkspace against NULL frame for frameless
Wayland windows.  Log pid= in the wManageWindow-succeeded line;
add Phase 50 pid check to smoke test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 07:03:55 +01:00
Levi Neely 0ca749896a wayland: Phase 49 — guard PropSet/PropCleanUp against NULL dpy
Add if (!dpy) return guards to PropSetWMakerProtocols,
PropSetIconTileHint, and PropCleanUp so the Wayland path does not
call XChangeProperty/XInternAtom/XDeleteProperty on a NULL display
during screen setup and shutdown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:55:50 +01:00
Levi Neely b0728c7048 wayland: Phase 48 — guard NETWM init/update/cleanup functions against NULL dpy
Add if (!dpy) return guards to wNETWMInitStuff, wNETWMCleanup,
wNETWMUpdateDesktop, wNETWMGetCurrentDesktopFromHint,
wNETWMUpdateActions, and updateWindowOpacity so the Wayland backend
path does not crash calling XChangeProperty/XDeleteProperty/
XGetWindowProperty on a NULL display.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:54:35 +01:00
Levi Neely 2d3d6d4716 wayland: Phase 47 — prop_get_normal_hints from XDG toplevel constraints
Implement wl_prop_get_normal_hints: look up the wl_toplevel_view, read
wlr_xdg_toplevel::current.{min,max}_{width,height} for WNH_P_MIN/MAX_SIZE
flags, and report the current committed surface size as WNH_P_SIZE so
wManageWindow/wClientGetNormalHints sees real constraints.

Returns 1 if any flags were set, 0 if the view has no constraints.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:49:58 +01:00
Levi Neely fc0e233865 wayland: Phase 46 — client_close vtable; title updates; protocol guards
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>
2026-03-28 06:46:46 +01:00
Levi Neely 69cee6fb15 wayland: Phase 45 — pointer_query returns on-screen; focus path guarded
pointer_query / pointer_query_full: return 1 when compositor is running
(wl_state.started) so the same_screen check in wManageWindow passes and
wSetFocusTo is called for newly mapped XDG toplevels.

Guard frame-dependent calls in the focus update path:
  - wWindowFocus (window.c): guard wFrameWindowChangeState on frame!=NULL
  - wWindowUnfocus (window.c): same; also guard wFrameWindowPaint on
    owner->frame when clearing semi-focus on transient owner

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:43:16 +01:00
Levi Neely 4574fe8873 wayland: Phase 44 — client_synth_configure/window_resize send XDG configure
Implement three vtable slots:
  - client_synth_configure: calls wlr_xdg_toplevel_set_size + schedule_configure
    so the WM can resize/reposition XDG toplevel clients
  - window_resize: same — sends a configure with the new width/height
  - window_move: no-op comment (position is WM-side only for Wayland)

All three use wl_find_view_by_id to recover the wl_toplevel_view.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:41:17 +01:00
Levi Neely 0fe2960995 wayland: Phase 43 — focus_set delivers keyboard focus via wlr_seat
Create a headless keyboard input device during wl_display_open and
attach it to wlr_seat so wlr_seat_keyboard_notify_enter() can deliver
keyboard focus to XDG toplevel surfaces.

Implement wl_focus_set: look up the view by synthetic ID, call
wlr_seat_keyboard_notify_enter with the xdg_surface->surface.
Call wl_focus_set from handle_toplevel_map immediately after
wManageWindow so newly mapped toplevels receive keyboard focus.

Smoke test: add Phase 43 check — grep "focus_set id=" in stderr.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:40:16 +01:00
Levi Neely d9a70e9177 wayland: Phase 42 — window_get_client_attrs returns real map/geometry
Implement wl_window_get_client_attrs: look up the toplevel view, return
WCLIENT_VIEWABLE with width/height from wlr_surface.current for mapped
surfaces; WCLIENT_UNMAPPED for unknown IDs.

Extend the wManageWindow success log to include geo=WxH so the smoke
test can verify the geometry is non-zero after the client commits a frame.

Smoke test: add Phase 42 check — grep geo= and verify it is logged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:37:59 +01:00
Levi Neely 0ea33dc830 wayland: Phase 41 — prop_get_wm_class/window_fetch_name from XDG metadata
Add wl_find_view_by_id() helper that walks toplevel_list to recover a
wl_toplevel_view from its synthetic WNativeWindow ID.

Implement vtable slots:
  - prop_get_wm_class: returns XDG app_id as both WM_CLASS and WM_INSTANCE
  - window_fetch_name: returns XDG toplevel title

Extend the wManageWindow success log to include class= and name= so
the smoke test can verify these fields are populated from Wayland metadata.

Smoke test: add Phase 41 check — grep for
"class=org.freedesktop.weston.simple-shm" in manage log.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:36:22 +01:00
Levi Neely 490ecb34ff wayland: Phase 40 — wire toplevel unmap to wUnmanageWindow
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>
2026-03-28 06:34:15 +01:00
Levi Neely ca09635129 wayland: Phase 39 — wire toplevel map to wManageWindow
Guard all dpy==NULL crash sites reached from wManageWindow:
  - wNETWMGetPidForWindow (wmspec.c) — XGetWindowProperty with NULL dpy
  - wNETWMCheckClientHints (wmspec.c) — XGetWindowProperty
  - wNETWMCheckInitialClientState (wmspec.c) — XChangeProperty chain
  - getMWMHints (motif.c) — XInternAtom before NULL dpy check
  - wClientSetState (client.c) — XChangeProperty
  - wColormapInstallForWindow (colormap.c) — XGetWindowAttributes
  - wWindowSetKeyGrabs (window.c) — frame->core->window dereference

Wire handle_toplevel_map → wManageWindow(scr, view->id) so mapped
XDG toplevels appear in scr->focused_window.  Log success via
"wl_backend: wManageWindow succeeded id=0x%lx".

Smoke test: add Phase 39 check — grep "wManageWindow succeeded".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 06:23:23 +01:00
Levi Neely 74a43f0180 wayland: Phase 38 — per-toplevel view lifecycle and context store
Introduce struct wl_toplevel_view with map/unmap/destroy wl_signal
listeners and a synthetic WNativeWindow ID (>= 0x10000000).
Implement context_save/find/delete as a per-key linked list of
(WNativeWindow, void*) entries — enables downstream policy code to
look up views by handle.  wl-smoke-test now verifies "toplevel mapped"
appears in compositor stderr when weston-simple-shm creates its surface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 23:19:18 +01:00
Levi Neely 3e1fd061e9 wayland: Phase 37 — frame timer drives client frame callbacks at 60 fps
Replace the output frame listener + render pipeline approach (which
required a swapchain allocator) with a simple wl_event_loop timer that
calls wlr_output_send_frame every 16 ms.  Clients (weston-simple-shm)
now complete their render loops without the compositor needing a GPU
allocator.  Also schedule an initial xdg_surface configure on new
toplevels so they can commit their first buffer.  wl-smoke-test verifies
weston-simple-shm runs for 3 s without crashing the compositor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 23:15:59 +01:00
Levi Neely 2182ec0fc1 wayland: Phase 36 — wl_shm, wl_output, XDG toplevel listener
Advertise wl_shm (via wlr_renderer_init_wl_shm) and expose the headless
output as a wl_output global so SHM buffer clients can render.  Wire up
the xdg_shell new_surface listener to track incoming XDG toplevels
(management hook placeholder).  wl-smoke-test now verifies wl_shm and
wl_output in the registry and that weston-simple-shm can connect without
crashing the compositor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 23:12:21 +01:00
Levi Neely 075b648021 wayland: Phase 35 — advertise core Wayland protocol globals
Register wl_compositor (+ wl_subcompositor), wl_seat, wl_data_device_manager,
and xdg_wm_base in the compositor's global registry so that Wayland clients
can enumerate and bind them.  Add generated xdg-shell-protocol.{h,c} from
wayland-scanner.  wl-smoke-test now uses weston-info to verify all three
key globals are present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 23:09:39 +01:00
Levi Neely 97a9209b4f wayland: Phase 34 — Wayland socket, output layout, real monitors_query
Create the compositor UNIX socket via wl_display_add_socket_auto so
Wayland clients can connect; store socket name and set WAYLAND_DISPLAY.
Add wlr_output_layout for multi-head tracking and implement monitors_query
to return real 1920x1080 head geometry from the headless output.
wl-smoke-test now verifies the socket file exists in XDG_RUNTIME_DIR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 23:06:49 +01:00
Levi Neely f7dfc50f26 wayland: Phase 33 — event_loop_run/atom_intern vtable; wmaker starts and exits cleanly under Wayland
Add display_default_screen, atom_intern, and event_loop_run vtable slots.
Guard all X11-only paths in startup.c/screen.c/shutdown.c/event.c/xdnd.c
with if (!dpy) so the Wayland path reaches wl_display_run() and exits
cleanly (exit 0) on SIGTERM.  wl-smoke-test.sh now PASSES.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 23:02:26 +01:00
Levi Neely d07362b90e wayland: Phase 32 — display_open/close/screen_count through vtable
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>
2026-03-27 22:35:54 +01:00
Levi Neely e8e230b2db wayland: add WMAKER_USE_WAYLAND backend selector and split smoke tests
- startup.c: include wl_backend.h when USE_WAYLAND_BACKEND is defined;
  select wl_backend when WMAKER_USE_WAYLAND env var is set, otherwise
  fall back to x11_backend (no-op for non-Wayland builds)
- tests/smoke-test.sh renamed to tests/x11-smoke-test.sh (X11-only path)
- tests/wl-smoke-test.sh: new Wayland smoke test; currently verifies
  wl_backend symbol presence and wlroots linkage; headless compositor
  tests will be added as vtable slots are implemented

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 22:29:27 +01:00
Levi Neely d2632b8487 wayland: Phase 31 — Wayland backend skeleton (complete stub vtable)
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>
2026-03-27 22:12:41 +01:00
Levi Neely a486329b52 Wayland backend abstraction: WMBackend vtable (Phases 0–30)
Introduce a display-system-agnostic WMBackend vtable that routes all
display operations through function pointers, making the WM policy
layer independent of X11.  The X11 implementation is preserved in
src/backend/x11/ and behaviour is unchanged.

Key structural changes
──────────────────────
• src/backend/backend_types.h — backend-neutral type definitions:
    WNativeWindow, WKeyCode, WContextKey, WBackendScreen,
    WBackendEvent (+typed fields), WNormalHints, WWMHints,
    WNETWindowType, WHeadGeometry, WClientAttributes, WClientVisual,
    WSegment, WPoint, WM_KEY_* keysym constants, WA_* atom IDs,
    WKB_GROUP*_INDEX, WCUR_NONE

• src/backend/backend.h — WMBackend vtable (~100 function-pointer
    slots) covering: frame/context lifecycle, stacking, focus, grabs,
    pointer, keyboard, overlays, properties, ICCCM, EWMH/NETWM,
    monitors, screen setup, cursors, extensions, error handlers.
    No <X11/> headers remain in this file after Phase 30.

• src/backend/x11/ — X11 backend implementation:
    x11_backend.c  full vtable; all display calls confined here
    x11_props.c    WM_NORMAL_HINTS / WM_HINTS translation
    x11_event.c    XEvent → WBackendEvent translation
    x11_monitor.c  Xinerama / RandR monitor query

Policy files cleaned
────────────────────
All 47 files in WM_POLICY_CLEAN_FILES pass check-no-x11-policy
(no direct #include <X11/> anywhere).  X11 types that still appear
in policy structs (Visual*, Colormap, Window, Atom …) arrive only
transitively via WINGs.h; the vtable boundary itself is X11-free.

Tests
─────
• tests/smoke-test.sh — full Xvfb lifecycle test (PASS)
• tests/test_geom.c   — geometry / constraint unit tests
• tests/test_x11_event.c — WBackendEvent field extraction tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 19:20:00 +01:00
Levi Neely fcee811b99 WindowMaker 0.96.0 upstream source 2026-03-26 15:38:49 +01:00