mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
set x cursor type in lua
This commit is contained in:
parent
42204bc4d2
commit
22e3553580
3 changed files with 23 additions and 3 deletions
|
|
@ -275,17 +275,26 @@ local master = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
mez.input.add_mousemap("alt", "BTN_LEFT", {
|
mez.input.add_mousemap("alt", "BTN_LEFT", {
|
||||||
|
press = function()
|
||||||
|
mez.input.set_cursor_type("pointer")
|
||||||
|
end,
|
||||||
drag = function(pos, drag)
|
drag = function(pos, drag)
|
||||||
if drag.view ~= nil then
|
if drag.view ~= nil then
|
||||||
mez.view.set_position(drag.view.id, pos.x - drag.view.offset.x, pos.y - drag.view.offset.y)
|
mez.view.set_position(drag.view.id, pos.x - drag.view.offset.x, pos.y - drag.view.offset.y)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
release = function()
|
||||||
|
mez.input.set_cursor_type("default")
|
||||||
|
end,
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
mez.input.add_mousemap("alt", "BTN_RIGHT", {
|
mez.input.add_mousemap("alt", "BTN_RIGHT", {
|
||||||
press = function() return false end,
|
press = function()
|
||||||
|
mez.input.set_cursor_type("cross")
|
||||||
|
end,
|
||||||
drag = function(pos, drag)
|
drag = function(pos, drag)
|
||||||
if drag.view ~= nil then
|
if drag.view ~= nil then
|
||||||
|
-- mez.input.set_cursor_type("pointer")
|
||||||
mez.view.set_size(
|
mez.view.set_size(
|
||||||
drag.view.id,
|
drag.view.id,
|
||||||
(pos.x - drag.start.x) + drag.view.offset.x + (drag.view.dims.width - drag.view.offset.x),
|
(pos.x - drag.start.x) + drag.view.offset.x + (drag.view.dims.width - drag.view.offset.x),
|
||||||
|
|
@ -293,7 +302,9 @@ local master = function()
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
release = function() return false end
|
release = function()
|
||||||
|
mez.input.set_cursor_type("default")
|
||||||
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ pub fn deinit(self: *Cursor) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn processCursorMotion(self: *Cursor, time_msec: u32) void {
|
pub fn processCursorMotion(self: *Cursor, time_msec: u32) void {
|
||||||
self.wlr_cursor.setXcursor(self.x_cursor_manager, "default");
|
// TODO: allow acces via lua
|
||||||
|
|
||||||
var handled = false;
|
var handled = false;
|
||||||
|
|
||||||
|
|
@ -129,6 +129,7 @@ pub fn processCursorMotion(self: *Cursor, time_msec: u32) void {
|
||||||
} else {
|
} else {
|
||||||
// This may not be necessary, remove if no bugs
|
// This may not be necessary, remove if no bugs
|
||||||
server.seat.wlr_seat.pointerClearFocus();
|
server.seat.wlr_seat.pointerClearFocus();
|
||||||
|
self.wlr_cursor.setXcursor(self.x_cursor_manager, "default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,3 +171,11 @@ pub fn set_repeat_info(L: *zlua.Lua) i32 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ---Set the cursor type
|
||||||
|
/// ---@param string cursor name
|
||||||
|
pub fn set_cursor_type(L: *zlua.Lua) i32 {
|
||||||
|
const name = L.checkString(1);
|
||||||
|
server.cursor.wlr_cursor.setXcursor(server.cursor.x_cursor_manager, name);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue