2020-05-02 10:21:10 -07:00
|
|
|
// This file is part of river, a dynamic tiling wayland compositor.
|
|
|
|
//
|
|
|
|
// Copyright 2020 Isaac Freund
|
|
|
|
//
|
|
|
|
// 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/>.
|
|
|
|
|
2020-05-02 07:27:00 -07:00
|
|
|
const Self = @This();
|
|
|
|
|
2020-04-07 12:48:56 -07:00
|
|
|
const std = @import("std");
|
2020-05-02 07:27:00 -07:00
|
|
|
|
2020-04-07 12:48:56 -07:00
|
|
|
const c = @import("c.zig");
|
2020-06-16 13:08:36 -07:00
|
|
|
const util = @import("util.zig");
|
2020-04-07 12:48:56 -07:00
|
|
|
|
2020-05-02 14:11:56 -07:00
|
|
|
const Server = @import("Server.zig");
|
2020-06-01 06:16:18 -07:00
|
|
|
const Mapping = @import("Mapping.zig");
|
2020-04-07 12:48:56 -07:00
|
|
|
|
2020-06-19 09:44:28 -07:00
|
|
|
/// Color of background in RGBA (alpha should only affect nested sessions)
|
|
|
|
background_color: [4]f32,
|
|
|
|
|
2020-05-02 07:27:00 -07:00
|
|
|
/// Width of borders in pixels
|
|
|
|
border_width: u32,
|
2020-04-22 14:35:16 -07:00
|
|
|
|
2020-06-13 04:09:43 -07:00
|
|
|
/// Color of border of focused window in RGBA
|
|
|
|
border_color_focused: [4]f32,
|
2020-06-12 09:07:39 -07:00
|
|
|
|
2020-06-13 04:09:43 -07:00
|
|
|
/// Color of border of unfocused window in RGBA
|
|
|
|
border_color_unfocused: [4]f32,
|
2020-06-12 09:07:39 -07:00
|
|
|
|
2020-05-02 07:27:00 -07:00
|
|
|
/// Amount of view padding in pixels
|
|
|
|
view_padding: u32,
|
2020-04-07 12:48:56 -07:00
|
|
|
|
2020-05-02 07:27:00 -07:00
|
|
|
/// Amount of padding arount the outer edge of the layout in pixels
|
|
|
|
outer_padding: u32,
|
2020-04-13 16:18:44 -07:00
|
|
|
|
2020-06-01 06:16:18 -07:00
|
|
|
/// Map of keymap mode name to mode id
|
2020-05-31 15:20:49 -07:00
|
|
|
mode_to_id: std.StringHashMap(usize),
|
2020-05-31 14:56:25 -07:00
|
|
|
|
2020-06-01 06:16:18 -07:00
|
|
|
/// All user-defined keymap modes, indexed by mode id
|
|
|
|
modes: std.ArrayList(std.ArrayList(Mapping)),
|
2020-05-02 07:27:00 -07:00
|
|
|
|
|
|
|
/// List of app_ids which will be started floating
|
|
|
|
float_filter: std.ArrayList([*:0]const u8),
|
|
|
|
|
2020-07-15 16:21:22 -07:00
|
|
|
/// List of app_ids which are allowed to use client side decorations
|
|
|
|
csd_filter: std.ArrayList([]const u8),
|
|
|
|
|
2020-06-16 13:08:36 -07:00
|
|
|
pub fn init(self: *Self) !void {
|
2020-06-19 09:44:28 -07:00
|
|
|
self.background_color = [_]f32{ 0.0, 0.16862745, 0.21176471, 1.0 }; // Solarized base03
|
2020-05-02 07:27:00 -07:00
|
|
|
self.border_width = 2;
|
2020-06-13 04:09:43 -07:00
|
|
|
self.border_color_focused = [_]f32{ 0.57647059, 0.63137255, 0.63137255, 1.0 }; // Solarized base1
|
|
|
|
self.border_color_unfocused = [_]f32{ 0.34509804, 0.43137255, 0.45882353, 1.0 }; // Solarized base0
|
2020-05-02 07:27:00 -07:00
|
|
|
self.view_padding = 8;
|
|
|
|
self.outer_padding = 8;
|
|
|
|
|
2020-06-19 05:31:53 -07:00
|
|
|
self.mode_to_id = std.StringHashMap(usize).init(util.gpa);
|
2020-06-26 03:46:18 -07:00
|
|
|
errdefer self.mode_to_id.deinit();
|
2020-06-26 03:58:11 -07:00
|
|
|
const owned_slice = try std.mem.dupe(util.gpa, u8, "normal");
|
|
|
|
errdefer util.gpa.free(owned_slice);
|
|
|
|
try self.mode_to_id.putNoClobber(owned_slice, 0);
|
2020-05-31 14:56:25 -07:00
|
|
|
|
2020-06-19 05:31:53 -07:00
|
|
|
self.modes = std.ArrayList(std.ArrayList(Mapping)).init(util.gpa);
|
2020-06-26 03:46:18 -07:00
|
|
|
errdefer self.modes.deinit();
|
2020-06-19 05:31:53 -07:00
|
|
|
try self.modes.append(std.ArrayList(Mapping).init(util.gpa));
|
2020-05-16 15:03:26 -07:00
|
|
|
|
2020-06-19 05:31:53 -07:00
|
|
|
self.float_filter = std.ArrayList([*:0]const u8).init(util.gpa);
|
2020-06-26 03:46:18 -07:00
|
|
|
errdefer self.float_filter.deinit();
|
2020-05-02 07:27:00 -07:00
|
|
|
|
2020-07-15 16:21:22 -07:00
|
|
|
self.csd_filter = std.ArrayList([]const u8).init(util.gpa);
|
|
|
|
errdefer self.csd_filter.deinit();
|
|
|
|
|
2020-05-16 15:03:26 -07:00
|
|
|
// Float views with app_id "float"
|
2020-05-02 07:27:00 -07:00
|
|
|
try self.float_filter.append("float");
|
2020-07-15 16:21:22 -07:00
|
|
|
|
|
|
|
// Client side decorations for views with app_id "csd"
|
|
|
|
try self.csd_filter.append("csd");
|
2020-05-02 07:27:00 -07:00
|
|
|
}
|
2020-05-16 15:03:26 -07:00
|
|
|
|
2020-06-16 13:08:36 -07:00
|
|
|
pub fn deinit(self: Self) void {
|
2020-06-26 03:58:11 -07:00
|
|
|
var it = self.mode_to_id.iterator();
|
|
|
|
while (it.next()) |kv| util.gpa.free(kv.key);
|
2020-05-31 14:56:25 -07:00
|
|
|
self.mode_to_id.deinit();
|
2020-06-26 03:58:11 -07:00
|
|
|
|
2020-06-02 04:45:56 -07:00
|
|
|
for (self.modes.items) |mode| {
|
2020-06-19 05:31:53 -07:00
|
|
|
for (mode.items) |mapping| mapping.deinit(util.gpa);
|
2020-06-02 04:45:56 -07:00
|
|
|
mode.deinit();
|
|
|
|
}
|
2020-05-19 13:59:50 -07:00
|
|
|
self.modes.deinit();
|
2020-06-26 03:58:11 -07:00
|
|
|
|
2020-06-02 04:45:56 -07:00
|
|
|
self.float_filter.deinit();
|
2020-07-15 16:21:22 -07:00
|
|
|
self.csd_filter.deinit();
|
2020-05-19 13:59:50 -07:00
|
|
|
}
|