Implement libinput device configuration

We need to defer config application to the first manage_start event
using a should_manage flag so that all *_support events have arrived
before we try applying the configs

This commit also has two other fixes
- fixes a potential use-after-free by telling InputDevice when a
 LibinputDevice is .removed.
- fix logFn (removed "if (scope != .default) return;")

I used kwm to help figure out the manage pattern for the input config.
Link to kwm: https://github.com/kewuaa/kwm
This commit is contained in:
Ben Buhse 2026-02-10 20:06:17 -06:00
commit 296f875993
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
5 changed files with 184 additions and 22 deletions

View file

@ -112,6 +112,12 @@ pub fn manage(context: *Context) void {
context.config = new_config;
context.initialized = false;
// Mark all libinput devices as needing config re-application
var dev_it = context.im.libinput_devices.iterator(.forward);
while (dev_it.next()) |libinput_device| {
libinput_device.should_manage = true;
}
if (wallpaper_changed) {
if (context.wallpaper_image) |img| img.destroy();
context.wallpaper_image = loadWallpaperImage(new_config);
@ -132,6 +138,12 @@ pub fn manage(context: *Context) void {
}
}
}
// Apply input configs for new or reconfigured devices
var dev_it = context.im.libinput_devices.iterator(.forward);
while (dev_it.next()) |libinput_device| {
libinput_device.manage();
}
}
fn loadWallpaperImage(config: *Config) ?*WallpaperImage {