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

commit1bf2dbefb422f422aa847730069c0a4a62b42a1f
parentb4899b82d0
authorIsaac Freund <[email protected]>
date2026-03-10 16:13
InputDevice: fix cleanup

These things are only initialized for non-virtual input devices.
Therefore, only clean them up for non-virtual input devices.

 river/InputDevice.zig | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/river/InputDevice.zig b/river/InputDevice.zig
index 9f53c91..443323a 100644
--- a/river/InputDevice.zig
+++ b/river/InputDevice.zig
@@ -126,11 +126,21 @@ pub fn deinit(device: *InputDevice) void {
     assert(device.objects.empty());
     device.remove.link.remove();
 
-    if (device.wlr_device.getLibinputDevice() != null) {
-        device.libinput.deinit();
-    }
-    if (device.wlr_device.type == .keyboard) {
-        device.xkb_keyboard.deinit();
+    if (!device.virtual) {
+        {
+            var it = device.objects.iterator(.forward);
+            while (it.next()) |object| {
+                object.getLink().remove();
+                object.sendRemoved();
+                object.setHandler(?*anyopaque, handleRequestInert, null, null);
+            }
+        }
+        if (device.wlr_device.getLibinputDevice() != null) {
+            device.libinput.deinit();
+        }
+        if (device.wlr_device.type == .keyboard) {
+            device.xkb_keyboard.deinit();
+        }
     }
 
     device.link.remove();
@@ -158,15 +168,6 @@ fn handleRemove(listener: *wl.Listener(*wlr.InputDevice), _: *wlr.InputDevice) v
         device.wlr_device.name orelse "unknown",
     });
 
-    {
-        var it = device.objects.iterator(.forward);
-        while (it.next()) |object| {
-            object.getLink().remove();
-            object.sendRemoved();
-            object.setHandler(?*anyopaque, handleRequestInert, null, null);
-        }
-    }
-
     switch (device.wlr_device.type) {
         .keyboard => {
             const keyboard: *Keyboard = @fieldParentPtr("device", device);