Commit Graph

22 Commits

Author SHA1 Message Date
lkn 0e0847b48b wayland: remove persistent X display connection
wlroots manages XWayland internally via its own xcb connection.
Our second Xlib connection (XOpenDisplay) interfered with XWayland's
event routing, preventing WM_DELETE_WINDOW from reaching X clients
and causing slow XWayland startup.

Removed:
- Persistent wl_state.x_display / x11_event_source
- X11 event pump (wl_handle_x11_events)
- Xlib-based icon capture, GC creation, key/message forwarding
- XSetErrorHandler on our connection
- Reentrant wl_event_loop_dispatch in wl_event_flush (caused UAF)

Root cursor now set via wlr_xwayland_set_cursor (wlroots API).
XWayland close button now works correctly.
2026-06-27 19:09:53 +02:00
lkn 01fb5f9e92 wayland: add canary-based heap overflow detection to frame_bufs
Each frame_buf gets a canary field (0xDEADBEEF) set at creation.
Before every frame_paint, all canaries are checked. If one is
trashed, dumps all frame_buf IDs/sizes/addresses to /tmp/wm-canary.log
before aborting.

Set canary in ALL frame_buf creation paths:
- wl_frame_create_toplevel, wl_frame_create_child
- wl_fake_leader_create
- wl_client_reparent (WINGs view frame_buf creation)
- wl_view_commit_backing_impl (WINGs toplevel)
- wl_screen dock_shadow and icon frame_bufs
- wl_window pixmap-to-frame_buf path
2026-06-26 07:07:06 +02:00
lkn ab933c6565 wayland: fix close button for internal window panels
The close button on internal windows (dock app settings, etc.) did
nothing because:

1. wwin->protocols.DELETE_WINDOW was never set for internal windows,
   so windowCloseClick skipped the wClientSendProtocol call.

2. Even if it were called, wl_client_send_protocol just called
   client_close which looks for an XDG/XWayland surface. Internal
   windows have synthetic WINGs view IDs, not real surfaces.

Fix: set DELETE_WINDOW protocol flag in wManageInternalWindow, and
handle internal windows in wl_client_send_protocol by calling
wUnmanageWindow directly.
2026-06-24 22:25:11 +02:00
lkn 144b089dff fix UAF: NULL last_hovered_view when view is destroyed
W_ViewDestroyedFn hook clears last_hovered_view when the pointed-to
view is destroyed. Prevents use-after-free in motion handler when
the hovering over a view inside a dialog that is then closed.
2026-06-24 00:20:07 +02:00
lkn 321df47493 send XDG fullscreen state to Wayland clients
Add client_set_fullscreen backend vtable entry. Call
wlr_xdg_toplevel_set_fullscreen on enter/leave so clients
(e.g. Firefox) know to render content at full size.
2026-06-23 20:40:57 +02:00
lkn 143b8906bb wayland: fix view_table probe chain corruption on widget reopen
The WINGs view_table (open-addressing hash, size 256) used id=0 as both
"empty" and "deleted". Zeroing a slot on removal broke probe chains for
entries that hashed past that slot. After two dialog open/close cycles
(~40 views created and destroyed), enough chains were broken that
W_GetViewForWindow/W_GetViewBacking returned NULL for valid IDs.

Fix: use a tombstone marker (id=1) for deleted slots. Lookups skip
tombstones (continue probing), inserts reuse them. This is the standard
approach for deletion in open-addressing hash tables (Knuth Vol.3 §6.4).

Also:
- wl_destroy now calls view_table_remove + frees backing pixman image
- wl_frame_destroy cleans up child frame_bufs
- client_reparent existing path re-links backing and recreates scene_buf
- client_reparent to root destroys the child frame_buf
2026-06-22 00:21:42 +02:00
lkn 1ee10d37f5 wayland: use xdg geometry instead of surface size for CSD clients
Firefox and other CSD clients include invisible shadow borders in their
surface buffer.  Use xdg_surface->geometry (the client-declared content
rect) for:
- reporting client width/height to the WM frame
- sizing the frame on commit
- offsetting the scene node so shadows are outside the frame bounds

Falls back to surface->current.width/height when geometry is unset.
2026-06-21 19:17:06 +02:00
lkn c027f092c0 cleanup: remove debug wwarning/fprintf output
Remove diagnostic output from wl_framebuf.c (hit debug), wl_handlers.c
(button routing), wl_grabstate.c (grab/ungrab), wl_client.c (reparent),
wl_xdg.c (toplevel unmap), window.c (wWindowMap), wview_wl.c
(map/unmap), superfluous.c (MakeGhostIcon), and appicon.c (move loop).

Also simplify the wl_unmap logic in wview_wl.c.
2026-06-21 17:25:06 +02:00
lkn 405c481e38 clean up diagnostics in wl_unmap and wl_view_scene_node_set_enabled
Remove duplicate W_ViewSceneNodeSetEnabledFn call, fix malformed debug code.
wl_unmap now logs cleanup diagnostics once. wl_view_scene_node_set_enabled
logs proxy ID lookup, match result, and no-match case properly.
2026-06-07 15:38:19 +02:00
lkn 7b15ded31a add diagnostics to wl_view_scene_node_set_enabled for popup stale-pixel tracing 2026-06-07 15:35:25 +02:00
lkn 60efe4db78 wl_view_scene_node_set_enabled: find WINGs client toplevels via wl_proxy_get_id
The function only handled wl_frame_buf entries. WINGs client popup menus have
their own xdg_toplevel surface with a scene_node but no wl_frame_buf. Their
WINGs view window IDs (0x20000000+) differ from compositor view IDs
(0x10000000+), so wl_find_view_by_id could not find them.

Fix: add wlc_top_get_surface_id() in wclient_wl.c which returns the
libwayland-client proxy ID for the wl_surface. In
wl_view_scene_node_set_enabled, use this ID to iterate the compositor
toplevel_list and find the matching wlr_surface resource by object ID.
Then enable/disable the view scene_node directly.
2026-06-07 15:00:08 +02:00
lkn 3e5c594d6f Revert "wl_view_scene_node_set_enabled: also handle WINGs client toplevels (popups)"
This reverts commit 971089b3d9.
2026-06-07 14:50:58 +02:00
lkn 971089b3d9 wl_view_scene_node_set_enabled: also handle WINGs client toplevels (popups)
The function only searched for wl_frame_buf entries to enable/disable
their scene nodes. WINGs client popup menus have their own xdg_toplevel
surface with a scene_node but no wl_frame_buf. On unmap, the scene node
was never disabled, so the popup content remained rendered underneath
other windows.

Fix: fall through to wl_find_view_by_id when no frame_buf is found,
and operate on the wl_toplevel_view->scene_node instead.
2026-06-07 13:45:50 +02:00
Window Maker 0453888f08 split USE_X11_BACKEND from XWayland: USE_XWAYLAND now controls X11 support in the wayland backend (X11 wrapper functions, error handlers, XWayland event loop, X11 window helpers), separate from USE_X11_BACKEND which controls the x11_backend.c classic WM mode 2026-06-05 19:09:55 +02:00
Window Maker 598f6f304b finish X11 call isolation: guard XSendEvent in wl_client.c, guard X11 error handlers in wl_extensions.c, guard vtable entries in wl_stubs.c 2026-06-05 18:42:26 +02:00
Window Maker b39c03e69e confine X11 calls to wl_xdisplay.c and wl_xwayland.c: move XInternAtom/XFlush/XSync to wl_xdisplay.c, move XGetImage/opacity to wl_xwayland.c, remove <X11/Xlib.h> from wl_atom.c/wl_event.c/wl_client.c/wl_framebuf.c 2026-06-05 18:30:20 +02:00
Window Maker 3eaf2bc499 cleanup: remove stale Phase planning comments and DBG/DBG1 debug macros from all wayland backend source files 2026-06-04 21:34:37 +02:00
Window Maker 29aeffd6ac decompose wl_stubs.c: move remaining real implementations to module files 2026-06-02 21:25:27 +02:00
Window Maker 859af074ad cleanup: remove stale Phase planning comments from all wayland backend files 2026-06-02 20:23:26 +02:00
Window Maker cbc9fa5a84 decompose wl_backend.c: extract wl_client.c 2026-06-02 10:28:48 +02:00
Window Maker b9450d16ad remove corrupted extraction files not yet building 2026-06-02 10:07:29 +02:00
Window Maker 5175cf880c decompose wl_backend.c: extract event, stacking, overlay modules 2026-06-02 10:07:10 +02:00