From 7838d092756b84e308312b344ba6cd2ad6f5e767 Mon Sep 17 00:00:00 2001 From: Harrison DiAmbrosio Date: Thu, 16 Oct 2025 17:19:03 -0400 Subject: [PATCH] research in ideation.md --- ideation.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.zig | 1 - src/output.zig | 6 ++++++ src/scene.zig | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/output.zig create mode 100644 src/scene.zig diff --git a/ideation.md b/ideation.md index 8ab1538..b43632d 100644 --- a/ideation.md +++ b/ideation.md @@ -15,3 +15,56 @@ # Style Guide Perhaps we do what river does for organization? Checkout river/Server.zig:17's use of @This(); + +# information + +server owns +- compositor + +wlr_compositor owms +- a list of wlr_surfaces + +wlr_surfaces owns +- wl_resources which should (be/have?) buffers + +## Scene Structure +wlr_scene owns +- list of outputs +- wlr_scene_tree + +wlr_scene_tree owns +- its own wlr_scene_node +- list of its children wlr_scene_node + +wlr_scene_node can be TREE, RECT or BUFFER and owns +- its own type +- a pointer to its parent wlr_scene_tree +- a list of children as wlr_scene_trees +- boolean if enabled +- x, y position relative to parent +- wl signal for destroy +- *void arbitrary data + +```zig +struct wl_resource *_surface; + +wl_resource_for_each(_surface, &server->compositor->surfaces) { + struct wlr_surface *surface = wlr_surface_from_resource(_surface); + if (!wlr_surface_has_buffer(surface)) { + continue; + } + + struct wlr_box render_box = { + .x = 20, .y = 20, + .width = surface->current->width, + .height = surface->current->height + }; + + float matrix[16]; + wlr_matrix_project_box(&matrix, &render_box, + surface->current->transform, + 0, &wlr_output->transform_matrix); + wlr_render_with_matrix(renderer, surface->texture, &matrix, 1.0f); + wlr_surface_send_frame_done(surface, &now); +} +``` diff --git a/src/main.zig b/src/main.zig index 05ea093..60f6960 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,6 +3,5 @@ const std = @import("std"); const Server = @import("server.zig").Server; pub fn main() !void { - std.debug.print("Starting mezzaluna", .{}); _ = try Server.init(); } diff --git a/src/output.zig b/src/output.zig new file mode 100644 index 0000000..ea9d62f --- /dev/null +++ b/src/output.zig @@ -0,0 +1,6 @@ +const std = @import("std"); +const wl = @import("wayland").server.wl; +const wlr = @import("wlroots"); + +pub const Ouput = struct { +} diff --git a/src/scene.zig b/src/scene.zig new file mode 100644 index 0000000..da3dd3f --- /dev/null +++ b/src/scene.zig @@ -0,0 +1,50 @@ +const wl = @import("wayland").server.wl; +const wlr = @import("wlroots"); + +// server owns +// - compositor +// +// wlr_compositor owms +// - a list of wlr_surfaces +// +// wlr_surfaces own_buffers +// +// struct wl_resource *_surface; +// wl_resource_for_each(_surface, &server->compositor->surfaces) { +// struct wlr_surface *surface = wlr_surface_from_resource(_surface); +// if (!wlr_surface_has_buffer(surface)) { +// continue; +// } +// struct wlr_box render_box = { +// .x = 20, .y = 20, +// .width = surface->current->width, +// .height = surface->current->height +// }; +// float matrix[16]; +// wlr_matrix_project_box(&matrix, &render_box, +// surface->current->transform, +// 0, &wlr_output->transform_matrix); +// wlr_render_with_matrix(renderer, surface->texture, &matrix, 1.0f); +// wlr_surface_send_frame_done(surface, &now); +// } +// +// +// +// wlr_scene owns +// - list of outputs +// - wlr_scene_tree +// +// wlr_scene_tree owns +// - its own wlr_scene_node +// - list of its children wlr_scene_node +// +// wlr_scene_node can be TREE, RECT or BUFFER and owns +// - its own type +// - a pointer to its parent wlr_scene_tree +// - a list of children as wlr_scene_trees +// - boolean if enabled +// - x, y position relative to parent +// - wl signal for destroy +// - *void arbitrary data + +