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:
parent
ba047d3a94
commit
e80a328381
1 changed files with 14 additions and 12 deletions
|
|
@ -498,22 +498,24 @@ impl ZwlrLayerSurfaceV1 {
|
|||
_ => opos,
|
||||
};
|
||||
let (owidth, oheight) = rect.size();
|
||||
let mut x1 = 0;
|
||||
let mut y1 = 0;
|
||||
if anchor.contains(LEFT | RIGHT) {
|
||||
x1 = ml + (owidth - width - ml - mr) / 2;
|
||||
let x1 = if anchor.contains(LEFT | RIGHT) {
|
||||
ml + (owidth - width - ml - mr) / 2
|
||||
} else if anchor.contains(LEFT) {
|
||||
x1 = ml;
|
||||
ml
|
||||
} else if anchor.contains(RIGHT) {
|
||||
x1 = owidth - width - mr;
|
||||
}
|
||||
if anchor.contains(TOP | BOTTOM) {
|
||||
y1 = mt + (oheight - height - mt - mb) / 2;
|
||||
owidth - width - mr
|
||||
} else {
|
||||
(owidth - width) / 2
|
||||
};
|
||||
let y1 = if anchor.contains(TOP | BOTTOM) {
|
||||
mt + (oheight - height - mt - mb) / 2
|
||||
} else if anchor.contains(TOP) {
|
||||
y1 = mt;
|
||||
mt
|
||||
} 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 o_rect = a_rect.move_(-opos.x1(), -opos.y1());
|
||||
self.output_extents.set(o_rect);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue