git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit7e5bd3e79510e6ff38983083be6790b76c54006a
parent3a5be63923
authorIsaac Freund <[email protected]>
date2021-05-13 15:08
river: remove all stored *Root pointers

These are no longer needed as server is global.

 river/Output.zig            |  1 -
 river/Server.zig            |  2 +-
 river/View.zig              |  1 -
 river/XwaylandUnmanaged.zig | 13 +++++--------
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/river/Output.zig b/river/Output.zig
index 9731192..f66ffee 100644
--- a/river/Output.zig
+++ b/river/Output.zig
@@ -33,7 +33,6 @@ const Box = @import("Box.zig");
 const LayerSurface = @import("LayerSurface.zig");
 const Layout = @import("Layout.zig");
 const LayoutDemand = @import("LayoutDemand.zig");
-const Root = @import("Root.zig");
 const View = @import("View.zig");
 const ViewStack = @import("view_stack.zig").ViewStack;
 const AttachMode = @import("view_stack.zig").AttachMode;
diff --git a/river/Server.zig b/river/Server.zig
index d887541..0f059e0 100644
--- a/river/Server.zig
+++ b/river/Server.zig
@@ -236,7 +236,7 @@ fn handleNewXwaylandSurface(listener: *wl.Listener(*wlr.XwaylandSurface), wlr_xw
         // The unmanged surface will add itself to the list of unmanaged views
         // in Root when it is mapped.
         const node = util.gpa.create(std.TailQueue(XwaylandUnmanaged).Node) catch return;
-        node.data.init(&self.root, wlr_xwayland_surface);
+        node.data.init(wlr_xwayland_surface);
         return;
     }
 
diff --git a/river/View.zig b/river/View.zig
index 8d09e8e..394dde4 100644
--- a/river/View.zig
+++ b/river/View.zig
@@ -29,7 +29,6 @@ const util = @import("util.zig");
 
 const Box = @import("Box.zig");
 const Output = @import("Output.zig");
-const Root = @import("Root.zig");
 const Seat = @import("Seat.zig");
 const ViewStack = @import("view_stack.zig").ViewStack;
 const XdgToplevel = @import("XdgToplevel.zig");
diff --git a/river/XwaylandUnmanaged.zig b/river/XwaylandUnmanaged.zig
index f6ac480..d7d3fdd 100644
--- a/river/XwaylandUnmanaged.zig
+++ b/river/XwaylandUnmanaged.zig
@@ -21,12 +21,10 @@ const std = @import("std");
 const wlr = @import("wlroots");
 const wl = @import("wayland").server.wl;
 
+const server = &@import("main.zig").server;
 const util = @import("util.zig");
 
 const Box = @import("Box.zig");
-const Root = @import("Root.zig");
-
-root: *Root,
 
 /// The corresponding wlroots object
 xwayland_surface: *wlr.XwaylandSurface,
@@ -40,8 +38,8 @@ destroy: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).i
 map: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleMap),
 unmap: wl.Listener(*wlr.XwaylandSurface) = wl.Listener(*wlr.XwaylandSurface).init(handleUnmap),
 
-pub fn init(self: *Self, root: *Root, xwayland_surface: *wlr.XwaylandSurface) void {
-    self.* = .{ .root = root, .xwayland_surface = xwayland_surface };
+pub fn init(self: *Self, xwayland_surface: *wlr.XwaylandSurface) void {
+    self.* = .{ .xwayland_surface = xwayland_surface };
 
     // Add listeners that are active over the the entire lifetime
     xwayland_surface.events.request_configure.add(&self.request_configure);
@@ -75,11 +73,10 @@ fn handleDestroy(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface:
 /// Called when the xwayland surface is mapped, or ready to display on-screen.
 fn handleMap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *wlr.XwaylandSurface) void {
     const self = @fieldParentPtr(Self, "map", listener);
-    const root = self.root;
 
     // Add self to the list of unmanaged views in the root
     const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
-    root.xwayland_unmanaged_views.prepend(node);
+    server.root.xwayland_unmanaged_views.prepend(node);
 
     // TODO: handle keyboard focus
     // if (wlr_xwayland_or_surface_wants_focus(self.xwayland_surface)) { ...
@@ -91,5 +88,5 @@ fn handleUnmap(listener: *wl.Listener(*wlr.XwaylandSurface), xwayland_surface: *
 
     // Remove self from the list of unmanged views in the root
     const node = @fieldParentPtr(std.TailQueue(Self).Node, "data", self);
-    self.root.xwayland_unmanaged_views.remove(node);
+    server.root.xwayland_unmanaged_views.remove(node);
 }