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,
|
_ => 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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue