river-status: add mode event to seat status

This allows clients such as a status bar to display the currently active
mode.
This commit is contained in:
Isaac Freund
2022-05-31 18:09:03 +02:00
parent 03e8da669c
commit d657dc791b
10 changed files with 49 additions and 27 deletions

View File

@ -38,9 +38,12 @@ pub fn declareMode(
if (config.mode_to_id.get(new_mode_name) != null) return;
try config.mode_to_id.ensureUnusedCapacity(1);
try config.modes.ensureUnusedCapacity(util.gpa, 1);
const owned_name = try util.gpa.dupe(u8, new_mode_name);
errdefer util.gpa.free(owned_name);
try config.mode_to_id.putNoClobber(owned_name, config.modes.items.len);
config.modes.appendAssumeCapacity(.{});
const owned_name = try util.gpa.dupeZ(u8, new_mode_name);
const id = @intCast(u32, config.modes.items.len);
config.mode_to_id.putAssumeCapacityNoClobber(owned_name, id);
config.modes.appendAssumeCapacity(.{ .name = owned_name });
}

View File

@ -59,5 +59,5 @@ pub fn enterMode(
return Error.Other;
}
seat.mode_id = mode_id;
seat.enterMode(mode_id);
}