mirror of
https://github.com/zoriya/gaze.git
synced 2026-06-04 02:36:00 +00:00
Support basic popups
This commit is contained in:
@@ -28,7 +28,7 @@ pub const Client = struct {
|
||||
.scene_tree = try server.scene.tree.createSceneXdgSurface(xdg_surface),
|
||||
};
|
||||
self.scene_tree.node.data = @intFromPtr(self);
|
||||
xdg_surface.data = @intFromPtr(self);
|
||||
xdg_surface.data = @intFromPtr(self.scene_tree);
|
||||
|
||||
xdg_surface.surface.events.map.add(&self.map_l);
|
||||
xdg_surface.surface.events.unmap.add(&self.unmap_l);
|
||||
|
||||
+15
-4
@@ -88,13 +88,24 @@ pub const Server = struct {
|
||||
});
|
||||
}
|
||||
|
||||
fn onNewSurface(self: *Server, surface: *wlr.XdgSurface) void {
|
||||
switch (surface.role) {
|
||||
.toplevel => Client.create(self, surface) catch {
|
||||
fn onNewSurface(self: *Server, xdg_surface: *wlr.XdgSurface) void {
|
||||
switch (xdg_surface.role) {
|
||||
.toplevel => Client.create(self, xdg_surface) catch {
|
||||
std.log.err("Couldn't create a client", .{});
|
||||
},
|
||||
.popup => {
|
||||
// TODO: implement popupus
|
||||
// These asserts are fine since tinywl.zig doesn't support anything else that can
|
||||
// make xdg popups (e.g. layer shell).
|
||||
const parent = wlr.XdgSurface.tryFromWlrSurface(xdg_surface.role_data.popup.?.parent.?) orelse return;
|
||||
const parent_tree = @as(?*wlr.SceneTree, @ptrFromInt(parent.data)) orelse {
|
||||
// The xdg surface user data could be left null due to allocation failure.
|
||||
return;
|
||||
};
|
||||
const scene_tree = parent_tree.createSceneXdgSurface(xdg_surface) catch {
|
||||
std.log.err("failed to allocate xdg popup node", .{});
|
||||
return;
|
||||
};
|
||||
xdg_surface.data = @intFromPtr(scene_tree);
|
||||
},
|
||||
.none => unreachable,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user