tiling is working again, and surface at is mostly in

This commit is contained in:
Harrison DiAmbrosio 2025-12-13 23:38:29 -05:00
parent 1039e3a800
commit 49a6ced28e
7 changed files with 54 additions and 26 deletions

View file

@ -282,4 +282,3 @@ function print_table(tbl, indent, seen)
end end
end end
end end

View file

@ -1,4 +1,5 @@
local env_conf = os.getenv("XDG_CONFIG_HOME") local env_conf = os.getenv("XDG_CONFIG_HOME")
if not env_conf then if not env_conf then
env_conf = os.getenv("HOME") env_conf = os.getenv("HOME")
if not env_conf then if not env_conf then

View file

@ -32,7 +32,7 @@ mode: enum { passthrough, move, resize } = .passthrough,
drag: struct { drag: struct {
start_x: c_int, start_x: c_int,
start_y: c_int, start_y: c_int,
view: ?*View, view: ?*View,
view_offset_x: ?c_int, view_offset_x: ?c_int,
view_offset_y: ?c_int, view_offset_y: ?c_int,
}, },

View file

@ -92,7 +92,7 @@ pub fn init(wlr_output: *wlr.Output) ?*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();
wlr_output.data = self; wlr_output.data = &self.scene_node_data;
server.events.exec("OutputInitPost", .{self.id}); server.events.exec("OutputInitPost", .{self.id});
@ -187,24 +187,44 @@ pub fn surfaceAt(self: *Output, lx: f64, ly: f64) ?SurfaceAtResult {
}; };
for(layers) |layer| { for(layers) |layer| {
if(layer.node.at(lx, ly, &sx, &sy)) |node| { const node = layer.node.at(lx, ly, &sx, &sy);
const scene_buffer = wlr.SceneBuffer.fromNode(node); if(node == null) continue;
const scene_surface = wlr.SceneSurface.tryFromBuffer(scene_buffer) orelse continue;
if (node.data == null) continue; const surface: ?*wlr.Surface = blk: {
const scene_node_data: *SceneNodeData = @ptrCast(@alignCast(node.data.?)); if (node.?.type == .buffer) {
const scene_buffer = wlr.SceneBuffer.fromNode(node.?);
switch (scene_node_data.*) { if (wlr.SceneSurface.tryFromBuffer(scene_buffer)) |scene_surface| {
.layer_surface, .view => { break :blk scene_surface.surface;
return SurfaceAtResult{ }
.scene_node_data = scene_node_data,
.surface = scene_surface.surface,
.sx = sx,
.sy = sy,
};
},
else => continue
} }
break :blk null;
};
if(surface == null) continue;
const scene_node_data: *SceneNodeData = blk: {
var n = node.?;
while (true) {
if (@as(?*SceneNodeData, @ptrCast(@alignCast(n.data)))) |snd| {
break :blk snd;
}
if (n.parent) |parent_tree| {
n = &parent_tree.node;
} else {
continue;
}
}
};
switch (scene_node_data.*) {
.layer_surface, .view => {
return SurfaceAtResult{
.scene_node_data = scene_node_data,
.surface = surface.?,
.sx = sx,
.sy = sy,
};
},
else => continue
} }
} }

View file

@ -74,8 +74,8 @@ pub fn viewById(self: *Root, id: u64) ?*View {
while(output_it.next()) |o| { while(output_it.next()) |o| {
if(o.output.data == null) continue; if(o.output.data == null) continue;
const scene_node_data: *SceneNodeData = @ptrCast(@alignCast(o.output.data.?)); const output_snd: *SceneNodeData = @ptrCast(@alignCast(o.output.data.?));
const output: *Output = switch (scene_node_data.*) { const output: *Output = switch (output_snd.*) {
.output => |output_ptr| output_ptr, .output => |output_ptr| output_ptr,
else => { else => {
std.log.err("Incorrect scene node type found", .{}); std.log.err("Incorrect scene node type found", .{});
@ -88,8 +88,14 @@ pub fn viewById(self: *Root, id: u64) ?*View {
while(node_it.next()) |node| { while(node_it.next()) |node| {
if(node.data == null) continue; if(node.data == null) continue;
const view: *View = @as(*View, @ptrCast(@alignCast(node.data.?))); const view_snd: *SceneNodeData = @ptrCast(@alignCast(node.data.?));
if(view.id == id) return view;
// TODO: Should we assert that we want only views to be here
// -- Basically should we use switch statements for snd interactions
// -- Or if statements, for simplicity
if(view_snd.* == .view and view_snd.view.id == id) {
return view_snd.view;
}
} }
} }

View file

@ -131,7 +131,7 @@ pub fn init(self: *Server) void {
self.root.scene.setGammaControlManagerV1(try wlr.GammaControlManagerV1.create(self.wl_server)); self.root.scene.setGammaControlManagerV1(try wlr.GammaControlManagerV1.create(self.wl_server));
// Add event listeners to events // Add event listeners to events
// Backedn events // Backend events
self.backend.events.new_input.add(&self.new_input); self.backend.events.new_input.add(&self.new_input);
self.backend.events.new_output.add(&self.new_output); self.backend.events.new_output.add(&self.new_output);
@ -211,12 +211,13 @@ fn handleNewXdgToplevelDecoration(
decoration: *wlr.XdgToplevelDecorationV1 decoration: *wlr.XdgToplevelDecorationV1
) void { ) void {
if(server.root.viewById(@intFromPtr(decoration.toplevel))) |view| { if(server.root.viewById(@intFromPtr(decoration.toplevel))) |view| {
std.log.debug("found view\n", .{});
view.xdg_toplevel_decoration = decoration; view.xdg_toplevel_decoration = decoration;
} }
} }
fn handleNewXdgPopup(_: *wl.Listener(*wlr.XdgPopup), xdg_popup: *wlr.XdgPopup) void { fn handleNewXdgPopup(_: *wl.Listener(*wlr.XdgPopup), _: *wlr.XdgPopup) void {
_ = xdg_popup; std.log.debug("Unimplemented Server.handleNewXdgPopup\n", .{});
} }
fn handleNewLayerSurface( fn handleNewLayerSurface(

View file

@ -164,6 +164,7 @@ fn handleMap(listener: *wl.Listener(void)) void {
&server.seat.keyboard_group.keyboard.modifiers &server.seat.keyboard_group.keyboard.modifiers
); );
std.log.debug("setting view decoration mode to server side\n", .{});
if(view.xdg_toplevel_decoration) |decoration| { if(view.xdg_toplevel_decoration) |decoration| {
_ = decoration.setMode(wlr.XdgToplevelDecorationV1.Mode.server_side); _ = decoration.setMode(wlr.XdgToplevelDecorationV1.Mode.server_side);
} }