Implement csd-filter-add and float-filter-add commands

This commit is contained in:
Leon Henrik Plickat 2020-07-16 19:45:45 +02:00 committed by Isaac Freund
parent 76da7e2b0d
commit a93c263502
5 changed files with 77 additions and 6 deletions

View file

@ -86,3 +86,11 @@ riverctl map passthrough $mod F11 enter-mode normal
# Set the layout on startup
riverctl layout rivertile left
# Set app-ids of views which should float
riverctl float-filter-add "float"
riverctl float-filter-add "popup"
# Set app-ids of views which should use client side decorations
riverctl csd-filter-add "gedit"

View file

@ -20,9 +20,17 @@ used to control and configure river.
*close*
Close the focused view.
*csd-filter-add* _app-id_
Add an app-id to the CSD filter list. Windows with this app-id are allowed
to use client side decoration instead of the default server side decoration.
*exit*
Exit the compositor, terminating the Wayland session.
*float-filter-add* _app-id_
Add an app-id to the float filter list. Windows with this app-id will start
floating.
*focus-output* *next*|*previous*
Focus next or previous output.

View file

@ -78,12 +78,6 @@ pub fn init(self: *Self) !void {
self.csd_filter = std.ArrayList([]const u8).init(util.gpa);
errdefer self.csd_filter.deinit();
// Float views with app_id "float"
try self.float_filter.append("float");
// Client side decorations for views with app_id "csd"
try self.csd_filter.append("csd");
}
pub fn deinit(self: Self) void {

View file

@ -35,9 +35,11 @@ const str_to_impl_fn = [_]struct {
.{ .name = "border-color-unfocused", .impl = @import("command/config.zig").borderColorUnfocused },
.{ .name = "border-width", .impl = @import("command/config.zig").borderWidth },
.{ .name = "close", .impl = @import("command/close.zig").close },
.{ .name = "csd-filter-add", .impl = @import("command/filter.zig").csdFilterAdd },
.{ .name = "declare-mode", .impl = @import("command/declare_mode.zig").declareMode },
.{ .name = "enter-mode", .impl = @import("command/enter_mode.zig").enterMode },
.{ .name = "exit", .impl = @import("command/exit.zig").exit },
.{ .name = "float-filter-add", .impl = @import("command/filter.zig").floatFilterAdd },
.{ .name = "focus-output", .impl = @import("command/focus_output.zig").focusOutput },
.{ .name = "focus-view", .impl = @import("command/focus_view.zig").focusView },
.{ .name = "layout", .impl = @import("command/layout.zig").layout },

59
river/command/filter.zig Normal file
View file

@ -0,0 +1,59 @@
// This file is part of river, a dynamic tiling wayland compositor.
//
// Copyright 2020 Leon Henrik Plickat
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
const util = @import("../util.zig");
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");
fn appendFilter(
allocator: *std.mem.Allocator,
list: *std.ArrayList([]const u8),
args: []const []const u8,
) Error!void {
if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments;
try list.append(try std.mem.dupe(allocator, u8, args[1]));
}
pub fn floatFilterAdd(
allocator: *std.mem.Allocator,
seat: *Seat,
args: []const []const u8,
out: *?[]const u8,
) Error!void {
try appendFilter(
allocator,
&seat.input_manager.server.config.float_filter,
args,
);
}
pub fn csdFilterAdd(
allocator: *std.mem.Allocator,
seat: *Seat,
args: []const []const u8,
out: *?[]const u8,
) Error!void {
try appendFilter(
allocator,
&seat.input_manager.server.config.csd_filter,
args,
);
}