git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit81ffccf8d6e837f5441f23d8a11b7c32a19af7c4
parent4b11e3b7b1
authorIsaac Freund <[email protected]>
date2025-12-23 15:16
river: remove dead switch input device code

This can be re-added when supported by the rwm protocol.

 river/Config.zig       |  6 ----
 river/InputDevice.zig  |  8 +----
 river/InputManager.zig |  1 -
 river/Seat.zig         | 23 +-----------
 river/Switch.zig       | 98 --------------------------------------------------
 5 files changed, 2 insertions(+), 134 deletions(-)

diff --git a/river/Config.zig b/river/Config.zig
index dcde0f1..73fe9b4 100644
--- a/river/Config.zig
+++ b/river/Config.zig
@@ -26,16 +26,10 @@ const server = &@import("main.zig").server;
 const util = @import("util.zig");
 
 const Server = @import("Server.zig");
-const Switch = @import("Switch.zig");
 
 /// Color of background in RGBA with premultiplied alpha (alpha should only affect nested sessions)
 background_color: [4]f32 = [_]f32{ 0.0, 0.16862745, 0.21176471, 1.0 }, // Solarized base03
 
-switch_mappings: std.ArrayListUnmanaged(struct {
-    switch_type: Switch.Type,
-    switch_state: Switch.State,
-}) = .{},
-
 /// Keyboard repeat rate in characters per second
 repeat_rate: u31 = 25,
 
diff --git a/river/InputDevice.zig b/river/InputDevice.zig
index 7629755..48d9ecc 100644
--- a/river/InputDevice.zig
+++ b/river/InputDevice.zig
@@ -30,7 +30,6 @@ const util = @import("util.zig");
 
 const Seat = @import("Seat.zig");
 const Keyboard = @import("Keyboard.zig");
-const Switch = @import("Switch.zig");
 const Tablet = @import("Tablet.zig");
 
 const log = std.log.scoped(.input);
@@ -134,11 +133,6 @@ fn handleDestroy(listener: *wl.Listener(*wlr.InputDevice), _: *wlr.InputDevice)
             const tablet: *Tablet = @fieldParentPtr("device", device);
             tablet.destroy();
         },
-        .@"switch" => {
-            const switch_device: *Switch = @fieldParentPtr("device", device);
-            switch_device.deinit();
-            util.gpa.destroy(switch_device);
-        },
-        .tablet_pad => unreachable,
+        .@"switch", .tablet_pad => unreachable,
     }
 }
diff --git a/river/InputManager.zig b/river/InputManager.zig
index 3025876..cdecaa4 100644
--- a/river/InputManager.zig
+++ b/river/InputManager.zig
@@ -34,7 +34,6 @@ const InputRelay = @import("InputRelay.zig");
 const Keyboard = @import("Keyboard.zig");
 const PointerConstraint = @import("PointerConstraint.zig");
 const Seat = @import("Seat.zig");
-const Switch = @import("Switch.zig");
 const TextInput = @import("TextInput.zig");
 
 const default_seat_name = "default";
diff --git a/river/Seat.zig b/river/Seat.zig
index 2993724..8f8da4c 100644
--- a/river/Seat.zig
+++ b/river/Seat.zig
@@ -44,7 +44,6 @@ const Output = @import("Output.zig");
 const PointerBinding = @import("PointerBinding.zig");
 const PointerConstraint = @import("PointerConstraint.zig");
 const ShellSurface = @import("ShellSurface.zig");
-const Switch = @import("Switch.zig");
 const Tablet = @import("Tablet.zig");
 const Window = @import("Window.zig");
 const XkbBinding = @import("XkbBinding.zig");
@@ -722,19 +721,6 @@ pub fn matchPointerBinding(
     return found;
 }
 
-/// Handle any user-defined mapping for switches
-pub fn handleSwitchMapping(
-    _: *Seat,
-    switch_type: Switch.Type,
-    switch_state: Switch.State,
-) void {
-    for (server.config.switch_mappings.items) |mapping| {
-        if (std.meta.eql(mapping.switch_type, switch_type) and std.meta.eql(mapping.switch_state, switch_state)) {
-            // send trigger
-        }
-    }
-}
-
 pub fn opUpdate(seat: *Seat, x: i32, y: i32) void {
     const op = &seat.op.?;
     op.x = x;
@@ -780,15 +766,8 @@ fn tryAddDevice(seat: *Seat, wlr_device: *wlr.InputDevice, virtual: bool) !void
             try Tablet.create(seat, wlr_device);
             seat.cursor.wlr_cursor.attachInputDevice(wlr_device);
         },
-        .@"switch" => {
-            const switch_device = try util.gpa.create(Switch);
-            errdefer util.gpa.destroy(switch_device);
-
-            try switch_device.init(seat, wlr_device);
-        },
-
         // TODO Support these types of input devices.
-        .tablet_pad => {},
+        .@"switch", .tablet_pad => {},
     }
 }
 
diff --git a/river/Switch.zig b/river/Switch.zig
deleted file mode 100644
index a441345..0000000
--- a/river/Switch.zig
+++ /dev/null
@@ -1,98 +0,0 @@
-// This file is part of river, a dynamic tiling wayland compositor.
-//
-// Copyright 2022 The River Developers
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, version 3.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-const Switch = @This();
-
-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");
-const InputDevice = @import("InputDevice.zig");
-
-const log = std.log.scoped(.input);
-
-pub const Type = enum {
-    lid,
-    tablet,
-};
-
-pub const State = union(Type) {
-    lid: LidState,
-    tablet: TabletState,
-};
-
-pub const LidState = enum {
-    open,
-    close,
-};
-
-pub const TabletState = enum {
-    off,
-    on,
-};
-
-device: InputDevice,
-
-toggle: wl.Listener(*wlr.Switch.event.Toggle) = .init(handleToggle),
-
-pub fn init(switch_device: *Switch, seat: *Seat, wlr_device: *wlr.InputDevice) !void {
-    switch_device.* = .{
-        .device = undefined,
-    };
-    try switch_device.device.init(seat, wlr_device);
-    errdefer switch_device.device.deinit();
-
-    wlr_device.toSwitch().events.toggle.add(&switch_device.toggle);
-}
-
-pub fn deinit(switch_device: *Switch) void {
-    switch_device.toggle.link.remove();
-
-    switch_device.device.deinit();
-
-    switch_device.* = undefined;
-}
-
-fn handleToggle(listener: *wl.Listener(*wlr.Switch.event.Toggle), event: *wlr.Switch.event.Toggle) void {
-    const switch_device: *Switch = @fieldParentPtr("toggle", listener);
-
-    switch_device.device.seat.handleActivity();
-
-    var switch_type: Type = undefined;
-    var switch_state: State = undefined;
-    switch (event.switch_type) {
-        .lid => {
-            switch_type = .lid;
-            switch_state = switch (event.switch_state) {
-                .off => .{ .lid = .open },
-                .on => .{ .lid = .close },
-            };
-        },
-        .tablet_mode => {
-            switch_type = .tablet;
-            switch_state = switch (event.switch_state) {
-                .off => .{ .tablet = .off },
-                .on => .{ .tablet = .on },
-            };
-        },
-    }
-
-    switch_device.device.seat.handleSwitchMapping(switch_type, switch_state);
-}