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.

(cherry picked from commit ae7f4b8fcbb323e68b07eebf8dc8cca38b582940)
This commit is contained in:
Isaac Freund 2024-06-25 12:24:25 +02:00
parent b85da67886
commit 6564db22df
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);