This commit is contained in:
Bloxx12 2025-05-19 21:21:16 +02:00
commit 3aeb006440
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E

View file

@ -3,7 +3,6 @@ const mem = std.mem;
const posix = std.posix;
const wayland = @import("wayland");
const wl = wayland.client.wl;
const zwlr = wayland.client.zwlr;
const layer_shell = zwlr.common.zwlr.layer_shell_v1;
@ -20,6 +19,7 @@ const Context = struct {
compositor: *wl.Compositor = undefined,
blk: []u32 = undefined,
// width and height of our context
width: i32 = 0,
height: i32 = 0,
};
@ -46,34 +46,51 @@ pub fn main() !void {
context.layer_surface = try context.shell.getLayerSurface(context.surface, null, .top, "zayneko");
defer context.layer_surface.destroy();
context.layer_surface.setExclusiveZone(20);
context.layer_surface.setExclusiveZone(0);
context.layer_surface.setAnchor(.{
.top = true,
.bottom = false,
.top = false,
.bottom = true,
.left = true,
.right = true,
});
context.layer_surface.setSize(0, 20);
context.layer_surface.setSize(0, 30);
context.layer_surface.setListener(*Context, layerSurfaceListener, &context);
context.surface.commit();
if (display.roundtrip() != .SUCCESS) return error.RoundtripFailed;
std.debug.print("{}\n", .{context.blk.len});
for (context.blk) |*a|
// a.* = if (i < 2000) 0 else 0xFFFFFFFF;
a.* = 0xFFFFFFFF;
std.debug.print("Width: {}\n", .{context.width});
std.debug.print("Height: {}\n", .{context.height});
context.surface.attach(context.buffer, 0, 0);
context.surface.damageBuffer(0, 0, context.width, context.height);
context.surface.commit();
if (display.roundtrip() != .SUCCESS) return error.RoundtripFailed;
_ = display.flush();
if (display.dispatchPending() != .SUCCESS) return error.DispatchFailed;
while (true) {
const segment: usize =
@intCast(@divFloor(context.width, 10));
for (0..segment) |i| {
std.debug.print("{}\n", .{i});
const casted: i32 = @intCast(i);
std.time.sleep(4000000000);
move_buffer(casted, &context);
_ = display.flush();
if (display.dispatchPending() != .SUCCESS) return error.DispatchFailed;
std.time.sleep(500000);
}
for (0..segment) |i| {
// const casted: i32 = @intCast(i);
std.debug.print("smaller {}\n", .{(segment - i)});
move_buffer(@intCast(segment - i), &context);
_ = display.flush();
if (display.dispatchPending() != .SUCCESS) return error.DispatchFailed;
std.time.sleep(500000);
}
}
// std.time.sleep(4000000000);
}
fn registryListener(
@ -94,6 +111,20 @@ fn registryListener(
.global_remove => {},
}
}
fn move_buffer(offset: i32, context: *Context) void {
@memset(context.blk, 0);
for (context.blk, 0..context.blk.len) |*a, i| {
const context_width: usize = @intCast(context.width);
if (i % context_width > offset * 10 and i % context_width < offset * 10 + @divFloor(context.width, 10))
a.* = 0xFFFFFFFF;
}
context.surface.attach(context.buffer, 0, 0);
context.surface.damageBuffer(offset * 10 - 10, 0, @divFloor(context.width, 10) * 2, context.height);
context.surface.commit();
}
fn layerSurfaceListener(
surface: *zwlr.LayerSurfaceV1,
event: zwlr.LayerSurfaceV1.Event,