mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
started letting/denying passthrough of mouse events
This commit is contained in:
parent
973ea9d509
commit
42204bc4d2
3 changed files with 16 additions and 17 deletions
|
|
@ -280,23 +280,20 @@ local master = function()
|
||||||
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,
|
||||||
})
|
}, {})
|
||||||
|
|
||||||
mez.input.add_mousemap("alt", "BTN_RIGHT", {
|
mez.input.add_mousemap("alt", "BTN_RIGHT", {
|
||||||
|
press = function() return false end,
|
||||||
drag = function(pos, drag)
|
drag = function(pos, drag)
|
||||||
if drag.view ~= nil then
|
if drag.view ~= nil then
|
||||||
mez.view.set_size(
|
mez.view.set_size(
|
||||||
drag.view.id,
|
drag.view.id,
|
||||||
(pos.x - drag.start.x) + drag.view.offset.x,
|
(pos.x - drag.start.x) + drag.view.offset.x + (drag.view.dims.width - drag.view.offset.x),
|
||||||
(pos.y - drag.start.y) + drag.view.offset.y
|
(pos.y - drag.start.y) + drag.view.offset.y + (drag.view.dims.height - drag.view.offset.y)
|
||||||
)
|
)
|
||||||
-- mez.view.set_size(
|
|
||||||
-- drag.view.id,
|
|
||||||
-- (pos.x - drag.start.x) + drag.view.offset.x + (drag.view.dims.width - drag.view.offset.x),
|
|
||||||
-- (pos.y - drag.start.y) + drag.view.offset.y + (drag.view.dims.height - drag.view.offset.y)
|
|
||||||
-- )
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
release = function() return false end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,8 @@ pub fn processCursorMotion(self: *Cursor, time_msec: u32) void {
|
||||||
// Proceed if mousemap for current mouse and modifier state's exist
|
// Proceed if mousemap for current mouse and modifier state's exist
|
||||||
if (server.mousemaps.get(Mousemap.hash(modifiers, @bitCast(self.drag.?.event_code)))) |map| {
|
if (server.mousemaps.get(Mousemap.hash(modifiers, @bitCast(self.drag.?.event_code)))) |map| {
|
||||||
if(map.options.lua_drag_ref_idx > 0) {
|
if(map.options.lua_drag_ref_idx > 0) {
|
||||||
handled = true;
|
std.debug.print("check\n", .{});
|
||||||
map.callback(.drag, .{
|
handled = map.callback(.drag, .{
|
||||||
.{
|
.{
|
||||||
.x = @as(c_int, @intFromFloat(self.wlr_cursor.x)),
|
.x = @as(c_int, @intFromFloat(self.wlr_cursor.x)),
|
||||||
.y = @as(c_int, @intFromFloat(self.wlr_cursor.y))
|
.y = @as(c_int, @intFromFloat(self.wlr_cursor.y))
|
||||||
|
|
@ -210,24 +210,22 @@ fn handleButton(
|
||||||
.pressed => {
|
.pressed => {
|
||||||
// Only make callback if a callback function exists
|
// Only make callback if a callback function exists
|
||||||
if(map.options.lua_press_ref_idx > 0) {
|
if(map.options.lua_press_ref_idx > 0) {
|
||||||
map.callback(.press, .{
|
handled = map.callback(.press, .{
|
||||||
.{
|
.{
|
||||||
.x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)),
|
.x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)),
|
||||||
.y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y))
|
.y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y))
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
handled = true;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.released => {
|
.released => {
|
||||||
if(map.options.lua_press_ref_idx > 0) {
|
if(map.options.lua_press_ref_idx > 0) {
|
||||||
map.callback(.release, .{
|
handled = map.callback(.release, .{
|
||||||
.{
|
.{
|
||||||
.x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)),
|
.x = @as(c_int, @intFromFloat(cursor.wlr_cursor.x)),
|
||||||
.y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y))
|
.y = @as(c_int, @intFromFloat(cursor.wlr_cursor.y))
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
handled = true;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
else => { unreachable; }
|
else => { unreachable; }
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ options: struct {
|
||||||
|
|
||||||
pub const MousemapState = enum { press, drag, release };
|
pub const MousemapState = enum { press, drag, release };
|
||||||
|
|
||||||
pub fn callback(self: *const Mousemap, state: MousemapState, args: anytype) void {
|
// Returns true if mouse input should be passed through
|
||||||
|
pub fn callback(self: *const Mousemap, state: MousemapState, args: anytype) bool {
|
||||||
const ArgsType = @TypeOf(args);
|
const ArgsType = @TypeOf(args);
|
||||||
const args_type_info = @typeInfo(ArgsType);
|
const args_type_info = @typeInfo(ArgsType);
|
||||||
if (args_type_info != .@"struct") {
|
if (args_type_info != .@"struct") {
|
||||||
|
|
@ -41,7 +42,7 @@ pub fn callback(self: *const Mousemap, state: MousemapState, args: anytype) void
|
||||||
if (t != zlua.LuaType.function) {
|
if (t != zlua.LuaType.function) {
|
||||||
RemoteLua.sendNewLogEntry("Failed to call keybind, it doesn't have a callback.");
|
RemoteLua.sendNewLogEntry("Failed to call keybind, it doesn't have a callback.");
|
||||||
Lua.state.pop(1);
|
Lua.state.pop(1);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allow passing any arguments to the lua hook
|
// allow passing any arguments to the lua hook
|
||||||
|
|
@ -51,10 +52,13 @@ pub fn callback(self: *const Mousemap, state: MousemapState, args: anytype) void
|
||||||
i = k;
|
i = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lua.state.protectedCall(.{ .args = i, .results = 0 }) catch {
|
Lua.state.protectedCall(.{ .args = i, .results = 1 }) catch {
|
||||||
RemoteLua.sendNewLogEntry(Lua.state.toString(-1) catch unreachable);
|
RemoteLua.sendNewLogEntry(Lua.state.toString(-1) catch unreachable);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ret = if (Lua.state.isBoolean(-1)) Lua.state.toBoolean(-1) else false;
|
||||||
Lua.state.pop(-1);
|
Lua.state.pop(-1);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hash(modifier: wlr.Keyboard.ModifierMask, event_code: i32) u64 {
|
pub fn hash(modifier: wlr.Keyboard.ModifierMask, event_code: i32) u64 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue