From c8b101792331801bc48978f62540293768a394aa Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 13 May 2021 15:13:17 +0200 Subject: [PATCH] river: remove Seat.input_manager This is no longer needed as server is global. --- river/Cursor.zig | 6 +++--- river/InputManager.zig | 2 +- river/Seat.zig | 10 ++++------ river/command/move.zig | 2 +- river/command/toggle_float.zig | 4 +++- river/command/toggle_fullscreen.zig | 4 +++- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/river/Cursor.zig b/river/Cursor.zig index 73dff78..0884009 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -154,7 +154,7 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void { // If this cursor belongs to the default seat, set the xcursor environment // variables and the xwayland cursor theme. - if (self.seat == self.seat.input_manager.defaultSeat()) { + if (self.seat == server.input_manager.defaultSeat()) { const size_str = try std.fmt.allocPrint0(util.gpa, "{}", .{size}); defer util.gpa.free(size_str); if (c.setenv("XCURSOR_SIZE", size_str, 1) < 0) return error.OutOfMemory; @@ -586,7 +586,7 @@ fn leaveMode(self: *Self, event: *wlr.Pointer.event.Button) void { } fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64, delta_y: f64, unaccel_dx: f64, unaccel_dy: f64) void { - self.seat.input_manager.relative_pointer_manager.sendRelativeMotion( + server.input_manager.relative_pointer_manager.sendRelativeMotion( self.seat.wlr_seat, @as(u64, time) * 1000, delta_x, @@ -674,7 +674,7 @@ fn passthrough(self: *Self, time: u32) void { // If input is allowed on the surface, send pointer enter and motion // events. Note that wlroots won't actually send an enter event if // the surface has already been entered. - if (self.seat.input_manager.inputAllowed(surface)) { + if (server.input_manager.inputAllowed(surface)) { // The focus change must be checked before sending enter events const focus_change = self.seat.wlr_seat.pointer_state.focused_surface != surface; diff --git a/river/InputManager.zig b/river/InputManager.zig index 21258c7..2eb0237 100644 --- a/river/InputManager.zig +++ b/river/InputManager.zig @@ -75,7 +75,7 @@ pub fn init(self: *Self) !void { }; self.seats.prepend(seat_node); - try seat_node.data.init(self, default_seat_name); + try seat_node.data.init(default_seat_name); if (build_options.xwayland) server.xwayland.setSeat(self.defaultSeat().wlr_seat); diff --git a/river/Seat.zig b/river/Seat.zig index f085e1a..10ae97b 100644 --- a/river/Seat.zig +++ b/river/Seat.zig @@ -46,7 +46,6 @@ const FocusTarget = union(enum) { none: void, }; -input_manager: *InputManager, wlr_seat: *wlr.Seat, /// Multiple mice are handled by the same Cursor @@ -85,9 +84,8 @@ request_set_primary_selection: wl.Listener(*wlr.Seat.event.RequestSetPrimarySele wl.Listener(*wlr.Seat.event.RequestSetPrimarySelection).init(handleRequestSetPrimarySelection), // zig fmt: on -pub fn init(self: *Self, input_manager: *InputManager, name: [*:0]const u8) !void { +pub fn init(self: *Self, name: [*:0]const u8) !void { self.* = .{ - .input_manager = input_manager, // This will be automatically destroyed when the display is destroyed .wlr_seat = try wlr.Seat.create(server.wl_server, name), .focused_output = &server.root.noop_output, @@ -194,7 +192,7 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void { // If input is not allowed on the target surface (e.g. due to an active // input inhibitor) do not set focus. If there is no target surface we // still clear the focus. - if (if (target_surface) |wlr_surface| self.input_manager.inputAllowed(wlr_surface) else true) { + if (if (target_surface) |wlr_surface| server.input_manager.inputAllowed(wlr_surface) else true) { // First clear the current focus if (self.focused == .view) { self.focused.view.pending.focus -= 1; @@ -238,7 +236,7 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void { self.wlr_seat.keyboardNotifyEnter(wlr_surface, null, 0, null); } - if (self.input_manager.pointer_constraints.constraintForSurface(wlr_surface, self.wlr_seat)) |constraint| { + if (server.input_manager.pointer_constraints.constraintForSurface(wlr_surface, self.wlr_seat)) |constraint| { @intToPtr(*PointerConstraint, constraint.data).setAsActive(); } else if (self.cursor.constraint) |constraint| { PointerConstraint.warpToHint(&self.cursor); @@ -275,7 +273,7 @@ pub fn focusOutput(self: *Self, output: *Output) void { } pub fn handleActivity(self: Self) void { - self.input_manager.idle.notifyActivity(self.wlr_seat); + server.input_manager.idle.notifyActivity(self.wlr_seat); } /// Handle the unmapping of a view, removing it from the focus stack and diff --git a/river/command/move.zig b/river/command/move.zig index 245b4b3..cb8e771 100644 --- a/river/command/move.zig +++ b/river/command/move.zig @@ -156,7 +156,7 @@ fn getView(seat: *Seat) ?*View { if (view.pending.fullscreen) return null; // Do not touch views which are the target of a cursor action - if (seat.input_manager.isCursorActionTarget(view)) return null; + if (server.input_manager.isCursorActionTarget(view)) return null; return view; } diff --git a/river/command/toggle_float.zig b/river/command/toggle_float.zig index f8a7b22..c6bc9eb 100644 --- a/river/command/toggle_float.zig +++ b/river/command/toggle_float.zig @@ -17,6 +17,8 @@ const std = @import("std"); +const server = &@import("../main.zig").server; + const Error = @import("../command.zig").Error; const Seat = @import("../Seat.zig"); @@ -43,7 +45,7 @@ pub fn toggleFloat( if (view.pending.fullscreen) return; // Don't modify views which are the target of a cursor action - if (seat.input_manager.isCursorActionTarget(view)) return; + if (server.input_manager.isCursorActionTarget(view)) return; view.pending.float = !view.pending.float; view.applyPending(); diff --git a/river/command/toggle_fullscreen.zig b/river/command/toggle_fullscreen.zig index da8d7b6..f6a32d2 100644 --- a/river/command/toggle_fullscreen.zig +++ b/river/command/toggle_fullscreen.zig @@ -17,6 +17,8 @@ const std = @import("std"); +const server = &@import("../main.zig").server; + const Box = @import("../Box.zig"); const Error = @import("../command.zig").Error; const Seat = @import("../Seat.zig"); @@ -34,7 +36,7 @@ pub fn toggleFullscreen( const view = seat.focused.view; // Don't modify views which are the target of a cursor action - if (seat.input_manager.isCursorActionTarget(view)) return; + if (server.input_manager.isCursorActionTarget(view)) return; view.pending.fullscreen = !view.pending.fullscreen; view.applyPending();