Commit Graph

75 Commits

Author SHA1 Message Date
Levi Neely da4f662844 Fix modal loop re-composite: use vb->map for correct paint order
Was calling redisplay then map_subviews separately, with background
overwriting children. Now calls vb->map which does background first,
then children composite on top, with final commit showing everything.
2026-05-13 22:57:47 +02:00
Levi Neely 8f0ec30759 Fix keyboard input: don't forward keys to seat without focused surface
wlr_seat_keyboard_notify_key was being called unconditionally, which
caused re-entrancy that consumed WINGs events from the queue before
the modal loop could fetch them. Now only forwards to the seat when
there's an actual focused client surface.

Also use 16ms timeout in wl_flush so keyboard events from the nested
compositor are actually received during modal loop dispatch.
2026-05-13 22:48:13 +02:00
Levi Neely ace0585ec3 Unify WMCreateScreenWithRContext: single path, vtable dispatch
Eliminated the separate Wayland/X11 code paths. Now ONE path:
1. Backend selection (based on WMAKER_USE_WAYLAND)
2. Backend init
3. Common init (colors, fonts, antialiasedText)
4. viewBackend->platform_init() — X11 does GCs, atoms, cursors,
   cut buffers, modifier masks, pixmaps, IM, W_InitApplication.
   Wayland is NULL (no platform-specific late init needed).
5. rootView, balloon, return

All X11-specific screen setup moved to W_X11PlatformInit() called
through the view backend vtable. No if-guards, no early returns,
no separate paths.
2026-05-13 22:16:54 +02:00
Levi Neely 2e631eef15 Add selection_acquire/release to view backend vtable
- WINGsP.h: add selection_acquire/release slots to W_ViewBackend
- wview_x11.c: implement via XSetSelectionOwner/XGetSelectionOwner
- wview_wl.c: stub that returns True (TODO: wl_data_device)
- selection.c: use vtable instead of direct X11 calls
2026-05-13 21:53:55 +02:00
Levi Neely 840b00819d Route pointer events to deepest child view at click point
In X11, the server delivers events to the deepest child window.
In Wayland, all widgets share one frame_buf. WMHandleEvent now
does hit-testing within the view tree to find the correct child
widget for button press/release/motion events.
2026-05-13 21:49:29 +02:00
Levi Neely 01f2e4463e Re-composite dialog after each event in modal loop
After WMHandleEvent processes a key press, the text field repaints
into its backing image. The modal loop now re-composites the view tree
and commits to the scene graph so changes are visible immediately.
2026-05-13 21:47:24 +02:00
Levi Neely 76080cd2eb Implement keyboard input via font backend abstraction
- WMEKey: add keysym, utf8[8], utf8_len fields
- handle_keyboard_key: translate keycode via xkb_state, fill keysym/utf8,
  route event to focused WINGs view
- W_FontBackend: add lookup_string slot
- wfont_x11.c: implement via W_LookupString (wraps XLookupString)
- wfont_wl.c: implement by reading pre-translated keysym/utf8 from event
- wtextfield.c: use font backend lookup_string (no X11 guards)
2026-05-13 21:43:24 +02:00
Levi Neely 94b45b342e Fix dialog: paint background before children, not after
wl_map was calling wl_map_subviews (children) then wl_redisplay (bg fill),
overwriting children with the background. Reversed order so background
is filled first, then children composite on top.
2026-05-13 21:35:18 +02:00
Levi Neely bf9a0a9cf5 Fix dialog titlebar and background rendering
- window.c: always call frame_paint for internal windows (title=NULL
  skipped wFrameWindowChangeTitle which was the only paint trigger)
- wview_wl.c: fill view backing with background color before expose
  (X11 server fills background automatically, Wayland needs explicit fill)
2026-05-13 21:34:07 +02:00
Levi Neely 6cda661609 Fix dialog content rendering: re-trigger child paint when top-level maps
Children were painted during panel creation (before frame_buf backing
was connected). Now wl_map triggers wl_map_subviews when a top-level
view is mapped, re-painting all children into the correct backing image.
2026-05-13 21:27:22 +02:00
Levi Neely 305b8096da Fix regression: only trigger redisplay on map for top-level views
wl_map was calling wl_redisplay on every view map, including internal
widgets during startup. This caused crashes when non-dialog views
received expose events before being fully set up.
2026-05-13 21:24:07 +02:00
Levi Neely 72377068fd Dialog rendering: child view compositing and text field fixes
- wl_realize: allocate pixman backing image for every view
- wl_map_subviews: recursively trigger redisplay on child views
- wl_redisplay: composite child backing into parent, commit top-level
- wtextfield.c: replace XDefineCursor with W_SetViewCursor
- wtextfield.c: guard W_LookupString against NULL _x11_raw
2026-05-13 19:58:55 +02:00
Levi Neely b53cc4f0da Dialog rendering: composite child views into parent backing
- wl_realize: allocate pixman backing image for every view
- wl_map_subviews: recursively trigger redisplay on child views
- wl_redisplay: composite child's backing into parent's backing,
  then commit the top-level view's frame_buf
- wtextfield.c: guard W_LookupString against NULL _x11_raw
2026-05-13 19:57:12 +02:00
Levi Neely 4870c72c78 Fix dialog visibility: trigger paint on map, enable scene node on commit
- wl_map: set mapped=1 before calling wl_redisplay (was bailing because
  mapped flag wasn't set yet)
- wl_view_commit_backing_impl: enable scene node when content is committed
  (frame_buf was created disabled, never enabled before frame was mapped)
2026-05-13 19:51:22 +02:00
Levi Neely 9191f12913 Fix render backend crashes: resolve view IDs in all drawing functions
All WINGs render backend functions (draw_line, draw_rect, fill_rect,
pixmap_copy, composite_pixmap) now use resolve_drawable() to handle
WINGs view IDs (0x20000000+) by looking up the backing pixman image.

Also fixes:
- wfont_wl.c: resolve view IDs in draw_string/draw_image_string
- wtextfield.c paintCursor: use render backend draw_line (not XDrawLine)
- dialog.c wShowInfoPanel: guard scr->w_visual for Wayland mode
2026-05-13 19:40:31 +02:00
Levi Neely 1d0b82eed5 Implement WINGs dialog rendering infrastructure
- wl_client_reparent: create child frame_buf for WINGs views, connect
  backing pixman image so widgets paint into the scene graph
- View lookup table: map synthetic IDs to W_View* for event dispatch
- render_wl_pixmap_copy: detect view IDs and copy into backing image
- W_ViewCommitBacking callback: commit frame_buf after WINGs paint
- WMHandleEvent: use view table in Wayland mode (was always NULL)
- wtextfield.c paintCursor: use render backend draw_line instead of
  XDrawLine (crash fix for Run dialog)
2026-05-13 19:33:26 +02:00
Levi Neely 531dcf8235 Fix text rendering and titlebar positioning
- wl_draw_string: remove ascent subtraction, y is TOP position (matches
  X11 Pango behavior where pango_xft_render_layout takes top-left)
- Menu entry text: pass top position (y+3) not baseline (y+3+fh-1)
- Icon title: pass y=0 (top) not y=fh (baseline)
- frame_paint_titlebar: pass centered top not baseline
- frame_configure: compute absolute position from parent for children
  (was setting absolute pos to relative coords, warping to 0,0)
- Titlebar buffer: always render full frame width, resize if needed
- Frame scene node: disable when no resizebar (transparent, not needed)
- Always call frame_paint after show/hide button (TS_NEW was skipping it)
2026-05-13 19:03:49 +02:00
Levi Neely a517c16f5e Guard WINGs realizeWindow against NULL display in Wayland mode
When a menu entry triggers a WINGs dialog (e.g. 'Run...'), the
realizeObserver notification calls realizeWindow which does X11 calls
(XSetClassHint, XAllocWMHints). In Wayland mode scr->display is NULL,
causing a segfault. Skip the entire function when display is NULL.
2026-05-13 17:56:46 +02:00
Levi Neely d93f4935ca Fix input dispatch: custom event loop + modal menu support
The deadlock: frame_timer_cb called WMHandleEvent which entered
menuMouseDown's modal WMMaskEvent loop. That blocked inside
wl_event_loop_dispatch (reentrant), preventing new events.

Fix:
1. Replace wl_display_run() with custom loop that drains WINGs
   events BETWEEN wl_event_loop_dispatch calls (not inside timer)
2. Make WINGs wl_flush() pump wlroots (call dispatch_fn) so
   WMMaskEvent modal loops get new events without reentrancy
3. Fix wBalloonHide NULL dereference (scr->balloon not allocated)
4. Remove XEvent dependency from wSelectWindows (takes x,y now)
5. Remove debug traces

Right-click on background now opens the root menu.
2026-05-13 16:22:13 +02:00
Levi Neely 553d2ca0ba Phase 80: eliminate all 43 if(!dpy) return guards via vtable dispatch
Remove every 'if (!dpy) return' guard from policy files by moving
X11 mechanism code behind WMBackend vtable slots. Call sites now
dispatch through wm_backend->slot(), the X11 backend implements the
mechanism, and the Wayland backend provides no-ops or Wayland-native
implementations.

New vtable slots added to backend.h:
- Frame: frame_alloc_border_pixel, frame_update_texture, frame_paint_button
- NETWM: netwm_init, netwm_cleanup, netwm_update_desktop,
  netwm_get_current_desktop, netwm_update_opacity, netwm_update_actions,
  netwm_check_client_hints, netwm_check_initial_state, netwm_get_pid,
  netwm_cleanup_frame_extents
- Properties: prop_get_protocols, prop_get_check_property,
  prop_set_wmaker_protocols, prop_set_icon_tile, prop_cleanup
- Client: client_restore, client_set_state, client_send_protocol,
  client_kill, client_get_colormap_windows
- Misc: eat_expose, move_window, slide_windows, get_text_selection,
  get_shortcut_string, get_command_for_window
- Icon: icon_update_pixmap, icon_paint
- AppIcon: appicon_show, appicon_paint, appicon_bounce
- Shutdown: restore_desktop, wipe_desktop
- Resources: get_color_for_colormap, free_color, colormap_install
- Protocol: xdnd_init, motif_get_hints
- Startup: manage_all_windows
- Event: event_handle_signal_exit

Structural changes:
- MWMHints moved from motif.c local typedef to motif.h
- WProtocols given struct tag for forward declaration
- Static functions made non-static: wGetTextSelection, wGetCommandForWindow,
  wGetMWMHints, wWipeDesktop, wManageAllWindows, wNETWMUpdateWindowOpacity

Verification: grep -rn 'if (!dpy)' src/*.c returns zero results.
nm wl_backend.o confirms no new X11 symbols in Wayland path.
2026-05-13 10:01:57 +02:00
Levi Neely 803666fd5e WIP: Pure Wayland WINGs screen init (no X11 in WM path)
- WMCreateScreenWithRContext: add Wayland path that skips all X11 calls
  (no GCs, no atoms, no XListProperties, no XCreateGC)
- screen.c: skip RCreateContext in Wayland mode (pass NULL rcontext)
- Wayland path initializes: font/event/render backends, colors, fonts

Current issue: W_RealizeView tries to create X11 windows for WINGs
widgets. Need to make view realization work without X11 (views should
be pixman buffers in Wayland mode, not X windows).

The grey background + cursor render correctly. Startup reaches
WINGs init but crashes when widgets try to realize without a display.
2026-05-13 07:38:38 +02:00
Levi Neely 9b2448dd7f WIP: Wayland backend - fix atoms, OR surface compositing, frame/window ops
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.
2026-05-13 07:05:22 +02:00
Levi Neely b671f385ac gitignore: stop tracking all generated build outputs
Untrack and ignore all autotools-generated files (Makefile.in, configure,
config.h.in, compile, config.guess, config.sub, depcomp, install-sh,
missing, ltmain.sh, m4/libtool.m4, INSTALL), generated Makefiles,
compiled binaries, object files, libtool artifacts, generated headers,
man pages, and Wayland protocol headers.

Run `autoreconf -i && ./configure` to regenerate before building.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 13:36:58 +02: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