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

commitd53fc1eefbe6a8d147b57fa7f295cc5cc56d87d9
parent2adeb0fb90
authorIsaac Freund <[email protected]>
date2020-05-18 19:29
Implement popups for layer shell

 src/LayerSurface.zig | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/LayerSurface.zig b/src/LayerSurface.zig
index a90917c..088dd97 100644
--- a/src/LayerSurface.zig
+++ b/src/LayerSurface.zig
@@ -24,6 +24,7 @@ const c = @import("c.zig");
 const Box = @import("Box.zig");
 const Log = @import("log.zig").Log;
 const Output = @import("Output.zig");
+const XdgPopup = @import("XdgPopup.zig");
 
 output: *Output,
 wlr_layer_surface: *c.wlr_layer_surface_v1,
@@ -186,7 +187,10 @@ fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
 
 fn handleNewPopup(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
     const self = @fieldParentPtr(Self, "listen_new_popup", listener.?);
-    Log.Debug.log("new layer surface popup.", .{});
-    // TODO: handle popups
-    unreachable;
+    const wlr_xdg_popup = @ptrCast(*c.wlr_xdg_popup, @alignCast(@alignOf(*c.wlr_xdg_popup), data));
+    const allocator = self.output.root.server.allocator;
+
+    // This will free itself on destroy
+    var xdg_popup = allocator.create(XdgPopup) catch unreachable;
+    xdg_popup.init(self.output, &self.box, wlr_xdg_popup);
 }