From f5304237b58c61cf2eb023d8a4c91d97c8808d33 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2020 15:58:04 +0200 Subject: [PATCH] Pass self as immutable where possible --- src/cursor.zig | 8 ++++---- src/output.zig | 2 +- src/root.zig | 8 ++++---- src/seat.zig | 4 ++-- src/server.zig | 2 +- src/view.zig | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cursor.zig b/src/cursor.zig index af39e73..995f91d 100644 --- a/src/cursor.zig +++ b/src/cursor.zig @@ -89,12 +89,12 @@ pub const Cursor = struct { c.wl_signal_add(&self.seat.wlr_seat.events.request_set_cursor, &self.listen_request_set_cursor); } - pub fn destroy(self: *Self) void { + pub fn destroy(self: Self) void { c.wlr_xcursor_manager_destroy(self.wlr_xcursor_manager); c.wlr_cursor_destroy(self.wlr_cursor); } - fn processMove(self: *Self, time: u32) void { + fn processMove(self: Self, time: u32) void { // Move the grabbed view to the new position. // TODO: log on null if (self.grabbed_view) |view| { @@ -103,7 +103,7 @@ pub const Cursor = struct { } } - fn processsResize(self: *Self, time: u32) void { + fn processsResize(self: Self, time: u32) void { // Resizing the grabbed view can be a little bit complicated, because we // could be resizing from any corner or edge. This not only resizes the view // on one or two axes, but can also move the view if you resize from the top @@ -152,7 +152,7 @@ pub const Cursor = struct { ); } - fn processMotion(self: *Self, time: u32) void { + fn processMotion(self: Self, time: u32) void { // If the mode is non-passthrough, delegate to those functions. if (self.mode == CursorMode.Move) { self.processMove(time); diff --git a/src/output.zig b/src/output.zig index 12fcdc3..25b030d 100644 --- a/src/output.zig +++ b/src/output.zig @@ -107,7 +107,7 @@ pub const Output = struct { _ = c.wlr_output_commit(output.wlr_output); } - fn renderView(self: *Self, view: *View, now: *c.struct_timespec) void { + fn renderView(self: Self, view: *View, now: *c.struct_timespec) void { // If we have a stashed buffer, we are in the middle of a transaction // and need to render that buffer until the transaction is complete. if (view.stashed_buffer) |buffer| { diff --git a/src/root.zig b/src/root.zig index cb5bae6..4246838 100644 --- a/src/root.zig +++ b/src/root.zig @@ -53,7 +53,7 @@ pub const Root = struct { self.pending_count = 0; } - pub fn destroy(self: *Self) void { + pub fn destroy(self: Self) void { c.wlr_output_layout_destroy(self.wlr_output_layout); } @@ -72,7 +72,7 @@ pub const Root = struct { /// Finds the topmost view under the output layout coordinates lx, ly /// returns the view if found, and a pointer to the wlr_surface as well as the surface coordinates - pub fn viewAt(self: *Self, lx: f64, ly: f64, surface: *?*c.wlr_surface, sx: *f64, sy: *f64) ?*View { + pub fn viewAt(self: Self, lx: f64, ly: f64, surface: *?*c.wlr_surface, sx: *f64, sy: *f64) ?*View { var it = self.views.last; while (it) |node| : (it = node.prev) { if (node.data.isAt(lx, ly, surface, sx, sy)) { @@ -84,7 +84,7 @@ pub const Root = struct { /// Focus the next view in the stack, wrapping if needed. Does nothing /// if there is only one view in the stack. - pub fn focusNextView(self: *Self) void { + pub fn focusNextView(self: Self) void { if (self.focused_view) |current_focus| { // If there is a currently focused view, focus the next view in the stack. const node = @fieldParentPtr(std.TailQueue(View).Node, "data", current_focus); @@ -104,7 +104,7 @@ pub const Root = struct { /// Focus the previous view in the stack, wrapping if needed. Does nothing /// if there is only one view in the stack. - pub fn focusPrevView(self: *Self) void { + pub fn focusPrevView(self: Self) void { if (self.focused_view) |current_focus| { // If there is a currently focused view, focus the previous view in the stack. const node = @fieldParentPtr(std.TailQueue(View).Node, "data", current_focus); diff --git a/src/seat.zig b/src/seat.zig index 3e753ec..a55f128 100644 --- a/src/seat.zig +++ b/src/seat.zig @@ -37,7 +37,7 @@ pub const Seat = struct { c.wl_signal_add(&self.server.wlr_backend.events.new_input, &self.listen_new_input); } - pub fn destroy(self: *Self) void { + pub fn destroy(self: Self) void { self.cursor.destroy(); } @@ -49,7 +49,7 @@ pub const Seat = struct { self.keyboards.append(node); } - fn addPointer(self: *Self, device: *c.struct_wlr_input_device) void { + fn addPointer(self: Self, device: *c.struct_wlr_input_device) void { // We don't do anything special with pointers. All of our pointer handling // is proxied through wlr_cursor. On another compositor, you might take this // opportunity to do libinput configuration on the device to set diff --git a/src/server.zig b/src/server.zig index 7281ae8..266640f 100644 --- a/src/server.zig +++ b/src/server.zig @@ -76,7 +76,7 @@ pub const Server = struct { } /// Free allocated memory and clean up - pub fn destroy(self: *Self) void { + pub fn destroy(self: Self) void { c.wl_display_destroy_clients(self.wl_display); c.wl_display_destroy(self.wl_display); self.root.destroy(); diff --git a/src/view.zig b/src/view.zig index 62f5b60..55f198b 100644 --- a/src/view.zig +++ b/src/view.zig @@ -69,7 +69,7 @@ pub const View = struct { // c.wl_signal_add(&toplevel.events.request_resize, &view.request_resize); } - pub fn needsConfigure(self: *const Self) bool { + pub fn needsConfigure(self: Self) bool { return self.pending_state.width != self.current_state.width or self.pending_state.height != self.current_state.height; } @@ -82,7 +82,7 @@ pub const View = struct { ); } - pub fn sendFrameDone(self: *Self) void { + pub fn sendFrameDone(self: Self) void { var now: c.struct_timespec = undefined; _ = c.clock_gettime(c.CLOCK_MONOTONIC, &now); c.wlr_surface_send_frame_done(self.wlr_xdg_surface.surface, &now); @@ -211,7 +211,7 @@ pub const View = struct { ); } - fn isAt(self: *Self, lx: f64, ly: f64, surface: *?*c.wlr_surface, sx: *f64, sy: *f64) bool { + fn isAt(self: Self, lx: f64, ly: f64, surface: *?*c.wlr_surface, sx: *f64, sy: *f64) bool { // XDG toplevels may have nested surfaces, such as popup windows for context // menus or tooltips. This function tests if any of those are underneath the // coordinates lx and ly (in output Layout Coordinates). If so, it sets the