Implement csd_filter list

This commit is contained in:
Leon Henrik Plickat
2020-07-16 01:21:22 +02:00
committed by Isaac Freund
parent 91126388b5
commit be29b0ef95
6 changed files with 64 additions and 13 deletions

View File

@ -22,6 +22,10 @@ const std = @import("std");
const c = @import("c.zig");
const util = @import("util.zig");
const Server = @import("Server.zig");
server: *Server,
wlr_xdg_toplevel_decoration: *c.wlr_xdg_toplevel_decoration_v1,
listen_destroy: c.wl_listener,
@ -29,8 +33,11 @@ listen_request_mode: c.wl_listener,
pub fn init(
self: *Self,
server: *Server,
wlr_xdg_toplevel_decoration: *c.wlr_xdg_toplevel_decoration_v1,
) void {
self.server = server;
self.wlr_xdg_toplevel_decoration = wlr_xdg_toplevel_decoration;
self.listen_destroy.notify = handleDestroy;
@ -49,8 +56,24 @@ fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
fn handleRequestMode(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const self = @fieldParentPtr(Self, "listen_request_mode", listener.?);
_ = c.wlr_xdg_toplevel_decoration_v1_set_mode(
self.wlr_xdg_toplevel_decoration,
.WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE,
);
const wlr_xdg_surface: *c.wlr_xdg_surface = self.wlr_xdg_toplevel_decoration.surface;
const wlr_xdg_toplevel: *c.wlr_xdg_toplevel = @field(wlr_xdg_surface, c.wlr_xdg_surface_union).toplevel;
const app_id: [*:0]const u8 = if (wlr_xdg_toplevel.app_id) |id| id else "NULL";
const use_csd = for (self.server.config.csd_filter.items) |filter_app_id| {
if (std.mem.eql(u8, std.mem.span(app_id), filter_app_id)) break true;
} else false;
if (use_csd) {
_ = c.wlr_xdg_toplevel_decoration_v1_set_mode(
self.wlr_xdg_toplevel_decoration,
.WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE,
);
} else {
_ = c.wlr_xdg_toplevel_decoration_v1_set_mode(
self.wlr_xdg_toplevel_decoration,
.WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE,
);
}
}