From 3e7e3e057c2350443be1c0a0296243cb81065c60 Mon Sep 17 00:00:00 2001 From: Malcolm Still Date: Mon, 4 Mar 2024 18:45:31 +0000 Subject: [PATCH] WIP --- build.zig | 2 +- src/client.zig | 3 ++- src/resource/rectangle.zig | 2 +- src/resource/region.zig | 12 +++++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index 015d680..458d037 100644 --- a/build.zig +++ b/build.zig @@ -22,7 +22,7 @@ pub fn build(b: *std.Build) void { exe.linkSystemLibrary("c"); exe.linkSystemLibrary("gl"); exe.linkSystemLibrary("xkbcommon"); - exe.linkSystemLibrary("xkbcommon-x11"); + // exe.linkSystemLibrary("xkbcommon-x11"); exe.linkSystemLibrary("libsystemd"); exe.linkSystemLibrary("libudev"); exe.linkSystemLibrary("libinput"); diff --git a/src/client.zig b/src/client.zig index e902df7..bdb75b6 100644 --- a/src/client.zig +++ b/src/client.zig @@ -1096,7 +1096,8 @@ pub const Client = struct { client.unregister(.{ .xdg_popup = msg.xdg_popup }); }, .grab => |_| { - unreachable; + // unreachable; + log.warn(".grab not implemented", .{}); }, .reposition => |_| unreachable, } diff --git a/src/resource/rectangle.zig b/src/resource/rectangle.zig index bc7ff56..e3b3f73 100644 --- a/src/resource/rectangle.zig +++ b/src/resource/rectangle.zig @@ -5,7 +5,7 @@ pub const Rectangle = struct { height: i32, pub fn init(x: i32, y: i32, width: i32, height: i32) Rectangle { - return Rectangle{ + return .{ .x = x, .y = y, .width = width, diff --git a/src/resource/region.zig b/src/resource/region.zig index 54bdeef..7975369 100644 --- a/src/resource/region.zig +++ b/src/resource/region.zig @@ -11,20 +11,22 @@ const wl = @import("../client.zig").wl; pub const Region = struct { client: *Client, wl_region: wl.WlRegion, - rectangles: RectangleBuffer = RectangleBuffer.init(), - window: ?*Window = null, + rectangles: RectangleBuffer, + window: ?*Window, const Self = @This(); pub fn init(client: *Client, wl_region: wl.WlRegion) Region { - return Region{ + return .{ .client = client, .wl_region = wl_region, + .rectangles = RectangleBuffer.init(), + .window = null, }; } - pub fn pointInside(self: *Self, local_x: f64, local_y: f64) bool { - const slice = self.rectangles.readableSlice(0); + pub fn pointInside(region: *Region, local_x: f64, local_y: f64) bool { + const slice = region.rectangles.readableSlice(0); for (slice) |rect| { const left: f64 = @floatFromInt(rect.rectangle.x); const right = left + @as(f64, @floatFromInt(rect.rectangle.width));