Pass self as immutable where possible
This commit is contained in:
parent
9d0a41c0d2
commit
f5304237b5
6 changed files with 15 additions and 15 deletions
|
@ -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);
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue