Skip to content

Commit efcf877

Browse files
committed
Use cosmic-config for input configuration; allow dynamic changes
1 parent 94c89b6 commit efcf877

File tree

5 files changed

+118
-84
lines changed

5 files changed

+118
-84
lines changed

Cargo.lock

Lines changed: 41 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ ron = "0.7"
3030
libsystemd = { version = "0.5", optional = true }
3131
wayland-backend = "0.1.0"
3232
wayland-scanner = "0.30.0"
33+
cosmic-config = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c", features = ["calloop"] }
3334
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = ["server"] }
34-
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "42d7baf", default-features = false }
35-
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "42d7baf" }
35+
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c", default-features = false }
36+
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c" }
3637
tiny-skia = "0.9"
3738
ordered-float = "3.0"
3839
glow = "0.11.2"

src/backend/kms/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use smithay::{
5757
control::{connector, crtc, Device as ControlDevice, ModeTypeFlags},
5858
Device as _,
5959
},
60-
input::Libinput,
60+
input::{self, Libinput},
6161
nix::{fcntl::OFlag, sys::stat::dev_t},
6262
wayland_protocols::wp::{
6363
linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1,
@@ -97,6 +97,7 @@ const MIN_RENDER_TIME: Duration = Duration::from_millis(3);
9797
#[derive(Debug)]
9898
pub struct KmsState {
9999
devices: HashMap<DrmNode, Device>,
100+
pub input_devices: HashMap<String, input::Device>,
100101
pub api: GpuManager<GbmGlesBackend<GlowRenderer>>,
101102
pub primary: DrmNode,
102103
session: LibSeatSession,
@@ -171,8 +172,15 @@ pub fn init_backend(
171172
let libinput_event_source = event_loop
172173
.handle()
173174
.insert_source(libinput_backend, move |mut event, _, data| {
174-
if let &mut InputEvent::DeviceAdded { ref mut device } = &mut event {
175+
if let InputEvent::DeviceAdded { ref mut device } = &mut event {
175176
data.state.common.config.read_device(device);
177+
data.state
178+
.backend
179+
.kms()
180+
.input_devices
181+
.insert(device.name().into(), device.clone());
182+
} else if let InputEvent::DeviceRemoved { device } = &event {
183+
data.state.backend.kms().input_devices.remove(device.name());
176184
}
177185
data.state.process_input_event(event, true);
178186
for output in data.state.common.shell.outputs() {
@@ -362,6 +370,7 @@ pub fn init_backend(
362370
primary,
363371
session,
364372
devices: HashMap::new(),
373+
input_devices: HashMap::new(),
365374
});
366375

367376
// Create relative pointer global

0 commit comments

Comments
 (0)