Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
Xwayland: fix unsound cast
The X11 protocol uses 16 bit integers for width/height but we use
32 bit integers everywhere else in river. Make sure that values outside
the range of a 16 bit integer don't cause river to crash with an
assertion failure.
I think that coordinates outside the range of a 16 bit integer could
theoretically be reasonable with tiled high resolution displays in the
future. I doubt they ever get used in practice today but at the same
time we can't allow an errant layout generator to crash river.
river/XwaylandView.zig | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/river/XwaylandView.zig b/river/XwaylandView.zig
index 80cecc6..db91199 100644
--- a/river/XwaylandView.zig
+++ b/river/XwaylandView.zig
@@ -106,10 +106,10 @@ pub fn configure(xwayland_view: XwaylandView) bool {
}
xwayland_view.xwayland_surface.configure(
- @intCast(inflight.box.x + output_box.x),
- @intCast(inflight.box.y + output_box.y),
- @intCast(inflight.box.width),
- @intCast(inflight.box.height),
+ math.lossyCast(i16, inflight.box.x + output_box.x),
+ math.lossyCast(i16, inflight.box.y + output_box.y),
+ math.lossyCast(u16, inflight.box.width),
+ math.lossyCast(u16, inflight.box.height),
);
xwayland_view.setActivated(inflight.focus != 0);