moving
This commit is contained in:
parent
00e9e6f967
commit
3aeb006440
1 changed files with 44 additions and 13 deletions
53
src/main.zig
53
src/main.zig
|
@ -3,7 +3,6 @@ const mem = std.mem;
|
||||||
const posix = std.posix;
|
const posix = std.posix;
|
||||||
|
|
||||||
const wayland = @import("wayland");
|
const wayland = @import("wayland");
|
||||||
|
|
||||||
const wl = wayland.client.wl;
|
const wl = wayland.client.wl;
|
||||||
const zwlr = wayland.client.zwlr;
|
const zwlr = wayland.client.zwlr;
|
||||||
const layer_shell = zwlr.common.zwlr.layer_shell_v1;
|
const layer_shell = zwlr.common.zwlr.layer_shell_v1;
|
||||||
|
@ -20,6 +19,7 @@ const Context = struct {
|
||||||
compositor: *wl.Compositor = undefined,
|
compositor: *wl.Compositor = undefined,
|
||||||
blk: []u32 = undefined,
|
blk: []u32 = undefined,
|
||||||
|
|
||||||
|
// width and height of our context
|
||||||
width: i32 = 0,
|
width: i32 = 0,
|
||||||
height: 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");
|
context.layer_surface = try context.shell.getLayerSurface(context.surface, null, .top, "zayneko");
|
||||||
defer context.layer_surface.destroy();
|
defer context.layer_surface.destroy();
|
||||||
|
|
||||||
context.layer_surface.setExclusiveZone(20);
|
context.layer_surface.setExclusiveZone(0);
|
||||||
context.layer_surface.setAnchor(.{
|
context.layer_surface.setAnchor(.{
|
||||||
.top = true,
|
.top = false,
|
||||||
.bottom = false,
|
.bottom = true,
|
||||||
.left = true,
|
.left = true,
|
||||||
.right = true,
|
.right = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
context.layer_surface.setSize(0, 20);
|
context.layer_surface.setSize(0, 30);
|
||||||
context.layer_surface.setListener(*Context, layerSurfaceListener, &context);
|
context.layer_surface.setListener(*Context, layerSurfaceListener, &context);
|
||||||
|
|
||||||
context.surface.commit();
|
context.surface.commit();
|
||||||
if (display.roundtrip() != .SUCCESS) return error.RoundtripFailed;
|
if (display.roundtrip() != .SUCCESS) return error.RoundtripFailed;
|
||||||
|
|
||||||
std.debug.print("{}\n", .{context.blk.len});
|
std.debug.print("{}\n", .{context.blk.len});
|
||||||
for (context.blk) |*a|
|
std.debug.print("Width: {}\n", .{context.width});
|
||||||
// a.* = if (i < 2000) 0 else 0xFFFFFFFF;
|
std.debug.print("Height: {}\n", .{context.height});
|
||||||
a.* = 0xFFFFFFFF;
|
|
||||||
|
|
||||||
context.surface.attach(context.buffer, 0, 0);
|
context.surface.attach(context.buffer, 0, 0);
|
||||||
context.surface.damageBuffer(0, 0, context.width, context.height);
|
|
||||||
|
|
||||||
context.surface.commit();
|
context.surface.commit();
|
||||||
|
if (display.roundtrip() != .SUCCESS) return error.RoundtripFailed;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const segment: usize =
|
||||||
|
@intCast(@divFloor(context.width, 10));
|
||||||
|
for (0..segment) |i| {
|
||||||
|
std.debug.print("{}\n", .{i});
|
||||||
|
const casted: i32 = @intCast(i);
|
||||||
|
|
||||||
|
move_buffer(casted, &context);
|
||||||
_ = display.flush();
|
_ = display.flush();
|
||||||
if (display.dispatchPending() != .SUCCESS) return error.DispatchFailed;
|
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);
|
// std.time.sleep(4000000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn registryListener(
|
fn registryListener(
|
||||||
|
@ -94,6 +111,20 @@ fn registryListener(
|
||||||
.global_remove => {},
|
.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(
|
fn layerSurfaceListener(
|
||||||
surface: *zwlr.LayerSurfaceV1,
|
surface: *zwlr.LayerSurfaceV1,
|
||||||
event: zwlr.LayerSurfaceV1.Event,
|
event: zwlr.LayerSurfaceV1.Event,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue