river: Allow applying CSD based on window titles

This extends the `csd-filter-add` command to allow matching on window
titles as well, using a `csd-filter-add kind pattern` syntax. The
following kinds are supported:

  * `title`, which matches window titles
  * `app-id`, which matches app ids

Only exact matches are considered.

As an example following configuration applies client-side decorations to
all windows with the title 'asdf with spaces'.

    riverctl csd-filter-add title 'asdf with spaces'
This commit is contained in:
Ben Fiedler
2021-09-06 15:28:05 +02:00
committed by Isaac Freund
parent 98aed8d47e
commit 5f6428bafe
6 changed files with 79 additions and 33 deletions

View File

@ -26,6 +26,7 @@ const server = &@import("main.zig").server;
const util = @import("util.zig");
const Server = @import("Server.zig");
const View = @import("View.zig");
xdg_toplevel_decoration: *wlr.XdgToplevelDecorationV1,
@ -62,8 +63,8 @@ fn handleRequestMode(
) void {
const self = @fieldParentPtr(Self, "request_mode", listener);
const toplevel = self.xdg_toplevel_decoration.surface.role_data.toplevel;
if (toplevel.app_id != null and server.config.csd_filter.contains(mem.span(toplevel.app_id.?))) {
const view = @intToPtr(*View, self.xdg_toplevel_decoration.surface.data);
if (server.config.csdAllowed(view)) {
_ = self.xdg_toplevel_decoration.setMode(.client_side);
} else {
_ = self.xdg_toplevel_decoration.setMode(.server_side);