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.
This commit is contained in:
Isaac Freund 2024-06-25 12:24:25 +02:00
parent 2e09b66963
commit ae7f4b8fcb
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -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);