Skip to content

Fix negative dimensions in scene rect sizing#9080

Open
beeblebrox wants to merge 1 commit into
swaywm:masterfrom
beeblebrox:fix/clamp-scene-rect-negative-dimensions-v2
Open

Fix negative dimensions in scene rect sizing#9080
beeblebrox wants to merge 1 commit into
swaywm:masterfrom
beeblebrox:fix/clamp-scene-rect-negative-dimensions-v2

Conversation

@beeblebrox
Copy link
Copy Markdown

Summary

  • Fix crash when dragging a tiled window across multiple outputs without dropping on intermediate output
  • wlr_scene_rect_set_size assertion width >= 0 && height >= 0 fails at types/scene/wlr_scene.c:739
  • Same class of bug as Crash with titlebar_padding 1 10000 #8120 (fixed by 62fd8c4 for height, but width was missed)

Root Cause

During cross-output tiling drags, box dimensions can go negative via:

  1. resize_box() subtracting thickness * 2 from width/height (WLR_EDGE_NONE case)
  2. Threshold calculations producing negative values during cross-output coordinate transforms
  3. Border width passed unclamped to wlr_scene_rect_set_size in arrange_container()

Changes

  • sway/input/seatop_move_tiling.c: Clamp dimensions in resize_box() and update_indicator()
  • sway/desktop/transaction.c: Clamp border width in arrange_container() (matches existing height clamp from 62fd8c4)
  • sway/tree/container.c: Clamp pixman region box dimensions in update_rect_list()

Environment

  • Sway 1.11, wlroots 0.19.2, Mesa 26.0.2, Linux 6.19.7
  • 3 monitors in non-trivial layout (mix of side-by-side and stacked)
  • Reproducible: drag tiled window across outputs without releasing, particularly with a gamescope application on the intermediate monitor

Stack Trace

wlr_scene.c:739: wlr_scene_rect_set_size: Assertion `width >= 0 && height >= 0' failed.
#4  wlr_scene_rect_set_size (libwlroots-0.19.so + 0x3e0de)
#5  sway+0x3b6e4
#6  wl_signal_emit_mutable (libwayland-server.so.0) x2
#7  libwlroots-0.19.so + 0x764b9
#8  wl_event_loop_dispatch → wl_display_run

Test Plan

  • Drag tiled window across 3 outputs without dropping on intermediate
  • Verify crash no longer occurs
  • Drag windows between all monitor pairs
  • Create many small tiled containers and drag across outputs
  • Resize windows to minimum near output boundaries

@beeblebrox beeblebrox force-pushed the fix/clamp-scene-rect-negative-dimensions-v2 branch from 53a2ee3 to a948ab3 Compare March 19, 2026 04:10
During cross-output tiling drags, computed box dimensions can become
negative due to coordinate transforms and thickness subtractions. This
triggers the assertion in wlr_scene_rect_set_size() which requires
width >= 0 && height >= 0, crashing the compositor.

Clamp dimensions to zero in three locations:
- resize_box() in seatop_move_tiling.c for the WLR_EDGE_NONE case
- update_indicator() in seatop_move_tiling.c as a safety net
- arrange_container() in transaction.c for border width (matching the
  existing vert_border_height clamping from 62fd8c4)
- update_rect_list() in container.c for pixman region boxes

This is the same class of bug fixed by 62fd8c4 (height clamping) and
partially addressed by c2d6aff (too-many-containers guards).
@beeblebrox beeblebrox force-pushed the fix/clamp-scene-rect-negative-dimensions-v2 branch from a948ab3 to da901a2 Compare March 19, 2026 04:13
@beeblebrox beeblebrox marked this pull request as ready for review March 19, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant