From 1d8bca24ae3936c830574089e827839c3da428d5 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 14 Mar 2024 12:55:54 +0100 Subject: [PATCH] SeatStatus: eliminate "self" naming convention --- river/SeatStatus.zig | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/river/SeatStatus.zig b/river/SeatStatus.zig index 59c4531..1941774 100644 --- a/river/SeatStatus.zig +++ b/river/SeatStatus.zig @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -const Self = @This(); +const SeatStatus = @This(); const std = @import("std"); const wayland = @import("wayland"); @@ -29,52 +29,52 @@ const Output = @import("Output.zig"); const View = @import("View.zig"); seat: *Seat, -seat_status: *zriver.SeatStatusV1, +seat_status_v1: *zriver.SeatStatusV1, -pub fn init(self: *Self, seat: *Seat, seat_status: *zriver.SeatStatusV1) void { - self.* = .{ .seat = seat, .seat_status = seat_status }; +pub fn init(seat_status: *SeatStatus, seat: *Seat, seat_status_v1: *zriver.SeatStatusV1) void { + seat_status.* = .{ .seat = seat, .seat_status_v1 = seat_status_v1 }; - seat_status.setHandler(*Self, handleRequest, handleDestroy, self); + seat_status_v1.setHandler(*SeatStatus, handleRequest, handleDestroy, seat_status); // Send all info once on bind - self.sendMode(server.config.modes.items[seat.mode_id].name); - if (seat.focused_output) |output| self.sendOutput(output, .focused); - self.sendFocusedView(); + seat_status.sendMode(server.config.modes.items[seat.mode_id].name); + if (seat.focused_output) |output| seat_status.sendOutput(output, .focused); + seat_status.sendFocusedView(); } -fn handleRequest(seat_status: *zriver.SeatStatusV1, request: zriver.SeatStatusV1.Request, _: *Self) void { +fn handleRequest(seat_status_v1: *zriver.SeatStatusV1, request: zriver.SeatStatusV1.Request, _: *SeatStatus) void { switch (request) { - .destroy => seat_status.destroy(), + .destroy => seat_status_v1.destroy(), } } -fn handleDestroy(_: *zriver.SeatStatusV1, self: *Self) void { - const node = @fieldParentPtr(std.SinglyLinkedList(Self).Node, "data", self); - self.seat.status_trackers.remove(node); +fn handleDestroy(_: *zriver.SeatStatusV1, seat_status: *SeatStatus) void { + const node = @fieldParentPtr(std.SinglyLinkedList(SeatStatus).Node, "data", seat_status); + seat_status.seat.status_trackers.remove(node); util.gpa.destroy(node); } -pub fn sendOutput(self: Self, output: *Output, state: enum { focused, unfocused }) void { - const client = self.seat_status.getClient(); +pub fn sendOutput(seat_status: SeatStatus, output: *Output, state: enum { focused, unfocused }) void { + const client = seat_status.seat_status_v1.getClient(); var it = output.wlr_output.resources.iterator(.forward); while (it.next()) |wl_output| { if (wl_output.getClient() == client) switch (state) { - .focused => self.seat_status.sendFocusedOutput(wl_output), - .unfocused => self.seat_status.sendUnfocusedOutput(wl_output), + .focused => seat_status.seat_status_v1.sendFocusedOutput(wl_output), + .unfocused => seat_status.seat_status_v1.sendUnfocusedOutput(wl_output), }; } } -pub fn sendFocusedView(self: Self) void { - const title: [*:0]const u8 = if (self.seat.focused == .view) - self.seat.focused.view.getTitle() orelse "" +pub fn sendFocusedView(seat_status: SeatStatus) void { + const title: [*:0]const u8 = if (seat_status.seat.focused == .view) + seat_status.seat.focused.view.getTitle() orelse "" else ""; - self.seat_status.sendFocusedView(title); + seat_status.seat_status_v1.sendFocusedView(title); } -pub fn sendMode(self: Self, mode: [*:0]const u8) void { - if (self.seat_status.getVersion() >= 3) { - self.seat_status.sendMode(mode); +pub fn sendMode(seat_status: SeatStatus, mode: [*:0]const u8) void { + if (seat_status.seat_status_v1.getVersion() >= 3) { + seat_status.seat_status_v1.sendMode(mode); } }