mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
got all window dragging, passthrough for mousemaps is still improper
This commit is contained in:
parent
1f45f27f74
commit
b37519369d
6 changed files with 84 additions and 39 deletions
|
|
@ -279,6 +279,7 @@ local master = function()
|
||||||
mez.input.set_cursor_type("pointer")
|
mez.input.set_cursor_type("pointer")
|
||||||
end,
|
end,
|
||||||
drag = function(pos, drag)
|
drag = function(pos, drag)
|
||||||
|
print("running this too!")
|
||||||
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
|
||||||
|
|
@ -288,6 +289,28 @@ local master = function()
|
||||||
end,
|
end,
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
|
-- This is so impractical
|
||||||
|
-- I love it
|
||||||
|
mez.input.add_mousemap("alt|shift", "BTN_LEFT", {
|
||||||
|
press = function()
|
||||||
|
mez.input.set_cursor_type("cross")
|
||||||
|
move_all_drag = {}
|
||||||
|
for _, id in ipairs(mez.view.get_all_ids()) do
|
||||||
|
move_all_drag[id] = mez.view.get_position(id)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
drag = function(pos, drag)
|
||||||
|
print("Dragging")
|
||||||
|
for id, view_start in pairs(move_all_drag) do
|
||||||
|
mez.view.set_position(id, view_start.x + pos.x - drag.start.x, view_start.y + pos.y - drag.start.y)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
release = function()
|
||||||
|
move_all_drag = nil
|
||||||
|
mez.input.set_cursor_type("default")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
mez.input.add_mousemap("alt", "BTN_RIGHT", {
|
mez.input.add_mousemap("alt", "BTN_RIGHT", {
|
||||||
press = function()
|
press = function()
|
||||||
mez.input.set_cursor_type("cross")
|
mez.input.set_cursor_type("cross")
|
||||||
|
|
@ -306,6 +329,7 @@ local master = function()
|
||||||
mez.input.set_cursor_type("default")
|
mez.input.set_cursor_type("default")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
master()
|
master()
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ 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) {
|
||||||
std.debug.print("check\n", .{});
|
|
||||||
handled = 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)),
|
||||||
|
|
|
||||||
|
|
@ -28,24 +28,18 @@ pub fn init(wlr_layer_surface: *wlr.LayerSurfaceV1) *LayerSurface {
|
||||||
const self = try gpa.create(LayerSurface);
|
const self = try gpa.create(LayerSurface);
|
||||||
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.output = blk: {
|
.output = undefined,
|
||||||
// These block things are dangerous
|
|
||||||
// There was no need for this
|
|
||||||
// But I cannot be stopped
|
|
||||||
// - Powerhungry programmer
|
|
||||||
const data = wlr_layer_surface.output.?.data;
|
|
||||||
if(data == null) unreachable;
|
|
||||||
const scene_node_data: *SceneNodeData = @ptrCast(@alignCast(wlr_layer_surface.output.?.data.?));
|
|
||||||
break :blk switch(scene_node_data.*) {
|
|
||||||
.output => @fieldParentPtr("scene_node_data", scene_node_data),
|
|
||||||
else => unreachable
|
|
||||||
};
|
|
||||||
},
|
|
||||||
.wlr_layer_surface = wlr_layer_surface,
|
.wlr_layer_surface = wlr_layer_surface,
|
||||||
.scene_layer_surface = undefined,
|
.scene_layer_surface = undefined,
|
||||||
.scene_node_data = .{ .layer_surface = self }
|
.scene_node_data = .{ .layer_surface = self }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(wlr_layer_surface.output.?.data == null) {
|
||||||
|
std.log.err("Wlr_output arbitrary data not assigned", .{});
|
||||||
|
unreachable;
|
||||||
|
}
|
||||||
|
self.output = @ptrCast(@alignCast(wlr_layer_surface.output.?.data));
|
||||||
|
|
||||||
if(server.seat.focused_output) |output| {
|
if(server.seat.focused_output) |output| {
|
||||||
self.scene_layer_surface = switch (wlr_layer_surface.current.layer) {
|
self.scene_layer_surface = switch (wlr_layer_surface.current.layer) {
|
||||||
.background => try output.layers.background.createSceneLayerSurfaceV1(wlr_layer_surface),
|
.background => try output.layers.background.createSceneLayerSurfaceV1(wlr_layer_surface),
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,8 @@ destroy: wl.Listener(*wlr.Output) = .init(handleDestroy),
|
||||||
pub fn init(wlr_output: *wlr.Output) ?*Output {
|
pub fn init(wlr_output: *wlr.Output) ?*Output {
|
||||||
errdefer Utils.oomPanic();
|
errdefer Utils.oomPanic();
|
||||||
|
|
||||||
server.events.exec("OutputInitPre", .{});
|
|
||||||
|
|
||||||
const self = try gpa.create(Output);
|
const self = try gpa.create(Output);
|
||||||
|
|
||||||
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.focused = false,
|
.focused = false,
|
||||||
.id = @intFromPtr(wlr_output),
|
.id = @intFromPtr(wlr_output),
|
||||||
|
|
@ -108,11 +105,12 @@ pub fn init(wlr_output: *wlr.Output) ?*Output {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Allow user to define output positions
|
||||||
const layout_output = try server.root.output_layout.addAuto(self.wlr_output);
|
const layout_output = try server.root.output_layout.addAuto(self.wlr_output);
|
||||||
server.root.scene_output_layout.addOutput(layout_output, self.scene_output);
|
server.root.scene_output_layout.addOutput(layout_output, self.scene_output);
|
||||||
self.setFocused();
|
self.setFocused();
|
||||||
|
|
||||||
self.wlr_output.data = &self.scene_node_data;
|
self.wlr_output.data = self;
|
||||||
self.tree.node.data = &self.scene_node_data;
|
self.tree.node.data = &self.scene_node_data;
|
||||||
|
|
||||||
self.layers.background.node.data = &self.layer_scene_node_data.background;
|
self.layers.background.node.data = &self.layer_scene_node_data.background;
|
||||||
|
|
|
||||||
11
src/Root.zig
11
src/Root.zig
|
|
@ -74,17 +74,12 @@ pub fn viewById(self: *Root, id: u64) ?*View {
|
||||||
var output_it = self.output_layout.outputs.iterator(.forward);
|
var output_it = self.output_layout.outputs.iterator(.forward);
|
||||||
|
|
||||||
while(output_it.next()) |o| {
|
while(output_it.next()) |o| {
|
||||||
if(o.output.data == null) continue;
|
if(o.output.data == null) {
|
||||||
|
std.log.err("Wlr_output arbitrary data not assigned", .{});
|
||||||
const output_snd: *SceneNodeData = @ptrCast(@alignCast(o.output.data.?));
|
|
||||||
const output: *Output = switch (output_snd.*) {
|
|
||||||
.output => |output_ptr| output_ptr,
|
|
||||||
else => {
|
|
||||||
std.log.err("Incorrect scene node type found", .{});
|
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
const output: *Output = @ptrCast(@alignCast(o.output.data.?));
|
||||||
var node_it = output.layers.content.children.iterator(.forward);
|
var node_it = output.layers.content.children.iterator(.forward);
|
||||||
|
|
||||||
while(node_it.next()) |node| {
|
while(node_it.next()) |node| {
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,19 @@ fn view_id_err(L: *zlua.Lua) noreturn {
|
||||||
// ---@return view_id[]?
|
// ---@return view_id[]?
|
||||||
pub fn get_all_ids(L: *zlua.Lua) i32 {
|
pub fn get_all_ids(L: *zlua.Lua) i32 {
|
||||||
var output_it = server.root.output_layout.outputs.iterator(.forward);
|
var output_it = server.root.output_layout.outputs.iterator(.forward);
|
||||||
var index: i32 = 1;
|
|
||||||
|
|
||||||
|
var index: i32 = 1;
|
||||||
L.newTable();
|
L.newTable();
|
||||||
|
|
||||||
while(output_it.next()) |o| {
|
while(output_it.next()) |o| {
|
||||||
if(o.output.data == null) continue;
|
if(o.output.data == null) {
|
||||||
const output: *Output = @ptrCast(@alignCast(o.output.data.?));
|
std.log.err("Output arbitrary data not assigned", .{});
|
||||||
if (!output.state.enabled) {
|
unreachable;
|
||||||
std.log.debug("ts not enabled", .{});
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const output: *Output = @ptrCast(@alignCast(o.output.data.?));
|
||||||
|
if (!output.state.enabled) continue;
|
||||||
|
|
||||||
const layers = [_]*wlr.SceneTree{
|
const layers = [_]*wlr.SceneTree{
|
||||||
output.layers.content,
|
output.layers.content,
|
||||||
output.layers.fullscreen,
|
output.layers.fullscreen,
|
||||||
|
|
@ -123,11 +124,11 @@ pub fn get_position(L: *zlua.Lua) i32 {
|
||||||
L.newTable();
|
L.newTable();
|
||||||
|
|
||||||
_ = L.pushString("x");
|
_ = L.pushString("x");
|
||||||
L.pushInteger(@intCast(v.xdg_toplevel.base.geometry.x));
|
L.pushInteger(@intCast(v.scene_tree.node.x));
|
||||||
L.setTable(-3);
|
L.setTable(-3);
|
||||||
|
|
||||||
_ = L.pushString("y");
|
_ = L.pushString("y");
|
||||||
L.pushInteger(@intCast(v.xdg_toplevel.base.geometry.y));
|
L.pushInteger(@intCast(v.scene_tree.node.y));
|
||||||
L.setTable(-3);
|
L.setTable(-3);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -251,9 +252,9 @@ pub fn get_app_id(L: *zlua.Lua) i32 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---Get the app_id of the view
|
// ---Enable or disable a view
|
||||||
// ---@param view_id view_id 0 maps to focused view
|
// ---@param view_id view_id 0 maps to focused view
|
||||||
// ---@param enable boolean
|
// ---@param enabled boolean
|
||||||
pub fn set_enabled(L: *zlua.Lua) i32 {
|
pub fn set_enabled(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);
|
||||||
if (!L.isBoolean(2)) {
|
if (!L.isBoolean(2)) {
|
||||||
|
|
@ -270,7 +271,7 @@ pub fn set_enabled(L: *zlua.Lua) i32 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---Get the app_id of the view
|
// ---Check if a view is enabled
|
||||||
// ---@param view_id view_id 0 maps to focused view
|
// ---@param view_id view_id 0 maps to focused view
|
||||||
// ---@return boolean?
|
// ---@return boolean?
|
||||||
pub fn get_enabled(L: *zlua.Lua) i32 {
|
pub fn get_enabled(L: *zlua.Lua) i32 {
|
||||||
|
|
@ -285,6 +286,40 @@ pub fn get_enabled(L: *zlua.Lua) i32 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---Set a view you intend to resize
|
||||||
|
// ---@param view_id view_id 0 maps to focused view
|
||||||
|
// ---@param enable boolean
|
||||||
|
pub fn set_resizing(L: *zlua.Lua) i32 {
|
||||||
|
const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L);
|
||||||
|
if (!L.isBoolean(2)) {
|
||||||
|
L.raiseErrorStr("argument 2 must be a boolean", .{});
|
||||||
|
}
|
||||||
|
const resizing = L.toBoolean(2);
|
||||||
|
|
||||||
|
if (LuaUtils.viewById(view_id)) |v| {
|
||||||
|
_ = v.xdg_toplevel.setResizing(resizing);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
L.pushNil();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---Check if a view is resizing
|
||||||
|
// ---@param view_id view_id 0 maps to focused view
|
||||||
|
// ---@return boolean? nil if view cannot be found
|
||||||
|
pub fn get_resizing(L: *zlua.Lua) i32 {
|
||||||
|
const view_id = LuaUtils.coerceInteger(u64, L.checkInteger(1)) catch view_id_err(L);
|
||||||
|
|
||||||
|
if(LuaUtils.viewById(view_id)) |v| {
|
||||||
|
_ = L.pushBoolean(v.xdg_toplevel.current.resizing);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
L.pushNil();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/// TODO: impl
|
/// TODO: impl
|
||||||
/// Setting the wm capabilities is for telling the client what they can request.
|
/// Setting the wm capabilities is for telling the client what they can request.
|
||||||
/// This is important to letting the user define whatever type of layout they
|
/// This is important to letting the user define whatever type of layout they
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue