From ece465b7ed4314285c2b18be48f139ec37ee0d16 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 13 May 2021 14:53:08 +0200 Subject: [PATCH] river: remove InputManager.server The server is now global so this is no longer needed. --- river/Cursor.zig | 22 ++++++++-------------- river/DragIcon.zig | 4 ++-- river/InputManager.zig | 9 ++++----- river/Keyboard.zig | 9 ++++----- river/Seat.zig | 15 +++++++-------- river/Server.zig | 2 +- river/command/config.zig | 9 +++++---- river/command/declare_mode.zig | 3 ++- river/command/enter_mode.zig | 5 +++-- river/command/exit.zig | 4 +++- river/command/filter.zig | 5 +++-- river/command/focus_follows_cursor.zig | 3 +-- river/command/focus_output.zig | 13 +++++++------ river/command/layout.zig | 3 ++- river/command/map.zig | 11 ++++++----- river/command/opacity.zig | 4 ++-- river/command/send_to_output.zig | 13 +++++++------ river/command/set_repeat.zig | 7 ++++--- 18 files changed, 71 insertions(+), 70 deletions(-) diff --git a/river/Cursor.zig b/river/Cursor.zig index 27d9ec5..73dff78 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -94,7 +94,7 @@ swipe_end: wl.Listener(*wlr.Pointer.event.SwipeEnd) = pub fn init(self: *Self, seat: *Seat) !void { const wlr_cursor = try wlr.Cursor.create(); errdefer wlr_cursor.destroy(); - wlr_cursor.attachOutputLayout(seat.input_manager.server.root.output_layout); + wlr_cursor.attachOutputLayout(server.root.output_layout); // This is here so that self.xcursor_manager doesn't need to be an // optional pointer. This isn't optimal as it does a needless allocation, @@ -105,7 +105,7 @@ pub fn init(self: *Self, seat: *Seat) !void { self.* = .{ .seat = seat, .wlr_cursor = wlr_cursor, - .pointer_gestures = try wlr.PointerGesturesV1.create(seat.input_manager.server.wl_server), + .pointer_gestures = try wlr.PointerGesturesV1.create(server.wl_server), .xcursor_manager = xcursor_manager, }; try self.setTheme(null, null); @@ -346,8 +346,7 @@ fn handlePointerMapping(self: *Self, event: *wlr.Pointer.event.Button, view: *Vi const fullscreen = view.current.fullscreen or view.pending.fullscreen; - const config = self.seat.input_manager.server.config; - return for (config.modes.items[self.seat.mode_id].pointer_mappings.items) |mapping| { + return for (server.config.modes.items[self.seat.mode_id].pointer_mappings.items) |mapping| { if (event.button == mapping.event_code and std.meta.eql(modifiers, mapping.modifiers)) { switch (mapping.action) { .move => if (!fullscreen) self.enterMode(.move, view), @@ -427,14 +426,13 @@ fn handleRequestSetCursor( /// surface coordinates. /// This function must be kept in sync with the rendering order in render.zig. fn surfaceAt(self: Self, lx: f64, ly: f64, sx: *f64, sy: *f64) ?*wlr.Surface { - const root = self.seat.input_manager.server.root; - const wlr_output = root.output_layout.outputAt(lx, ly) orelse return null; + const wlr_output = server.root.output_layout.outputAt(lx, ly) orelse return null; const output = @intToPtr(*Output, wlr_output.data); // Get output-local coords from the layout coords var ox = lx; var oy = ly; - root.output_layout.outputCoords(wlr_output, &ox, &oy); + server.root.output_layout.outputCoords(wlr_output, &ox, &oy); // Check surfaces in the reverse order they are rendered in: // 1. overlay layer (+ popups) @@ -643,8 +641,7 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64, view.applyPending(); }, .resize => |data| { - const config = &self.seat.input_manager.server.config; - const border_width = if (data.view.draw_borders) config.border_width else 0; + const border_width = if (data.view.draw_borders) server.config.border_width else 0; // Set width/height of view, clamp to view size constraints and output dimensions const box = &data.view.pending.box; @@ -671,9 +668,6 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64, /// Pass an event on to the surface under the cursor, if any. fn passthrough(self: *Self, time: u32) void { - const root = &self.seat.input_manager.server.root; - const config = self.seat.input_manager.server.config; - var sx: f64 = undefined; var sy: f64 = undefined; if (self.surfaceAt(self.wlr_cursor.x, self.wlr_cursor.y, &sx, &sy)) |surface| { @@ -687,12 +681,12 @@ fn passthrough(self: *Self, time: u32) void { self.seat.wlr_seat.pointerNotifyEnter(surface, sx, sy); self.seat.wlr_seat.pointerNotifyMotion(time, sx, sy); - const follow_mode = config.focus_follows_cursor; + const follow_mode = server.config.focus_follows_cursor; if (follow_mode == .strict or (follow_mode == .normal and focus_change)) { if (View.fromWlrSurface(surface)) |view| { self.seat.focusOutput(view.output); self.seat.focus(view); - root.startTransaction(); + server.root.startTransaction(); } } } diff --git a/river/DragIcon.zig b/river/DragIcon.zig index ee9cc91..3ab4c34 100644 --- a/river/DragIcon.zig +++ b/river/DragIcon.zig @@ -21,6 +21,7 @@ const std = @import("std"); const wlr = @import("wlroots"); const wl = @import("wayland").server.wl; +const server = &@import("main.zig").server; const util = @import("util.zig"); const Seat = @import("Seat.zig"); @@ -37,8 +38,7 @@ pub fn init(self: *Self, seat: *Seat, wlr_drag_icon: *wlr.Drag.Icon) void { fn handleDestroy(listener: *wl.Listener(*wlr.Drag.Icon), wlr_drag_icon: *wlr.Drag.Icon) void { const self = @fieldParentPtr(Self, "destroy", listener); - const root = &self.seat.input_manager.server.root; const node = @fieldParentPtr(std.SinglyLinkedList(Self).Node, "data", self); - root.drag_icons.remove(node); + server.root.drag_icons.remove(node); util.gpa.destroy(node); } diff --git a/river/InputManager.zig b/river/InputManager.zig index b65d78a..21258c7 100644 --- a/river/InputManager.zig +++ b/river/InputManager.zig @@ -22,6 +22,7 @@ const std = @import("std"); const wlr = @import("wlroots"); const wl = @import("wayland").server.wl; +const server = &@import("main.zig").server; const util = @import("util.zig"); const Seat = @import("Seat.zig"); @@ -33,7 +34,6 @@ const default_seat_name = "default"; const log = std.log.scoped(.input_manager); -server: *Server, new_input: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(handleNewInput), idle: *wlr.Idle, @@ -60,12 +60,11 @@ new_virtual_keyboard: wl.Listener(*wlr.VirtualKeyboardV1) = wl.Listener(*wlr.VirtualKeyboardV1).init(handleNewVirtualKeyboard), // zig fmt: on -pub fn init(self: *Self, server: *Server) !void { +pub fn init(self: *Self) !void { const seat_node = try util.gpa.create(std.TailQueue(Seat).Node); errdefer util.gpa.destroy(seat_node); self.* = .{ - .server = server, // These are automatically freed when the display is destroyed .idle = try wlr.Idle.create(server.wl_server), .input_inhibit_manager = try wlr.InputInhibitManager.create(server.wl_server), @@ -156,7 +155,7 @@ fn handleInhibitDeactivate( // Calling arrangeLayers() like this ensures that any top or overlay, // keyboard-interactive surfaces will re-grab focus. - var output_it = self.server.root.outputs.first; + var output_it = server.root.outputs.first; while (output_it) |output_node| : (output_it = output_node.next) { output_node.data.arrangeLayers(); } @@ -169,7 +168,7 @@ fn handleInhibitDeactivate( seat_node.data.mode_id = seat_node.data.prev_mode_id; } - self.server.root.startTransaction(); + server.root.startTransaction(); } /// This event is raised by the backend when a new input device becomes available. diff --git a/river/Keyboard.zig b/river/Keyboard.zig index 3642061..f0a9d71 100644 --- a/river/Keyboard.zig +++ b/river/Keyboard.zig @@ -22,6 +22,7 @@ const wlr = @import("wlroots"); const wl = @import("wayland").server.wl; const xkb = @import("xkbcommon"); +const server = &@import("main.zig").server; const util = @import("util.zig"); const Seat = @import("Seat.zig"); @@ -60,8 +61,7 @@ pub fn init(self: *Self, seat: *Seat, input_device: *wlr.InputDevice) !void { if (!wlr_keyboard.setKeymap(keymap)) return error.SetKeymapFailed; - const config = &seat.input_manager.server.config; - wlr_keyboard.setRepeatInfo(config.repeat_rate, config.repeat_delay); + wlr_keyboard.setRepeatInfo(server.config.repeat_rate, server.config.repeat_delay); wlr_keyboard.events.key.add(&self.key); wlr_keyboard.events.modifiers.add(&self.modifiers); @@ -149,9 +149,8 @@ fn handleBuiltinMapping(self: Self, keysym: xkb.Keysym) bool { switch (@enumToInt(keysym)) { @enumToInt(xkb.Keysym.XF86Switch_VT_1)...@enumToInt(xkb.Keysym.XF86Switch_VT_12) => { log.debug("switch VT keysym received", .{}); - const backend = self.seat.input_manager.server.backend; - if (backend.isMulti()) { - if (backend.getSession()) |session| { + if (server.backend.isMulti()) { + if (server.backend.getSession()) |session| { const vt = @enumToInt(keysym) - @enumToInt(xkb.Keysym.XF86Switch_VT_1) + 1; const log_server = std.log.scoped(.server); log_server.notice("switching to VT {}", .{vt}); diff --git a/river/Seat.zig b/river/Seat.zig index bfdac9c..f085e1a 100644 --- a/river/Seat.zig +++ b/river/Seat.zig @@ -24,6 +24,7 @@ const wl = @import("wayland").server.wl; const xkb = @import("xkbcommon"); const command = @import("command.zig"); +const server = &@import("main.zig").server; const util = @import("util.zig"); const DragIcon = @import("DragIcon.zig"); @@ -88,8 +89,8 @@ pub fn init(self: *Self, input_manager: *InputManager, name: [*:0]const u8) !voi self.* = .{ .input_manager = input_manager, // This will be automatically destroyed when the display is destroyed - .wlr_seat = try wlr.Seat.create(input_manager.server.wl_server, name), - .focused_output = &self.input_manager.server.root.noop_output, + .wlr_seat = try wlr.Seat.create(server.wl_server, name), + .focused_output = &server.root.noop_output, }; self.wlr_seat.data = @ptrToInt(self); @@ -202,7 +203,7 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void { if (build_options.xwayland and self.focused.view.impl == .xwayland_view) self.focused.view.impl.xwayland_view.xwayland_surface.activate(false); if (self.focused.view.pending.focus == 0 and !self.focused.view.pending.fullscreen) { - self.focused.view.pending.target_opacity = self.input_manager.server.config.opacity.unfocused; + self.focused.view.pending.target_opacity = server.config.opacity.unfocused; } } @@ -216,7 +217,7 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void { if (build_options.xwayland and target_view.impl == .xwayland_view) target_view.impl.xwayland_view.xwayland_surface.activate(true); if (!target_view.pending.fullscreen) { - target_view.pending.target_opacity = self.input_manager.server.config.opacity.focused; + target_view.pending.target_opacity = server.config.opacity.focused; } }, .layer => |target_layer| std.debug.assert(self.focused_output == target_layer.output), @@ -264,8 +265,6 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void { pub fn focusOutput(self: *Self, output: *Output) void { if (self.focused_output == output) return; - const root = &self.input_manager.server.root; - var it = self.status_trackers.first; while (it) |node| : (it = node.next) node.data.sendOutput(.unfocused); @@ -306,7 +305,7 @@ pub fn handleMapping( modifiers: wlr.Keyboard.ModifierMask, released: bool, ) bool { - const modes = &self.input_manager.server.config.modes; + const modes = &server.config.modes; for (modes.items[self.mode_id].mappings.items) |mapping| { if (std.meta.eql(modifiers, mapping.modifiers) and keysym == mapping.keysym and released == mapping.release) { // Execute the bound command @@ -409,7 +408,7 @@ fn handleStartDrag( return; }; node.data.init(self, wlr_drag_icon); - self.input_manager.server.root.drag_icons.prepend(node); + server.root.drag_icons.prepend(node); } self.cursor.mode = .passthrough; } diff --git a/river/Server.zig b/river/Server.zig index d7ed2c4..db9e239 100644 --- a/river/Server.zig +++ b/river/Server.zig @@ -115,7 +115,7 @@ pub fn init(self: *Self) !void { try self.decoration_manager.init(self); try self.root.init(); // Must be called after root is initialized - try self.input_manager.init(self); + try self.input_manager.init(); try self.control.init(self); try self.status_manager.init(self); try self.layout_manager.init(self); diff --git a/river/command/config.zig b/river/command/config.zig index d881c2c..fd71761 100644 --- a/river/command/config.zig +++ b/river/command/config.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"); @@ -29,7 +31,6 @@ pub fn borderWidth( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - const server = seat.input_manager.server; server.config.border_width = try std.fmt.parseInt(u32, args[1], 10); server.root.arrangeAll(); server.root.startTransaction(); @@ -44,7 +45,7 @@ pub fn backgroundColor( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - seat.input_manager.server.config.background_color = try parseRgba(args[1]); + server.config.background_color = try parseRgba(args[1]); } pub fn borderColorFocused( @@ -56,7 +57,7 @@ pub fn borderColorFocused( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - seat.input_manager.server.config.border_color_focused = try parseRgba(args[1]); + server.config.border_color_focused = try parseRgba(args[1]); } pub fn borderColorUnfocused( @@ -68,7 +69,7 @@ pub fn borderColorUnfocused( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - seat.input_manager.server.config.border_color_unfocused = try parseRgba(args[1]); + server.config.border_color_unfocused = try parseRgba(args[1]); } /// Parse a color in the format #RRGGBB or #RRGGBBAA diff --git a/river/command/declare_mode.zig b/river/command/declare_mode.zig index 36634aa..a889bdc 100644 --- a/river/command/declare_mode.zig +++ b/river/command/declare_mode.zig @@ -17,6 +17,7 @@ const std = @import("std"); +const server = &@import("../main.zig").server; const util = @import("../util.zig"); const Mode = @import("../Mode.zig"); @@ -34,7 +35,7 @@ pub fn declareMode( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - const config = &seat.input_manager.server.config; + const config = &server.config; const new_mode_name = args[1]; if (config.mode_to_id.get(new_mode_name) != null) return; diff --git a/river/command/enter_mode.zig b/river/command/enter_mode.zig index 41077fe..1fcd81f 100644 --- a/river/command/enter_mode.zig +++ b/river/command/enter_mode.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"); @@ -39,9 +41,8 @@ pub fn enterMode( return Error.Other; } - const config = seat.input_manager.server.config; const target_mode = args[1]; - const mode_id = config.mode_to_id.get(target_mode) orelse { + const mode_id = server.config.mode_to_id.get(target_mode) orelse { out.* = try std.fmt.allocPrint( allocator, "cannot enter non-existant mode '{}'", diff --git a/river/command/exit.zig b/river/command/exit.zig index 129a247..eb0d74d 100644 --- a/river/command/exit.zig +++ b/river/command/exit.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"); @@ -28,5 +30,5 @@ pub fn exit( out: *?[]const u8, ) Error!void { if (args.len > 1) return Error.TooManyArguments; - seat.input_manager.server.wl_server.terminate(); + server.wl_server.terminate(); } diff --git a/river/command/filter.zig b/river/command/filter.zig index cf3a47b..240f1d1 100644 --- a/river/command/filter.zig +++ b/river/command/filter.zig @@ -17,6 +17,7 @@ const std = @import("std"); +const server = &@import("../main.zig").server; const util = @import("../util.zig"); const Error = @import("../command.zig").Error; @@ -40,7 +41,7 @@ pub fn floatFilterAdd( ) Error!void { try appendFilter( allocator, - &seat.input_manager.server.config.float_filter, + &server.config.float_filter, args, ); } @@ -53,7 +54,7 @@ pub fn csdFilterAdd( ) Error!void { try appendFilter( allocator, - &seat.input_manager.server.config.csd_filter, + &server.config.csd_filter, args, ); } diff --git a/river/command/focus_follows_cursor.zig b/river/command/focus_follows_cursor.zig index b7744b1..fbc1500 100644 --- a/river/command/focus_follows_cursor.zig +++ b/river/command/focus_follows_cursor.zig @@ -17,6 +17,7 @@ const std = @import("std"); +const server = &@import("../main.zig").server; const util = @import("../util.zig"); const Config = @import("../Config.zig"); @@ -32,8 +33,6 @@ pub fn focusFollowsCursor( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - const server = seat.input_manager.server; - server.config.focus_follows_cursor = std.meta.stringToEnum(Config.FocusFollowsCursorMode, args[1]) orelse return Error.UnknownOption; } diff --git a/river/command/focus_output.zig b/river/command/focus_output.zig index a2cfd5b..6d0f088 100644 --- a/river/command/focus_output.zig +++ b/river/command/focus_output.zig @@ -17,6 +17,8 @@ const std = @import("std"); +const server = &@import("../main.zig").server; + const Direction = @import("../command.zig").Direction; const Error = @import("../command.zig").Error; const Output = @import("../Output.zig"); @@ -34,21 +36,20 @@ pub fn focusOutput( if (args.len > 2) return Error.TooManyArguments; const direction = std.meta.stringToEnum(Direction, args[1]) orelse return Error.InvalidDirection; - const root = &seat.input_manager.server.root; // If the noop output is focused, there are no other outputs to switch to - if (seat.focused_output == &root.noop_output) { - std.debug.assert(root.outputs.len == 0); + if (seat.focused_output == &server.root.noop_output) { + std.debug.assert(server.root.outputs.len == 0); return; } // Focus the next/prev output in the list if there is one, else wrap const focused_node = @fieldParentPtr(std.TailQueue(Output).Node, "data", seat.focused_output); seat.focusOutput(switch (direction) { - .next => if (focused_node.next) |node| &node.data else &root.outputs.first.?.data, - .previous => if (focused_node.prev) |node| &node.data else &root.outputs.last.?.data, + .next => if (focused_node.next) |node| &node.data else &server.root.outputs.first.?.data, + .previous => if (focused_node.prev) |node| &node.data else &server.root.outputs.last.?.data, }); seat.focus(null); - root.startTransaction(); + server.root.startTransaction(); } diff --git a/river/command/layout.zig b/river/command/layout.zig index dcef1da..710b59a 100644 --- a/river/command/layout.zig +++ b/river/command/layout.zig @@ -20,6 +20,8 @@ const mem = std.mem; const wl = @import("wayland").server.wl; const util = @import("../util.zig"); +const server = &@import("../main.zig").server; + const Error = @import("../command.zig").Error; const Seat = @import("../Seat.zig"); @@ -46,7 +48,6 @@ pub fn defaultLayout( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - const server = seat.input_manager.server; server.config.default_layout_namespace = try util.gpa.dupe(u8, args[1]); var it = server.root.all_outputs.first; while (it) |node| : (it = node.next) { diff --git a/river/command/map.zig b/river/command/map.zig index 28df44f..eddf7af 100644 --- a/river/command/map.zig +++ b/river/command/map.zig @@ -21,6 +21,7 @@ const wlr = @import("wlroots"); const xkb = @import("xkbcommon"); const c = @import("../c.zig"); +const server = &@import("../main.zig").server; const util = @import("../util.zig"); const Error = @import("../command.zig").Error; @@ -47,7 +48,7 @@ pub fn map( const modifiers = try parseModifiers(allocator, args[2 + offset], out); const keysym = try parseKeysym(allocator, args[3 + offset], out); - const mode_mappings = &seat.input_manager.server.config.modes.items[mode_id].mappings; + const mode_mappings = &server.config.modes.items[mode_id].mappings; const new = try Mapping.init(keysym, modifiers, optionals.release, args[4 + offset ..]); errdefer new.deinit(); @@ -96,7 +97,7 @@ pub fn mapPointer( .action = action, }; - const mode_pointer_mappings = &seat.input_manager.server.config.modes.items[mode_id].pointer_mappings; + const mode_pointer_mappings = &server.config.modes.items[mode_id].pointer_mappings; if (pointerMappingExists(mode_pointer_mappings, modifiers, event_code)) |current| { mode_pointer_mappings.items[current] = new; } else { @@ -105,7 +106,7 @@ pub fn mapPointer( } fn modeNameToId(allocator: *std.mem.Allocator, seat: *Seat, mode_name: []const u8, out: *?[]const u8) !usize { - const config = seat.input_manager.server.config; + const config = &server.config; return config.mode_to_id.get(mode_name) orelse { out.* = try std.fmt.allocPrint( allocator, @@ -255,7 +256,7 @@ pub fn unmap( const modifiers = try parseModifiers(allocator, args[2 + offset], out); const keysym = try parseKeysym(allocator, args[3 + offset], out); - const mode_mappings = &seat.input_manager.server.config.modes.items[mode_id].mappings; + const mode_mappings = &server.config.modes.items[mode_id].mappings; const mapping_idx = mappingExists(mode_mappings, modifiers, keysym, optionals.release) orelse return; var mapping = mode_mappings.swapRemove(mapping_idx); @@ -279,7 +280,7 @@ pub fn unmapPointer( const modifiers = try parseModifiers(allocator, args[2], out); const event_code = try parseEventCode(allocator, args[3], out); - const mode_pointer_mappings = &seat.input_manager.server.config.modes.items[mode_id].pointer_mappings; + const mode_pointer_mappings = &server.config.modes.items[mode_id].pointer_mappings; const mapping_idx = pointerMappingExists(mode_pointer_mappings, modifiers, event_code) orelse return; _ = mode_pointer_mappings.swapRemove(mapping_idx); diff --git a/river/command/opacity.zig b/river/command/opacity.zig index 79ff9bd..92dd5c7 100644 --- a/river/command/opacity.zig +++ b/river/command/opacity.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"); const View = @import("../View.zig"); @@ -36,8 +38,6 @@ pub fn opacity( if (args.len < 6) return Error.NotEnoughArguments; if (args.len > 6) return Error.TooManyArguments; - const server = seat.input_manager.server; - // Focused opacity server.config.opacity.focused = try std.fmt.parseFloat(f32, args[1]); if (server.config.opacity.focused < 0.0 or server.config.opacity.focused > 1.0) diff --git a/river/command/send_to_output.zig b/river/command/send_to_output.zig index 694bcb5..e3ba90b 100644 --- a/river/command/send_to_output.zig +++ b/river/command/send_to_output.zig @@ -17,6 +17,8 @@ const std = @import("std"); +const server = &@import("../main.zig").server; + const Direction = @import("../command.zig").Direction; const Error = @import("../command.zig").Error; const Output = @import("../Output.zig"); @@ -34,20 +36,19 @@ pub fn sendToOutput( if (args.len > 2) return Error.TooManyArguments; const direction = std.meta.stringToEnum(Direction, args[1]) orelse return Error.InvalidDirection; - const root = &seat.input_manager.server.root; if (seat.focused == .view) { // If the noop output is focused, there is nowhere to send the view - if (seat.focused_output == &root.noop_output) { - std.debug.assert(root.outputs.len == 0); + if (seat.focused_output == &server.root.noop_output) { + std.debug.assert(server.root.outputs.len == 0); return; } // Send to the next/prev output in the list if there is one, else wrap const current_node = @fieldParentPtr(std.TailQueue(Output).Node, "data", seat.focused_output); const destination_output = switch (direction) { - .next => if (current_node.next) |node| &node.data else &root.outputs.first.?.data, - .previous => if (current_node.prev) |node| &node.data else &root.outputs.last.?.data, + .next => if (current_node.next) |node| &node.data else &server.root.outputs.first.?.data, + .previous => if (current_node.prev) |node| &node.data else &server.root.outputs.last.?.data, }; // Move the view to the target output @@ -57,6 +58,6 @@ pub fn sendToOutput( seat.focus(null); seat.focused_output.arrangeViews(); destination_output.arrangeViews(); - root.startTransaction(); + server.root.startTransaction(); } } diff --git a/river/command/set_repeat.zig b/river/command/set_repeat.zig index 0c43ed0..a72ae66 100644 --- a/river/command/set_repeat.zig +++ b/river/command/set_repeat.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"); @@ -33,9 +35,8 @@ pub fn setRepeat( const rate = try std.fmt.parseInt(u31, args[1], 10); const delay = try std.fmt.parseInt(u31, args[2], 10); - const config = &seat.input_manager.server.config; - config.repeat_rate = rate; - config.repeat_delay = delay; + server.config.repeat_rate = rate; + server.config.repeat_delay = delay; var it = seat.keyboards.first; while (it) |node| : (it = node.next) {