From a6e9cd2aef129e71479800a8dfaec05b3d38d20e Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 3 Jul 2025 00:07:42 +0200 Subject: feat: Adjust to screen size --- src/main/java/moe/nea/mossbar/concepts/Bar.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/java/moe/nea/mossbar/concepts/Bar.java') diff --git a/src/main/java/moe/nea/mossbar/concepts/Bar.java b/src/main/java/moe/nea/mossbar/concepts/Bar.java index 891b28a..7ce6591 100644 --- a/src/main/java/moe/nea/mossbar/concepts/Bar.java +++ b/src/main/java/moe/nea/mossbar/concepts/Bar.java @@ -17,8 +17,7 @@ public class Bar extends Scope { private final ShmBufferPool bufferPool; private WlCallbackProxy callbackProxy; - - public Bar(Display display, WlOutputProxy output) { + public Bar(Display display, Output output) { this.display = display; this.surface = display.compositorProxy.createSurface(new WlSurfaceEventsV6() { @Override @@ -53,12 +52,15 @@ public class Bar extends Scope { public void closed(ZwlrLayerSurfaceV1Proxy emitter) { System.out.println("layer closed"); } - }, this.surface, output, ZwlrLayerShellV1Layer.OVERLAY.getValue(), "mossbar") + }, this.surface, output.proxy, ZwlrLayerShellV1Layer.OVERLAY.getValue(), "mossbar") .bindTo(this); - int width = 1920; + if (output.width <= 0) + throw new IllegalStateException("Monitor with 0 sized output"); + int width = output.width; int height = 30; layer.setSize(width, height); // TODO??? this should really not be a hardcoded width layer.setAnchor(EnumUtil.encode(EnumSet.of(ZwlrLayerSurfaceV1Anchor.TOP, ZwlrLayerSurfaceV1Anchor.RIGHT, ZwlrLayerSurfaceV1Anchor.LEFT))); + layer.setExclusiveZone(height); surface.commit(); try { bufferPool = ShmBufferPool.newARGBPool(display, width, height, 2); @@ -69,7 +71,6 @@ public class Bar extends Scope { } public void renderOnce() { - System.out.println("Rendering"); var nextBuffer = bufferPool.poll(); assert nextBuffer != null; var pixels = nextBuffer.getByteBuffer().asIntBuffer(); @@ -78,7 +79,6 @@ public class Bar extends Scope { surface.damage(0, 0, nextBuffer.width, nextBuffer.height); queueNextFrame(); surface.commit(); - System.out.println("surface committed"); } private void queueNextFrame() { -- cgit