Commit Graph

460 Commits

Author SHA1 Message Date
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
Window Maker 2aeb76971a WINGs: guard WMRegisterViewForDraggedTypes against NULL X display
In Wayland mode the X11 display is NULL. WMCreateColorWell calls
WMRegisterViewForDraggedTypes which calls XInternAtom, crashing.
Bail early when display is NULL since X11 DnD is not available.
2026-05-25 13:07:55 +02:00
Window Maker d5bc733842 wayland: directly synthesize close event for in-process WINGs clients
The xdg_toplevel.close protocol message requires the client to dispatch
its wl_display, but in-process WINGs clients may not do so promptly.
Directly enqueue the WME_CLIENT_MESSAGE/deleteWindowAtom event from
wl_client_close so the closeAction fires on the next WINGs event drain.
2026-05-25 13:05:42 +02:00
Window Maker e2f73e90e5 WINGs/wayland: handle xdg_toplevel close by synthesizing WM_DELETE_WINDOW
The close button press from the compositor sends xdg_toplevel.close,
but the handler only set a flag without notifying the WINGs event
system. Synthesize a WME_CLIENT_MESSAGE with deleteWindowAtom so
the window closeAction callback fires and the app shuts down
gracefully.
2026-05-25 13:03:31 +02:00
Window Maker 4442380d50 wayland: derive menu colors from appearance preferences
Menu background colors were hardcoded. Now uses:
- scr->select_color for selected item background
- scr->menu_item_texture->normal for unselected background
- scr->menu_item_texture->dim/light/dark for cascade arrow

Text colors already used scr->select_text_color, mtext_color, dtext_color.
2026-05-25 13:01:14 +02:00
Window Maker 40295223c6 wayland: match X11 cascade arrow style with 3D shaded lines
Replace the filled triangle with three lines matching the upstream X11
implementation: a dim top edge, light bottom edge, and dark left edge,
forming a 3D right-pointing triangle indicator for submenu entries.
2026-05-25 12:59:35 +02:00
Window Maker 95c4101ed3 wayland: fix submenu cascade arrow to point right
The triangle was drawn with increasing width from left to right,
making it point left. Reverse the vertical span so the widest part
is on the left and it tapers to a point on the right.
2026-05-25 12:58:39 +02:00
Window Maker b79f699a35 wayland: call W_CheckTimerHandlers in event loop for workspace fade
WINGs timers (used by workspace name fade animation) were never firing
because the compositor event loop never called W_CheckTimerHandlers.
This function is normally invoked by WMNextEvent, but the compositor
uses a custom loop. Add the call so timers fire each iteration.
2026-05-25 12:57:12 +02:00
Window Maker 7ea6a7ac88 wayland: workspace name badge with transparent background and fade
The workspace name display was rendering with an opaque black background
and never fading out. Fix by:
- Using transparent (alpha=0) background instead of black
- Returning RGBA images from badge_render and badge_get_background
- Preserving alpha channel in badge_update instead of hardcoding 0xFF

This allows the fade animation (RCombineImagesWithOpaqueness) to work
correctly, blending text with decreasing opacity over a transparent
background until the badge disappears.
2026-05-25 12:55:38 +02:00
Window Maker 172e226947 wayland: fix NULL dereference in wl_pointer_query_full
wWorkspaceForceChange passes NULL for root_x/root_y when it only needs
the child window. Add NULL checks before dereferencing these pointers.
2026-05-25 12:51:47 +02:00
Window Maker 5e60df9f3a WPrefs: redisplay toplevel for icon position preview
Redisplaying posVF alone leaves stale content in the parent backing.
Redisplay the entire toplevel window to ensure a clean full repaint.
2026-05-25 12:49:48 +02:00
Window Maker f1ded24294 WPrefs/wayland: fix icon preview one-click-behind with extra dispatch
WINGs button callbacks trigger wl_redisplay which commits the client
surface, but the compositor only processes that commit on the next
wl_event_loop_dispatch. Add a zero-timeout dispatch after handling
WINGs events so client commits are processed immediately, making
the next scheduled frame render the updated content.

Also revert posF redisplay back to posVF (posF caused gray flash).
2026-05-25 12:49:00 +02:00
Window Maker 04e84310df WPrefs: redisplay entire posF frame for icon position preview update
Redisplaying just posVF was insufficient; redisplay the entire posF
parent frame to ensure the icon position indicator renders at its
new location immediately after a button click.
2026-05-25 12:47:07 +02:00
Window Maker 69db74b3a6 wayland: fix frame pacing regression, schedule frame after dispatch
The extra wlr_scene_output_commit broke frame pacing in nested mode by
consuming the host frame callback. Instead, move wlr_output_schedule_frame
to after wl_event_loop_dispatch so client commits processed during
dispatch are rendered on the next frame event.
2026-05-25 12:45:25 +02:00
Window Maker ee434b024a wayland: commit scene after dispatch to fix one-frame-behind rendering
Client surface commits arrive during wl_event_loop_dispatch but may be
processed after the frame event has already rendered the old state. Add
an additional wlr_scene_output_commit after dispatch to immediately
pick up any new client content, fixing the one-interaction-behind
visual update issue in WINGs clients like WPrefs.
2026-05-25 12:43:55 +02:00
Window Maker 7982e8155d WINGs/wayland: flush display after surface commit for immediate updates
Without an explicit wl_display_flush after wl_surface_commit, protocol
requests were buffered until the next event loop iteration. This caused
visual updates (like the icon position preview in WPrefs) to appear one
interaction behind.
2026-05-25 12:25:43 +02:00
Window Maker a16c25a78e WPrefs: fix icon position preview lagging one click behind
The posV widget was moved/resized but the parent frame (posVF) was
never redrawn, so the visual update only appeared on the next event
that triggered a redraw. Add WMRedisplayWidget after the move.
2026-05-25 12:05:53 +02:00
Window Maker b94bc2ce95 WPrefs: drop SIGUSR2, rely on inotify for defaults reload
SIGUSR2 is fundamentally unsafe in a multi-threaded compositor: library
threads (pango fontconfig) created after pthread_sigmask receive the
signal and crash. The Wayland event loop already has inotify watching
the defaults directory, so file changes are detected automatically
without any explicit signaling.

The early pthread_sigmask(SIG_BLOCK, SIGUSR2) is retained as a safety
measure to prevent stray SIGUSR2 from terminating the compositor.
2026-05-25 12:02:26 +02:00
Window Maker d8592f3b57 wayland: block SIGUSR2 early so library threads inherit the mask
SIGUSR2 was being delivered to pango fontconfig threads instead of the
signalfd because those threads were created before the signal mask was
set in wl_event_loop_run. Block SIGUSR2 at the very start of real_main
so all threads (including library-spawned ones) inherit the blocked
mask and the signalfd is the sole recipient.
2026-05-25 12:00:13 +02:00
Window Maker 8630a5ce95 wayland: handle SIGUSR2 via signalfd to reload defaults without dying
SIGUSR2 was not in the signalfd set, so it was delivered asynchronously
to the old signal handler which set WSTATE_NEED_REREAD. But the Wayland
event loop never checked that state flag, and the signal delivery itself
could crash the compositor.

Add SIGUSR2 to the signalfd set and handle it synchronously within the
event loop by calling wDefaultsCheckDomains directly.
2026-05-25 11:58:14 +02:00
Window Maker 9dee4f7a65 WPrefs: fix SIGUSR2 targeting wmaker instead of parent shell
The previous getppid() approach sent SIGUSR2 to the terminal process
(foot) rather than wmaker, killing the shell. Now wmaker exports
WMAKER_PID at startup and wl_send_wm_command reads it to signal the
correct process.
2026-05-25 11:55:14 +02:00
Window Maker 35226c8588 WPrefs: send SIGUSR2 to wmaker after saving settings
The Wayland event backend stub for send_wm_command was a no-op, so
WPrefs settings changes never triggered a reread in the running wmaker.
Now sends SIGUSR2 to the parent process (wmaker) on "Reconfigure",
causing wDefaultsCheckDomains to run and apply changes immediately.
2026-05-25 11:51:25 +02:00
Window Maker 9a4438fb65 cursor: respect XCURSOR_THEME and XCURSOR_SIZE environment variables
The xcursor manager was hardcoded to NULL theme with size 24. Now reads
XCURSOR_THEME and XCURSOR_SIZE from the environment, matching the
behavior of other Wayland compositors like Sway.
2026-05-25 11:48:23 +02:00
Window Maker 703872bcca xwayland: route keyboard events via wlr_seat_keyboard_notify_enter
The XWayland focus path only called wlr_xwayland_surface_activate (X11
focus) but did not notify the wlr_seat about keyboard focus. Without
wlr_seat_keyboard_notify_enter, key events were never forwarded to the
XWayland surface via the Wayland transport.

Now wl_focus_set for XWayland surfaces sets the seat keyboard and calls
wlr_seat_keyboard_notify_enter, matching the XDG toplevel path.
2026-05-25 11:45:47 +02:00
Window Maker 5bff28efcd xwayland: fix rendering by switching from map_request to associate+surface.map
The map_request signal was never firing for managed XWayland surfaces,
preventing scene node creation and window management. Switch to the
standard wlroots 0.19 lifecycle: listen for associate (surface attached),
then hook surface->events.map (content committed) before creating the
scene node and calling wManageWindow.

Also fix wl_window_get_client_attrs to report VIEWABLE based on surface
existence rather than surface->mapped, since X11 geometry (xw->width/height)
is available before the wlr_surface maps.
2026-05-25 11:43:18 +02:00
Window Maker 9bb2d02254 debug: trace xwayland scene node creation 2026-05-25 10:35:07 +02:00
Window Maker b67d3a04fb wl_backend: send 640x480 configure for xwayland surfaces with tiny initial size
xterm starts with a 10x17 pixel window. The initial configure was
sending that size back (since > 0), so xterm rendered at 10x17.
Now use 640x480 default when the initial size is < 64px.
2026-05-25 10:33:18 +02:00
Window Maker d4d5240426 wl_backend: raise xwayland minimum size threshold to 64px
xterm's initial xw_surface size is 10x17 which passed the > 1 check.
Use >= 64 as the threshold for falling back to 640x480 default.
2026-05-25 10:09:49 +02:00
Window Maker 1733e3449c wl_backend: use map_request signal instead of associate for xwayland
The associate signal fires when a wlr_surface is linked to the
xwayland surface, but this can happen before or during new_surface
processing. map_request fires when the X11 client actually sends
MapRequest — at which point WM_CLASS is set and the client is ready
to be managed and shown.
2026-05-25 09:53:19 +02:00
Window Maker 72a592a402 wl_backend: handle already-associated xwayland surfaces
If the xwayland surface already has a wlr_surface when we register
listeners (associate event already fired), trigger the map handler
directly. This fixes xterm and other X11 clients that associate
their surface before the new_surface handler runs.
2026-05-25 09:48:42 +02:00
Window Maker 044a5b3486 wl_backend: use minimum 640x480 for xwayland surfaces with tiny initial size
xterm and other X11 clients create a small initial window then resize.
At map time, xw_surface->width/height may still be the initial tiny
value (e.g. 10x17). wManageWindow reads this and creates a tiny frame.
Use 640x480 as fallback when width/height <= 1.
2026-05-25 09:13:42 +02:00
Window Maker c243ac22ab wl_backend: don't skip XWayland surfaces without initial class/title
X11 clients (like xterm) create their window first, then set WM_CLASS
before mapping. The previous code skipped surfaces that had no class
AND no title at new_surface time, marking them override_redirect. This
prevented xterm and other well-behaved X11 apps from ever being managed.

Fix: log a warning but continue registering listeners. The surface will
be managed when it maps (associate signal) at which point WM_CLASS is
typically set.
2026-05-25 09:06:25 +02:00
Window Maker ffc4806f0b WINGs: implement keysym/keycode/modifier stubs and window_set_title
- wl_keysym_to_string: xkb_keysym_get_name
- wl_keysym_to_keycode: iterate keymap to find keycode
- wl_keycode_to_keysym: xkb_keymap_key_get_syms_by_level
- wl_keysym_convert_case: xkb_keysym_to_lower/upper
- wl_get_modifier_keysyms: standard XKB_KEY_* for 8 modifiers
- wl_window_set_title: calls xdg_toplevel_set_title
- W_WLClientGetKeymap accessor for xkb_keymap
2026-05-24 22:25:36 +02:00
Window Maker b7fb4725c4 WINGs/wview_wl: implement wl_balloon_draw for tooltip rendering 2026-05-24 22:19:53 +02:00
Window Maker b52ca0747c WINGs: commit all mapped toplevels on every event loop flush
Widgets that paint directly to their view backing (fill_rect,
draw_line, W_DrawRelief, W_PaintText) without going through the
DOUBLE_BUFFER pixmap_copy path never triggered a surface commit.
The painted content stayed in the pixman buffer but was never
submitted to the compositor — making popup menus, radio buttons,
text fields, sliders, and other controls appear empty/stale.

Fix: W_WLClientCommitAllToplevels() iterates all mapped toplevels
and commits their surfaces. Called from wl_flush() which runs once
per event loop iteration (in waitForEvent). This ensures any
direct-paint operations become visible on the next frame regardless
of which render path was used.
2026-05-24 22:17:17 +02:00
Window Maker db915281e0 WINGs/wevent_wl: implement translate_coordinates and get_window_geometry
Both were no-op stubs returning 0/False.  Editmenu uses these to
compute the original screen position of an item before drag-and-drop,
then animates the item back to that position via slideWindow on
revert.  With both returning 0, the slide animation moved popups
from where they were to (0, 0) instead of back to their origin —
producing the 'menus moving on their own' effect.

translate_coordinates: walk up from src view accumulating pos.x/y
to compute the position relative to the toplevel.

get_window_geometry: return the view's pos/size directly.
2026-05-24 19:27:33 +02:00
Window Maker 834efaff09 Remove stray empty file accidentally committed 2026-05-24 19:24:03 +02:00
Window Maker 8c8293acc9 debug: trace Z-order in wmaker_popup_apply; remove noisy debug 2026-05-24 19:23:43 +02:00
Window Maker 01508ef31a debug: trace commit_locked 2026-05-24 19:17:00 +02:00
Window Maker eb93d30fd9 debug: trace popup expose 2026-05-24 19:13:57 +02:00
Window Maker 54c8d585c3 WINGs/wpopupbutton: paint all items in expose, not just highlighted
paintMenuEntry was only called for the highlighted item on expose.
On X11 the X server auto-filled the rest of the window with the
background pixel, so unpainted items looked grey-but-empty.  On
Wayland the buffer starts transparent — unpainted items showed
through to whatever was behind, making the popup invisible.

Iterate all items in the expose handler so the menu's full content
is visible when it first appears.
2026-05-24 19:08:52 +02:00
Window Maker bf356c2567 WINGs/wclient_wl: clear input focus refs on toplevel destroy
When a popup toplevel is destroyed (e.g., menu editor submenu closes),
its WLClientToplevel struct is freed.  If wlc_kbd_focused or
wlc_ptr_focused pointed to it, subsequent input events dereferenced
the dangling pointer and crashed (saw it in keyboard_handle_leave).

Clear both refs in wl_client_view_destroy_backing before freeing.
2026-05-24 19:05:35 +02:00
Window Maker b040b5c7fe wmaker-popup-v1: raise popup above parent and track parent moves
Two issues:
1. Popups rendered behind their parent toplevel because the scene node
   wasn't raised on apply. Add wlr_scene_node_raise_to_top so popups
   appear above the parent.
2. When the parent toplevel moved, popups stayed at their old screen
   position. In wl_window_move (compositor-side), after a regular
   toplevel's position changes, iterate all popups and re-apply those
   whose popup_parent is this toplevel so they track the parent.
2026-05-24 18:58:07 +02:00
Window Maker baf021fa0c WPrefs/editmenu: paint with view backColor; default non-title items grey
paintEditMenuItem always filled with scr->white. On X11 the per-window
background was rendered by the X server based on WMSetWidgetBackgroundColor.
On Wayland we have to draw it ourselves.

Use the view's stored backColor if set; default to white otherwise.
Also set the default background of non-title items to grey at creation
time (previously only title items got an explicit colour, so non-title
items had a NULL backColor and rendered white).
2026-05-24 18:53:37 +02:00
Window Maker 931469dbf4 WPrefs/editmenu: use WME_ event types instead of X11 event types
editmenu.c switched on event->type (which is a WMEventType enum) but
the case labels used X11 event names (Expose, DestroyNotify, ButtonPress,
ButtonRelease, MotionNotify).  These are different numeric values, so
no case ever matched — menu items never painted, never received clicks,
never handled drag.

Replace with WME_EXPOSE, WME_DESTROY, WME_BUTTON_PRESS, WME_BUTTON_RELEASE,
WME_MOTION.
2026-05-24 18:49:59 +02:00
Window Maker 27802e6d43 wmaker-popup-v1: add set_parent for parent-relative positioning
The previous version had set_position(x, y) in compositor-global
coordinates, but Wayland clients don't know their toplevel's screen
position — the editmenu and popup button code naturally compute
positions relative to the parent toplevel via accumulated view->pos.

Add set_parent(xdg_toplevel) request. When a parent is set,
set_position(x, y) is interpreted as offsets from the parent
toplevel's top-left corner.

Compositor side resolves the parent's wl_toplevel_view via
wlr_xdg_toplevel_from_resource → wl_find_view_by_xdg_surface,
then adds parent->x and parent->y to the requested offsets.

Client side (wclient_wl.c) tracks the first non-popup toplevel as
ctx->main_toplevel and calls set_parent on every popup wrapper to
anchor it to the application's main window.
2026-05-24 18:37:48 +02:00
Window Maker 1cf271932a debug: trace wmaker-popup-v1 protocol flow 2026-05-24 18:31:37 +02:00
Window Maker b5cc53a8a8 .gitignore: exclude generated wmaker-popup-v1 files; keep protocols/
Generated *-protocol.c and *-server-protocol.h files were accidentally
committed in the previous commit. The .gitignore was also excluding
the protocols/ source directory (where the XML lives). Fix both.
2026-05-24 18:28:51 +02:00
Window Maker 60348da411 Implement wmaker-popup-v1 Wayland protocol for client-driven popup positioning
Standard xdg_shell does not allow Wayland clients to position toplevels —
the compositor decides placement.  WINGs UI patterns require client-driven
positioning (e.g., a dropdown popup must appear directly below its trigger
button; menu editor items must be placed by the client at specific screen
coordinates).

This protocol lets the client wrap an xdg_toplevel with a wmaker_popup
object and call set_position(x, y) before the surface is mapped.  The
compositor honours the requested position when the surface becomes visible
and on subsequent set_position calls.

Files:
- protocols/wmaker-popup-v1.xml: protocol definition
- src/Makefile.am, src/Makefile: server-protocol.h + protocol.c generation
- WINGs/Makefile.am, WINGs/Makefile: client-protocol.h + protocol.c generation
- src/backend/wayland/wl_backend.c: wmaker_popup_manager global, get_popup
  handler that wraps an xdg_toplevel; set_position handler that updates
  view->popup_x/y and calls wmaker_popup_apply to move the frame_buf
  scene tree.  Apply runs at toplevel_map time too for pre-map positions.
- WINGs/wclient_wl.c: bind manager in registry, wrap popup toplevels with
  wmaker_popup, expose W_WLClientPopupSetPosition.
- WINGs/wview_wl.c: wl_move calls W_WLClientPopupSetPosition for popup
  toplevels so WMMoveWidget propagates to the compositor.
- WINGs/wevent_wl.c: wl_move_window also routes to popup positioning.
2026-05-24 18:27:55 +02:00