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

20
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/zig-out/bin/mez",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"internalConsoleOptions": "openOnSessionStart",
"MIMode": "lldb",
"MIDebuggerPath": "/bin/lldb",
"preLaunchTask": "build",
}
]
}

15
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "zig build",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

View file

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

View file

@ -63,7 +63,7 @@ fn handleFrame(
_: *wl.Listener(*wlr.Output), _: *wl.Listener(*wlr.Output),
wlr_output: *wlr.Output wlr_output: *wlr.Output
) void { ) 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); 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; const gpa = std.heap.c_allocator;
scene: *wlr.Scene, scene: *wlr.Scene,
scene_tree: ?*wlr.SceneTree,
scene_output_layout: *wlr.SceneOutputLayout, scene_output_layout: *wlr.SceneOutputLayout,
output_layout: *wlr.OutputLayout, output_layout: *wlr.OutputLayout,
@ -29,11 +28,9 @@ pub fn init(self: *Root) !void {
self.* = .{ self.* = .{
.scene = scene, .scene = scene,
.scene_tree = null,
.output_layout = output_layout, .output_layout = output_layout,
.scene_output_layout = try scene.attachOutputLayout(output_layout), .scene_output_layout = try scene.attachOutputLayout(output_layout),
.all_views = try .initCapacity(gpa, 10), .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 { pub fn addView(self: *Root, view: *View) void {
self.all_views.append(gpa, view) catch { // self.all_views.append(gpa, view) catch {
std.log.err("Out of memory to append view", .{}); // std.log.err("Out of memory to append view", .{});
return; // 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", .{}); std.log.err("Unable to create scene node for new view", .{});
_ = self.all_views.pop(); _ = self.all_views.pop();

View file

@ -8,6 +8,7 @@ const gpa = std.heap.c_allocator;
const server = &@import("main.zig").server; const server = &@import("main.zig").server;
xdg_toplevel: *wlr.XdgToplevel, xdg_toplevel: *wlr.XdgToplevel,
scene_tree: ?*wlr.SceneTree,
// XdgTopLevel Listeners // XdgTopLevel Listeners
map: wl.Listener(void) = wl.Listener(void).init(handleMap), map: wl.Listener(void) = wl.Listener(void).init(handleMap),
@ -24,15 +25,23 @@ pub fn initFromTopLevel(xdg_toplevel: *wlr.XdgToplevel) ?*View {
return null; 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); // Debug what we have
self.xdg_toplevel.base.surface.events.unmap.add(&self.unmap); std.log.debug("xdg_toplevel ptr: {*}", .{xdg_toplevel});
self.xdg_toplevel.base.surface.events.commit.add(&self.commit); 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); const xdg_surface = xdg_toplevel.base;
// self.xdg_toplevel.events.request_move.add(&self.request_move);
// self.xdg_toplevel.events.request_resize.add(&self.request_resize); // 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; 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)"}); std.log.info("View mapped {s}", .{view.xdg_toplevel.title orelse "(unnamed)"});
const xdg_surface = view.xdg_toplevel.base; 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 { 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 { fn handleCommit(listener: *wl.Listener(*wlr.Surface), surface: *wlr.Surface) void {
_ = listener; _ = listener;
_ = surface; _ = surface;
std.log.err("Unimplemented view handle commit", .{});
} }
fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), popup: *wlr.XdgPopup) void { fn handleNewPopup(listener: *wl.Listener(*wlr.XdgPopup), popup: *wlr.XdgPopup) void {