diff --git a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs index f865798f..ad8e40e8 100644 --- a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs +++ b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs @@ -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);