Skip to content

Commit

Permalink
Use cosmic-config for input configuration; allow dynamic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Jul 28, 2023
1 parent 94c89b6 commit efcf877
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 84 deletions.
79 changes: 41 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ ron = "0.7"
libsystemd = { version = "0.5", optional = true }
wayland-backend = "0.1.0"
wayland-scanner = "0.30.0"
cosmic-config = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c", features = ["calloop"] }
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = ["server"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "42d7baf", default-features = false }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "42d7baf" }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c", default-features = false }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "4895b0c" }
tiny-skia = "0.9"
ordered-float = "3.0"
glow = "0.11.2"
Expand Down
13 changes: 11 additions & 2 deletions src/backend/kms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use smithay::{
control::{connector, crtc, Device as ControlDevice, ModeTypeFlags},
Device as _,
},
input::Libinput,
input::{self, Libinput},
nix::{fcntl::OFlag, sys::stat::dev_t},
wayland_protocols::wp::{
linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1,
Expand Down Expand Up @@ -97,6 +97,7 @@ const MIN_RENDER_TIME: Duration = Duration::from_millis(3);
#[derive(Debug)]
pub struct KmsState {
devices: HashMap<DrmNode, Device>,
pub input_devices: HashMap<String, input::Device>,
pub api: GpuManager<GbmGlesBackend<GlowRenderer>>,
pub primary: DrmNode,
session: LibSeatSession,
Expand Down Expand Up @@ -171,8 +172,15 @@ pub fn init_backend(
let libinput_event_source = event_loop
.handle()
.insert_source(libinput_backend, move |mut event, _, data| {
if let &mut InputEvent::DeviceAdded { ref mut device } = &mut event {
if let InputEvent::DeviceAdded { ref mut device } = &mut event {
data.state.common.config.read_device(device);
data.state
.backend
.kms()
.input_devices
.insert(device.name().into(), device.clone());
} else if let InputEvent::DeviceRemoved { device } = &event {
data.state.backend.kms().input_devices.remove(device.name());
}
data.state.process_input_event(event, true);
for output in data.state.common.shell.outputs() {
Expand Down Expand Up @@ -362,6 +370,7 @@ pub fn init_backend(
primary,
session,
devices: HashMap::new(),
input_devices: HashMap::new(),
});

// Create relative pointer global
Expand Down
Loading

0 comments on commit efcf877

Please sign in to comment.