mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
we can now pass arbitrary zig data to lua through hooks
This commit is contained in:
parent
91578d583a
commit
0bb1ba2963
3 changed files with 6 additions and 12 deletions
|
|
@ -59,8 +59,7 @@ end
|
||||||
-- })
|
-- })
|
||||||
|
|
||||||
mez.hook.add("ViewMapPre", {
|
mez.hook.add("ViewMapPre", {
|
||||||
callback = function(a)
|
callback = function(v)
|
||||||
print(a)
|
mez.view.set_size(v, 1000, 1000)
|
||||||
print("hello world")
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -31,19 +31,14 @@ pub fn callback(self: *const Hook, args: anytype) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allow passing any arguments to the lua hook
|
||||||
var i: u8 = 0;
|
var i: u8 = 0;
|
||||||
inline for (args, 0..) |field, k| {
|
inline for (args, 1..) |field, k| {
|
||||||
// std.log.debug("{any}", .{field});
|
|
||||||
|
|
||||||
// oh dear god I hope this works
|
|
||||||
std.log.debug("sldkjf {any}", .{field});
|
|
||||||
try Lua.state.pushAny(field);
|
try Lua.state.pushAny(field);
|
||||||
i = k;
|
i = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we need to send some data along with the callback, this data will
|
Lua.state.protectedCall(.{ .args = i }) catch {
|
||||||
// change based on the event which the user is hooking into
|
|
||||||
Lua.state.protectedCall(.{ .args = i, .results = 0 }) catch {
|
|
||||||
};
|
};
|
||||||
Lua.state.pop(-1);
|
Lua.state.pop(-1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ fn handleMap(listener: *wl.Listener(void)) void {
|
||||||
|
|
||||||
view.mapped = true;
|
view.mapped = true;
|
||||||
|
|
||||||
server.events.exec("ViewMapPost", .{});
|
server.events.exec("ViewMapPost", .{view.id});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleUnmap(listener: *wl.Listener(void)) void {
|
fn handleUnmap(listener: *wl.Listener(void)) void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue