Config: eliminate "self" naming convention
This commit is contained in:
parent
6c3f851464
commit
b7c53ceda7
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
const Self = @This();
|
const Config = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const fmt = std.fmt;
|
const fmt = std.fmt;
|
||||||
@ -133,7 +133,7 @@ xkb_context: *xkb.Context,
|
|||||||
/// The xkb keymap used for all keyboards
|
/// The xkb keymap used for all keyboards
|
||||||
keymap: *xkb.Keymap,
|
keymap: *xkb.Keymap,
|
||||||
|
|
||||||
pub fn init() !Self {
|
pub fn init() !Config {
|
||||||
const xkb_context = xkb.Context.new(.no_flags) orelse return error.XkbContextFailed;
|
const xkb_context = xkb.Context.new(.no_flags) orelse return error.XkbContextFailed;
|
||||||
defer xkb_context.unref();
|
defer xkb_context.unref();
|
||||||
|
|
||||||
@ -142,55 +142,55 @@ pub fn init() !Self {
|
|||||||
const keymap = xkb.Keymap.newFromNames(xkb_context, null, .no_flags) orelse return error.XkbKeymapFailed;
|
const keymap = xkb.Keymap.newFromNames(xkb_context, null, .no_flags) orelse return error.XkbKeymapFailed;
|
||||||
defer keymap.unref();
|
defer keymap.unref();
|
||||||
|
|
||||||
var self = Self{
|
var config = Config{
|
||||||
.mode_to_id = std.StringHashMap(u32).init(util.gpa),
|
.mode_to_id = std.StringHashMap(u32).init(util.gpa),
|
||||||
.modes = try std.ArrayListUnmanaged(Mode).initCapacity(util.gpa, 2),
|
.modes = try std.ArrayListUnmanaged(Mode).initCapacity(util.gpa, 2),
|
||||||
.xkb_context = xkb_context.ref(),
|
.xkb_context = xkb_context.ref(),
|
||||||
.keymap = keymap.ref(),
|
.keymap = keymap.ref(),
|
||||||
};
|
};
|
||||||
errdefer self.deinit();
|
errdefer config.deinit();
|
||||||
|
|
||||||
// Start with two empty modes, "normal" and "locked"
|
// Start with two empty modes, "normal" and "locked"
|
||||||
{
|
{
|
||||||
// Normal mode, id 0
|
// Normal mode, id 0
|
||||||
const owned_slice = try util.gpa.dupeZ(u8, "normal");
|
const owned_slice = try util.gpa.dupeZ(u8, "normal");
|
||||||
try self.mode_to_id.putNoClobber(owned_slice, 0);
|
try config.mode_to_id.putNoClobber(owned_slice, 0);
|
||||||
self.modes.appendAssumeCapacity(.{ .name = owned_slice });
|
config.modes.appendAssumeCapacity(.{ .name = owned_slice });
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Locked mode, id 1
|
// Locked mode, id 1
|
||||||
const owned_slice = try util.gpa.dupeZ(u8, "locked");
|
const owned_slice = try util.gpa.dupeZ(u8, "locked");
|
||||||
try self.mode_to_id.putNoClobber(owned_slice, 1);
|
try config.mode_to_id.putNoClobber(owned_slice, 1);
|
||||||
self.modes.appendAssumeCapacity(.{ .name = owned_slice });
|
config.modes.appendAssumeCapacity(.{ .name = owned_slice });
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(config: *Config) void {
|
||||||
self.mode_to_id.deinit();
|
config.mode_to_id.deinit();
|
||||||
for (self.modes.items) |*mode| mode.deinit();
|
for (config.modes.items) |*mode| mode.deinit();
|
||||||
self.modes.deinit(util.gpa);
|
config.modes.deinit(util.gpa);
|
||||||
|
|
||||||
self.rules.float.deinit();
|
config.rules.float.deinit();
|
||||||
self.rules.ssd.deinit();
|
config.rules.ssd.deinit();
|
||||||
self.rules.tags.deinit();
|
config.rules.tags.deinit();
|
||||||
for (self.rules.output.rules.items) |rule| {
|
for (config.rules.output.rules.items) |rule| {
|
||||||
util.gpa.free(rule.value);
|
util.gpa.free(rule.value);
|
||||||
}
|
}
|
||||||
self.rules.output.deinit();
|
config.rules.output.deinit();
|
||||||
self.rules.position.deinit();
|
config.rules.position.deinit();
|
||||||
self.rules.dimensions.deinit();
|
config.rules.dimensions.deinit();
|
||||||
self.rules.fullscreen.deinit();
|
config.rules.fullscreen.deinit();
|
||||||
|
|
||||||
util.gpa.free(self.default_layout_namespace);
|
util.gpa.free(config.default_layout_namespace);
|
||||||
|
|
||||||
self.keymap.unref();
|
config.keymap.unref();
|
||||||
self.xkb_context.unref();
|
config.xkb_context.unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outputRuleMatch(self: *Self, view: *View) !?*Output {
|
pub fn outputRuleMatch(config: *Config, view: *View) !?*Output {
|
||||||
const output_name = self.rules.output.match(view) orelse return null;
|
const output_name = config.rules.output.match(view) orelse return null;
|
||||||
var it = server.root.active_outputs.iterator(.forward);
|
var it = server.root.active_outputs.iterator(.forward);
|
||||||
while (it.next()) |output| {
|
while (it.next()) |output| {
|
||||||
const wlr_output = output.wlr_output;
|
const wlr_output = output.wlr_output;
|
||||||
|
Loading…
Reference in New Issue
Block a user