ts don't work

This commit is contained in:
Harrison DiAmbrosio 2025-12-15 08:56:13 -05:00
parent 49e0875a85
commit 4b3e1bbd5d
4 changed files with 67 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

View file

@ -20,8 +20,6 @@ pub fn build(b: *std.Build) void {
// subprocessing your CLI tool. // subprocessing your CLI tool.
// The below is copied from tinywl // The below is copied from tinywl
// TODO: Ensure versioning is correct
// TODO: Ensure paths for system protocols are correct
const scanner = Scanner.create(b, .{}); const scanner = Scanner.create(b, .{});
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
scanner.addSystemProtocol("stable/tablet/tablet-v2.xml"); scanner.addSystemProtocol("stable/tablet/tablet-v2.xml");

View file

@ -6,6 +6,43 @@ mez.input.add_keymap("alt", "g", {
end end
}) })
mez.input.add_keymap("alt", "i", {
press = function ()
local coroutine = require("coroutine")
print(coroutine)
local co = coroutine.create(function ()
print("starting coroutine")
local view_id = mez.view.get_focused_id()
local size = mez.view.get_size(view_id)
local pos = mez.view.get_position(view_id)
local res = mez.output.get_resolution(0)
local x_pos = pos.x
local y_pos = pos.y
local x_vel = 10
local y_vel = 10
while true do
x_pos = x_pos + x_vel
y_pos = y_pos + y_vel
if x_pos + size.width > res.width or x_pos < 0 then
x_vel = x_vel * -1
end
if y_pos + size.height > res.height or y_pos < 0 then
y_vel = y_vel * -1
end
print("(" .. x_pos .. ", " .. y_pos .. ")")
mez.view.set_position(view_id, x_pos, y_pos)
end
end)
coroutine.resume(co)
end
})
local master = function() local master = function()
local config = { local config = {
tag_count = 5, tag_count = 5,

View file

@ -109,10 +109,34 @@ pub fn set_position(L: *zlua.Lua) i32 {
return 1; return 1;
} }
// ---Resize the view by it's top left corner // ---Get the position of the view
// ---@param view_id view_id 0 maps to focused view // ---@param view_id view_id 0 maps to focused view
// ---@param width number width for view // ---@return { x: integer, y: integer }? Position of the view
// ---@param height number height for view pub fn get_position(L: *zlua.Lua) i32 {
const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L);
const view: ?*View = if (view_id == 0) server.seat.focused_view else server.root.viewById(view_id);
if (view) |v| {
L.newTable();
_ = L.pushString("x");
L.pushInteger(@intCast(v.xdg_toplevel.base.geometry.x));
L.setTable(-3);
_ = L.pushString("y");
L.pushInteger(@intCast(v.xdg_toplevel.base.geometry.y));
L.setTable(-3);
return 1;
}
L.pushNil();
return 1;
}
// ---Set the size of the spesified view. Will be resized relative to
// the view's top left corner.
// ---@param view_id view_id 0 maps to focused view
// ---@return
pub fn set_size(L: *zlua.Lua) i32 { pub fn set_size(L: *zlua.Lua) i32 {
const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L); const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L);
// We use u32s here to enforce a minimum size of zero. The call to resize a // We use u32s here to enforce a minimum size of zero. The call to resize a
@ -131,6 +155,9 @@ pub fn set_size(L: *zlua.Lua) i32 {
return 1; return 1;
} }
// ---Get the size of the view
// ---@param view_id view_id 0 maps to focused view
// ---@return { width: integer, height: integer }? Size of the view
pub fn get_size(L: *zlua.Lua) i32 { pub fn get_size(L: *zlua.Lua) i32 {
const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L); const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L);
const view: ?*View = if (view_id == 0) server.seat.focused_view else server.root.viewById(view_id); const view: ?*View = if (view_id == 0) server.seat.focused_view else server.root.viewById(view_id);