1
0
Fork 0
forked from wry/wry

zwlr_layer_surface_v1: center along unanchored axis

Per the wlr-layer-shell spec, if a surface is not anchored to either
edge on an axis, it should be centered along that axis. The previous
code left x1/y1 at 0 (top-left) in those cases.
This commit is contained in:
kossLAN 2026-04-04 01:48:00 -04:00
parent ba047d3a94
commit e80a328381
No known key found for this signature in database

View file

@ -498,22 +498,24 @@ impl ZwlrLayerSurfaceV1 {
_ => opos, _ => opos,
}; };
let (owidth, oheight) = rect.size(); let (owidth, oheight) = rect.size();
let mut x1 = 0; let x1 = if anchor.contains(LEFT | RIGHT) {
let mut y1 = 0; ml + (owidth - width - ml - mr) / 2
if anchor.contains(LEFT | RIGHT) {
x1 = ml + (owidth - width - ml - mr) / 2;
} else if anchor.contains(LEFT) { } else if anchor.contains(LEFT) {
x1 = ml; ml
} else if anchor.contains(RIGHT) { } else if anchor.contains(RIGHT) {
x1 = owidth - width - mr; owidth - width - mr
} } else {
if anchor.contains(TOP | BOTTOM) { (owidth - width) / 2
y1 = mt + (oheight - height - mt - mb) / 2; };
let y1 = if anchor.contains(TOP | BOTTOM) {
mt + (oheight - height - mt - mb) / 2
} else if anchor.contains(TOP) { } else if anchor.contains(TOP) {
y1 = mt; mt
} else if anchor.contains(BOTTOM) { } else if anchor.contains(BOTTOM) {
y1 = oheight - height - mb; oheight - height - mb
} } else {
(oheight - height) / 2
};
let a_rect = Rect::new_sized_saturating(x1 + rect.x1(), y1 + rect.y1(), width, height); let a_rect = Rect::new_sized_saturating(x1 + rect.x1(), y1 + rect.y1(), width, height);
let o_rect = a_rect.move_(-opos.x1(), -opos.y1()); let o_rect = a_rect.move_(-opos.x1(), -opos.y1());
self.output_extents.set(o_rect); self.output_extents.set(o_rect);