almost there

This commit is contained in:
Harrison DiAmbrosio 2025-10-19 20:23:46 -04:00
parent 898342400e
commit cf7f397ed9
6 changed files with 63 additions and 19 deletions

View file

@ -8,7 +8,7 @@ const gpa = std.heap.c_allocator;
pub var server: Server = undefined;
pub fn main() !void {
wlr.log.init(.debug, null);
wlr.log.init(.err, null);
std.log.info("Starting mezzaluna", .{});

View file

@ -63,7 +63,7 @@ fn handleFrame(
_: *wl.Listener(*wlr.Output),
wlr_output: *wlr.Output
) void {
// std.log.debug("Handling frame for {s}", .{wlr_output.name});
std.log.debug("Handling frame for {s}", .{wlr_output.name});
const scene_output = server.root.scene.getSceneOutput(wlr_output);

View file

@ -11,7 +11,6 @@ const server = &@import("main.zig").server;
const gpa = std.heap.c_allocator;
scene: *wlr.Scene,
scene_tree: ?*wlr.SceneTree,
scene_output_layout: *wlr.SceneOutputLayout,
output_layout: *wlr.OutputLayout,
@ -29,11 +28,9 @@ pub fn init(self: *Root) !void {
self.* = .{
.scene = scene,
.scene_tree = null,
.output_layout = output_layout,
.scene_output_layout = try scene.attachOutputLayout(output_layout),
.all_views = try .initCapacity(gpa, 10),
};
}
@ -51,12 +48,12 @@ pub fn addOutput(self: *Root, new_output: *Output) void {
}
pub fn addView(self: *Root, view: *View) void {
self.all_views.append(gpa, view) catch {
std.log.err("Out of memory to append view", .{});
return;
};
// self.all_views.append(gpa, view) catch {
// std.log.err("Out of memory to append view", .{});
// return;
// };
self.scene_tree = self.scene.tree.createSceneXdgSurface(view.xdg_toplevel.base) catch {
view.scene_tree = self.scene.tree.createSceneXdgSurface(view.xdg_toplevel.base) catch {
std.log.err("Unable to create scene node for new view", .{});
_ = self.all_views.pop();

View file

@ -8,6 +8,7 @@ const gpa = std.heap.c_allocator;
const server = &@import("main.zig").server;
xdg_toplevel: *wlr.XdgToplevel,
scene_tree: ?*wlr.SceneTree,
// XdgTopLevel Listeners
map: wl.Listener(void) = wl.Listener(void).init(handleMap),
@ -24,15 +25,23 @@ pub fn initFromTopLevel(xdg_toplevel: *wlr.XdgToplevel) ?*View {
return null;
};
self.xdg_toplevel = xdg_toplevel;
self.* = .{
.xdg_toplevel = xdg_toplevel,
.scene_tree = null,
};
self.xdg_toplevel.base.surface.events.map.add(&self.map);
self.xdg_toplevel.base.surface.events.unmap.add(&self.unmap);
self.xdg_toplevel.base.surface.events.commit.add(&self.commit);
// Debug what we have
std.log.debug("xdg_toplevel ptr: {*}", .{xdg_toplevel});
std.log.debug("xdg_toplevel.base ptr: {*}", .{xdg_toplevel.base});
std.log.debug("xdg_toplevel.base type: {}", .{@TypeOf(xdg_toplevel.base)});
self.xdg_toplevel.events.destroy.add(&self.destroy);
// self.xdg_toplevel.events.request_move.add(&self.request_move);
// self.xdg_toplevel.events.request_resize.add(&self.request_resize);
const xdg_surface = xdg_toplevel.base;
// Attach listeners
xdg_surface.surface.events.map.add(&self.map);
xdg_surface.surface.events.unmap.add(&self.unmap);
xdg_surface.surface.events.commit.add(&self.commit);
xdg_toplevel.events.destroy.add(&self.destroy);
return self;
}
@ -71,7 +80,11 @@ fn handleMap(listener: *wl.Listener(void)) void {
std.log.info("View mapped {s}", .{view.xdg_toplevel.title orelse "(unnamed)"});
const xdg_surface = view.xdg_toplevel.base;
server.seat.wlr_seat.keyboardNotifyEnter(xdg_surface.surface, &.{}, null);
server.seat.wlr_seat.keyboardNotifyEnter(
xdg_surface.surface,
server.keyboard.wlr_keyboard.keycodes[0..server.keyboard.wlr_keyboard.num_keycodes],
&server.keyboard.wlr_keyboard.modifiers
);
}
fn handleUnmap(listener: *wl.Listener(void)) void {
@ -102,7 +115,6 @@ fn handleDestroy(listener: *wl.Listener(void)) void {
fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void {
_ = listener;
_ = surface;
std.log.err("Unimplemented view handle commit", .{});
}
fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), popup: *wlr.XdgPopup) void {