Commit Graph

171 Commits

Author SHA1 Message Date
lkn 38a0009e03 wl_unmap: send NULL buffer to WINGs client toplevel surfaces on unmap
When a WINGs client popup is unmapped (popDownMenu), the scene node is
disabled via W_ViewSceneNodeSetEnabledFn. But for WINGs client toplevels
(which have their own wl_surface + xdg_toplevel via libwayland-client),
the surface still holds its last committed buffer. Disabling the scene
node is not enough - the compositor still sees the surface as mapped.

Fix: add wl_client_toplevel_unmap which attaches NULL to the wl_surface
and commits, properly unmapping it from the compositor. Wire through
W_WLClientUnmapFn function pointer in wview_wl.c, called from wl_unmap
for topLevel views.
2026-06-07 14:51:30 +02:00
lkn 1b04023591 Revert "wl_unmap: force commit sibling toplevels to clear stale popup pixels"
This reverts commit a9397b8291.
2026-06-07 14:50:58 +02:00
lkn a9397b8291 wl_unmap: force commit sibling toplevels to clear stale popup pixels
When a topLevel popup is unmapped, wl_redisplay(view-parent) clears stale popup pixels from the parent backing. But for rootView (common parent), the commit at the end of wl_redisplay is a no-op because rootView has no WLClientToplevel. The cleared backing was never pushed to any surface. Fix: iterate parent child list and force-commit every topLevel sibling, pushing the cleared backing to their wl_buffers.
2026-06-07 14:46:02 +02:00
lkn ff86d8055f wl_map: raise popup to top on remap via wmaker-popup-v1
When a WINGs popup is unmapped (popDownMenu) and remapped (popUpMenu),
the scene node is re-enabled via W_ViewSceneNodeSetEnabledFn, but its
Z-order position stays at its original insertion point. Other surfaces
mapped while the popup was disabled may now sit above it, making the
popup invisible when it reappears.

handle_toplevel_map (which calls wmaker_popup_apply to raise the
popup) only fires on the initial xdg_surface map event, not on
scene-node re-enable. Fix by calling W_WLClientPopupSetPosition on
every topLevel popup map, which triggers wmaker_popup_v1_set_position
→ wmaker_popup_apply → wlr_scene_node_raise_to_top.
2026-06-07 13:42:25 +02:00
lkn 10a22a8484 wpopupbutton: only clear menu state on leave from menuView, not on bPtr->view
When the pointer leaves the main button view to enter the popup surface,
the WME_LEAVE event fires for bPtr->view (which shares the same
handleActionEvents handler). This unconditionally cleared insideMenu=0
and highlightedItem=-1, causing the subsequent button release to fail
the selection check and not fire the action.

Fix: guard the leave handler with event->window == bPtr->menuView->window
so that clearing only happens when the pointer actually leaves the menu
view, not when it just leaves the main button on its way to the popup.
2026-06-07 13:38:46 +02:00
lkn d43ceae081 wclient_wl: hit-test child views on pointer enter/leave during drag
pointer_handle_enter always sent WME_ENTER to the toplevel root view
with _view_target=NULL, so child views (e.g. menuView) never received
proper WME_ENTER with correct local coordinates when the pointer entered
the popup surface during a held drag.

Fix: hit-test against the newly-focused toplevel on enter, find the
deepest child at the pointer position, and deliver WME_ENTER to that
child view with proper local coordinates and _view_target set.

Also fix pointer_handle_leave to deliver WME_LEAVE to the deepest
child (via wlc_ptr_child_focus) instead of the toplevel root view,
matching the enter side.
2026-06-07 13:33:19 +02:00
lkn a63c97638d wclient_wl: fix cross-surface motion/release during implicit grab
When a popup menu is opened during a button-held drag, the compositor
changes pointer focus to the popup surface as the pointer enters it.
But pointer_handle_motion always delivered events to the originally
grabbed view (wlc_ptr_grab), never hit-testing inside the popup.
This meant wpopupbutton.c received motion events targeted at the
main button view with coordinates relative to that view, not the menu.

Fix: in both pointer_handle_motion and pointer_handle_button (release),
check whether the grab target is within the currently focused toplevel.
If not (the pointer entered a different surface), use wlc_hit_test
against wlc_ptr_focused to find the correct child view with proper
local coordinates.

Also enable enter/leave synthesis during grabs when target changes,
so child views receive proper WME_ENTER/WME_LEAVE as the pointer
moves between them across the cross-surface boundary.
2026-06-07 13:31:16 +02:00
lkn d2c9a59344 popUpMenu: init highlight from pointer position on open, not selectedItemIndex
When the popup opens via ButtonPress on the main button, compute the
highlighted item from the pointer position relative to the menu view,
matching upstream WINGs semantics. Previously highlightedItem was set
to selectedItemIndex, which might be -1 (no prior selection), causing
the popup to open with no visible highlight until the first motion event.

The fix uses event->u.button.y_root - menuView->pos.y divided by item
height to determine which item the pointer is over when the menu appears.
This item is painted as highlighted immediately on open.
2026-06-07 13:08:21 +02:00
lkn 3a2f5e96db wl_pointer_grab: replace no-op stub with compositor-grab delegation
The WINGs view backend wl_pointer_grab was a no-op, meaning the
press-drag-release sequence for popup menus had no effect on compositor
state. On X11 this would call XGrabPointer to redirect events to the
menu window; the equivalent on Wayland is to activate the compositor
wl_pointer_grab which sets wl_state.grab_type and suppresses unwanted
cursor resets and axis leaks during the interactive drag.

Implementation: add function pointers W_WLPointerGrabFn and
W_WLPointerUngrabFn in wview_wl.c, initialized to NULL. The compositor
wires them to wl_pointer_grab / wl_pointer_ungrab at startup.
The WINGs view backend now delegates to the compositor instead of
silently returning.
2026-06-07 13:05:57 +02:00
lkn 7285ca6286 paintMenuEntry: redraw full row on non-highlight instead of just gray fill
The non-highlight path in paintMenuEntry only filled the row with gray
and returned early, erasing the item text, relief border, and indicator
pixmap. On Wayland this was immediately visible because the cascade+commit
on fill_rect commits every draw operation to the wl_surface.

Fix: after filling the gray background, redraw the relief border, the
item text (in black or darkGray depending on enabled state), and the
indicator pixmap for the selected item — matching what the highlight path
and makeMenuPixmap do.
2026-06-07 12:53:46 +02:00
lkn 3ccf87ff4f popup: fix click selection and blank second-open
Bug 1: Clicks on menu items did not select the correct item.
The WME_BUTTON_PRESS handler always called popUpMenu() which re-mapped
the already-open menu and reset highlightedItem to selectedItemIndex,
ignoring the click position. Since no motion event follows a
click-without-drag, the highlight was never corrected.
Fix: distinguish menuView vs main button events via event->window.
For menuView clicks, compute highlightedItem from click.y directly
without re-opening the menu.

Bug 2: Second popup open showed a blank gray box.
wl_unmap disabled the compositor scene node via W_ViewSceneNodeSetEnabledFn
but wl_map never re-enabled it. On re-map, the buffer was committed
to the wl_surface but the scene node stayed disabled.
Fix: re-enable scene node in wl_map before redisplay.
2026-06-07 12:47:24 +02:00
lkn 2c3a1764a4 popUpMenu: map before render, use makeMenuPixmap for robust initial content
Reorder popUpMenu to:
1. Resize menuView before map (correct backing dimensions)
2. W_MapView first (wl_map calls wl_redisplay which fills background
   and dispatches WME_EXPOSE — the old redisplay() before map was a
   no-op on Wayland because wl_redisplay returns early when !mapped)
3. Copy makeMenuPixmap() output into menuView->window backing as a
   safety net, ensuring the buffer has complete menu content
   independent of expose-timing correctness
4. paintMenuEntry for initial highlighted item

This ensures the first visible popup buffer has all menu items
rendered regardless of the order in which the Wayland configure
and commit events arrive.
2026-06-07 11:32:23 +02:00
lkn e063d8fa87 WINGs Wayland: fix popup dropdown blank gray box and motion highlight rendering
Three related fixes for WINGs popup menus on Wayland:

1. wl_client_toplevel_resize: update pending_w/h after resize
   (wclient_wl.c:545-546). Without this, the configure handler sees
   stale pending dimensions and creates a wrong-sized buffer,
   discarding the one containing the menu text.

2. Export wl_redisplay_depth (wview_wl.c:288) so render and font
   backends can detect when they are called from within a full
   redisplay cycle vs. from an event handler.

3. Add cascade+commit to render_wl_fill_rect (wrender_wl.c:162-183)
   and wl_draw_string (wfont_wl.c:183-208) when not inside a
   redisplay cycle. This makes motion-driven highlight changes
   (text color, background fill) immediately visible by compositing
   up the view tree and committing the toplevel wl_surface.
2026-06-07 11:24:00 +02:00
lkn 57a8973bc2 fix: wlclient_dispatch stops spinning when compositor closes the socket (NULLs ctx->display, making subsequent calls a no-op) 2026-06-06 16:53:13 +02:00
lkn a89859ab32 cleanup: remove WL_DECOMPOSITION_PLAN.md (decomposition complete) 2026-06-06 11:01:04 +02:00
Window Maker aaf5e94b05 fix full build: add W_GetViewForXWindow stub for Wayland-only build 2026-06-04 08:15:15 +02:00
Window Maker 258b625429 fix util/ build: add W_KeycodeToKeysym stub for Wayland-only build 2026-06-04 08:13:03 +02:00
Window Maker 8c1cbfaca8 Wayland-only build: guard X11 backend in Makefile.am, add wm_backend.c, WINGs _wl.c stubs 2026-06-04 08:07:21 +02:00
Window Maker cfa1e4aad7 WINGs: add wappresource_wl.c, wballoon_wl.c + fix wcolorpanel_wl.c for Wayland-only builds 2026-06-02 22:44:10 +02:00
Window Maker 86f7510a13 fix: non-responsive WINGs widgets on Wayland (overlapping sibling views + cascade compositing) 2026-05-30 15:29:04 +02:00
Ollie 2eef17de24 fix: slider page-click uses event->u.motion.x/y instead of button.x/y on Wayland
WMEButton and WMEMotion are separate structs in the WMEvent union with different field layouts — u.motion.x is at a different memory offset than u.button.x. The WME_BUTTON_PRESS handler in wslider.c was calling valueForMousePoint(sPtr, event->u.motion.x, event->u.motion.y) which reads uninitialized memory on Wayland (memset zero = 0). On X11 this happened to work because the X11 event translator writes to both union members. Fix: changed all event->u.motion.x/y references to event->u.button.x/y in the WME_BUTTON_PRESS case.
2026-05-30 13:31:50 +02:00
Ollie d615077df8 fix: sliders not responding on Wayland — add W_RedisplayView after paintSlider
Slider value changes (from click, drag, or programmatic set) call paintSlider to draw the new knob position into the pixman backing buffer, but the backing was never committed to the scene graph on Wayland. Added W_RedisplayView(slider->view) after each paintSlider call in: WMSetSliderValue, WMSetSliderMinValue, WMSetSliderMaxValue, and handleActionEvents (WME_MOTION/WME_BUTTON_RELEASE). The expose handler path does NOT get W_RedisplayView to avoid recursion.
2026-05-30 11:57:24 +02:00
Window Maker fd6e972bbf wl_backend: fix W_ViewSceneNodeSetEnabledFn never wired — gview scene buffer stayed on after unmap
The blue position indicator (gview — geometry view with blue-gray background,
white coordinate text) was visible during window move, but never disappeared
when the move ended.

Root cause: W_ViewSceneNodeSetEnabledFn was declared in wview_wl.c and
called by wl_unmap() to disable the view's scene buffer node, but
wl_backend.c never wired it up — the pointer was NULL.

Also: add auto-create of frame_buf for WINGs toplevel views not explicitly
reparented (switch panel, menus, gview), sync position from WINGs view on
commit, auto-realize children in wl_map/wl_map_subviews, and guard scene
node enablement against unmapped views.
2026-05-30 11:17:10 +02:00
Ollie 9ec08d9b6a fix: make view_table_remove non-static so wview.c can call it 2026-05-29 17:07:52 +02:00
Ollie 071f8aba6e fix extern declaration placement for view_table_remove 2026-05-29 17:06:41 +02:00
Ollie 03fa233ff7 wview: remove view from lookup table in destroyView before freeing — fix use-after-free race 2026-05-29 17:06:19 +02:00
Ollie 05b66c2b5c textfield: fix stuck waitingSelection after sync paste on Wayland (blocked key events) 2026-05-28 21:47:23 +02:00
Ollie f054296eb1 textfield: always re-acquire selection on double-click (fix Wayland paste→stale ownsSelection) 2026-05-28 21:44:51 +02:00
Ollie f2b4d25b81 selection: fix use-after-free crash from duplicate handler delete 2026-05-28 21:42:02 +02:00
Ollie 2b692a34f1 selection: delete stale handler on Wayland so re-selection pushes fresh data 2026-05-28 21:36:26 +02:00
Ollie 5d456d5b95 selection: fix crash on Wayland when W_NativeInternAtom called with NULL display 2026-05-28 21:18:18 +02:00
Ollie 367b488e47 selection: push data to compositor on acquire for Wayland (select→paste) 2026-05-28 21:04:24 +02:00
Ollie 784b4c89ce balloon: fix leave tracking + multi-line height in wl_balloon_draw 2026-05-28 20:37:51 +02:00
Ollie 14b660ff50 colorpanel: split into wcolorpanel.c + _x11.c + _wl.c (412->0 X11 calls) 2026-05-28 19:55:41 +02:00
Ollie 39b63a8184 DND: compositor-internal drag icon overlay + cursor feedback + cross-client wiring 2026-05-28 19:35:41 +02:00
Window Maker db8cd0ea34 WINGs: fix WPrefs not launching in X11 mode
Three issues prevented WPrefs from being managed by wmaker in X11:

1. W_X11OpenDisplay: XOpenDisplay("") fails; treat empty string as NULL
   so it falls back to DISPLAY env var.

2. wevent_x11.c/wevent.c: MapRequest and ConfigureRequest events must
   bypass WINGs view lookup (both _view_target in x11_fetch and
   W_GetViewForWindow in WMHandleEvent) to reach DispatchEvent via
   extraEventHandler.

3. wview_x11.c: x11_create_root must use RootWindow() not
   scr->rootWin (which may be an intermediate window created by
   RCreateContext for non-default visuals). Otherwise toplevel
   WINGs windows are created as children of the wrong parent and
   their MapRequest never reaches the WM.
2026-05-25 18:08:09 +02:00
Window Maker 8700f9a955 WINGs: fix XOpenDisplay with empty string failing for WPrefs
WPrefs.app/main.c defaults display_name to "" (empty string).
W_X11OpenDisplay passed this directly to XOpenDisplay, but
XOpenDisplay("") is not equivalent to XOpenDisplay(NULL) — the
former fails while the latter uses the DISPLAY environment variable.

Treat empty display string as NULL so XOpenDisplay falls back to
the environment variable.

Also remove debug traces from event.c and x11_backend.c.
2026-05-25 17:27:48 +02:00
Window Maker 03fe6771cc WINGs/wevent_x11: fix MapRequest/ConfigureRequest not reaching WM dispatch
SubstructureRedirect events (MapRequest, ConfigureRequest) are delivered
to the root window. Since the root window has a WINGs view registered
(the WMScreen root view), W_GetViewForXWindow resolves it and
WMHandleEvent dispatches to the view handlers instead of falling through
to extraEventHandler (DispatchEvent).

This caused WINGs-based apps like WPrefs to never have their windows
managed by the WM - the MapRequest was silently consumed.

Fix: skip the view lookup for MapRequest and ConfigureRequest events so
they always reach DispatchEvent via extraEventHandler.
2026-05-25 17:17:03 +02:00
Window Maker b714cb783d x11: fix menu rendering, balloon tooltips, clip arrows, and event handling
Menu entry painting:
- Add drawFrame() calls for 3D beveled entries (WTEX_SOLID)
- Add menu_text_clearance to text Y positioning
- Add left-side indicator drawing (radio/check/snap pixmaps)
- Add indicator X offset (MENU_INDICATOR_SPACE)
- Fix disabled+selected text color
- Fix texture-aware background clearing
- Add cascade arrow for submenu entries

Balloon tooltips:
- Implement x11_balloon_show() with text and mini-preview rendering
- Previously was a no-op stub

Clip arrows:
- Draw workspace-switching triangles on clip icon
- Previously stubbed out

Event handling:
- Add MapRequest, ConfigureRequest, ReparentNotify translation to
  xev_to_wme() in WINGs/wevent_x11.c
- These WM-critical events were silently dropped, preventing new X
  clients (e.g. xterm) from being managed
2026-05-25 17:04:30 +02:00
Window Maker f878117013 WINGs: deliver maskless events (selection, mapping) to all handlers
Selection and mapping events have mask 0 in the type table (matching
X11 semantics where they bypass event masks). Change the dispatch
check to deliver events with mask==0 to all registered handlers,
so these events are not silently dropped.
2026-05-25 13:39:18 +02:00
Window Maker 1954fa2a12 WINGs: fix WME_CLIENT_MESSAGE mask so close events reach handlers
The wmeMaskForType table had WME_CLIENT_MESSAGE mapped to 0, so
WMHandleEvent never dispatched client messages to registered handlers.
The window close handler (registered with ClientMessageMask) was never
called. Set the correct mask so the deleteWindow protocol works.
2026-05-25 13:37:32 +02:00
Window Maker d522fc87c5 wayland: use non-blocking read_events for client dispatch
The poll-based wlclient_dispatch with timeout 0 missed events that
were already buffered. Use prepare_read/read_events/dispatch_pending
which reads whatever is available on the socket without polling.
2026-05-25 13:33:30 +02:00
Window Maker fe2ec1fb9e wayland: pump client display in main loop for close button support
In-process WINGs clients have their own wl_display connection that
needs to be dispatched for xdg_toplevel.close to be received. Add
W_WLClientDispatchPending() and call it each main loop iteration
so protocol events reach the client-side handlers promptly.
2026-05-25 13:32:59 +02:00
Window Maker 36c2396130 WINGs/wayland: defer redisplay during W_RealizeView to prevent crash
During W_RealizeView, child views with mapWhenRealized triggered
wl_map which called wl_redisplay on the toplevel. This ran expose
handlers on a partially-realized widget tree, causing backing image
corruption from resizes during redisplay.

Fix: track realization depth with W_WL_Realizing counter. wl_map
skips redisplay when realization is in progress. After the outermost
W_RealizeView completes, trigger a single redisplay of the toplevel
to paint everything correctly.
2026-05-25 13:29:46 +02:00
Window Maker 6e18e1fe0d WINGs/wayland: use backing image dimensions for fill_rectangles
The fill_rectangles call used view->size which can exceed the backing
image dimensions when a view is resized during realization without its
backing being reallocated. This wrote past the allocated buffer,
corrupting the heap and causing later pixman_image_composite32 crashes.
Use pixman_image_get_width/height of the actual backing instead.
2026-05-25 13:22:41 +02:00
Window Maker 7a93b1d389 WINGs/wayland: remove diagnostic fprintf, keep bounds clipping
Remove the verbose COMPOSITE fprintf and BAD composite warning that
were used for debugging. Keep the source/destination bounds clipping
as it correctly handles the case where view->size diverges from the
backing image dimensions during realization.
2026-05-25 13:21:14 +02:00
Window Maker ef98cc3c64 WINGs/wayland: prevent infinite redisplay recursion during resize
The font prefs panel crashed because wl_resize called wl_redisplay
while already inside a redisplay. This caused expose handlers to
trigger more resizes, creating unbounded recursion and memory growth
(backing images growing to 1024+ pixels wide). Skip the redisplay
from wl_resize when wl_redisplay_depth > 0 — the ongoing parent
redisplay will composite the resized child at its new size.
2026-05-25 13:19:39 +02:00
Window Maker 4a6c5330a3 WINGs/wayland: also clip composite to destination bounds and check data
The previous source-only clamp was insufficient. Also check that both
src and dst have non-NULL pixel data, and clip the composite region to
the destination image dimensions to prevent out-of-bounds writes.
2026-05-25 13:12:58 +02:00
Window Maker 53b0b65b3b WINGs/wayland: clamp pixman composite to actual backing image size
During W_RealizeView the WME_EXPOSE handler can trigger child resizes
that make view->size exceed the backing image dimensions. Clamp the
composite width/height to the source image actual size to prevent
out-of-bounds reads in pixman_image_composite32.
2026-05-25 13:12:17 +02:00
Window Maker 9c83db6977 WINGs/wayland: guard pixman composite against zero-sized views
Font prefs panel crashed in pixman_image_composite32 during W_MapView
because a child view had zero width/height. Skip compositing for
zero-sized views.
2026-05-25 13:09:59 +02:00