fix for multiseat

Note: It panics if the seat doesn't exist
This commit is contained in:
Bryan Ndjeutcha 2021-05-25 11:39:04 -04:00
parent ab22aa63a8
commit 917e796dfa
4 changed files with 21 additions and 10 deletions

12
Cargo.lock generated
View File

@ -78,6 +78,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"wayland-client", "wayland-client",
"wayland-commons", "wayland-commons",
"wayland-protocols",
"wayland-scanner", "wayland-scanner",
] ]
@ -120,6 +121,17 @@ dependencies = [
"wayland-sys", "wayland-sys",
] ]
[[package]]
name = "wayland-protocols"
version = "0.28.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95df3317872bcf9eec096c864b69aa4769a1d5d6291a5b513f8ba0af0efbd52c"
dependencies = [
"bitflags",
"wayland-commons",
"wayland-scanner",
]
[[package]] [[package]]
name = "wayland-scanner" name = "wayland-scanner"
version = "0.28.5" version = "0.28.5"

View File

@ -10,6 +10,6 @@ edition = "2018"
wayland-scanner = "0.28.5" wayland-scanner = "0.28.5"
[dependencies] [dependencies]
wayland-scanner = "0.28.5" wayland-protocols = "0.28.5"
wayland-commons = "0.28.5" wayland-commons = "0.28.5"
wayland-client = "0.28.5" wayland-client = "0.28.5"

View File

@ -4,15 +4,16 @@ use crate::wayland::river_status_unstable_v1::{
zriver_output_status_v1, zriver_seat_status_v1, zriver_status_manager_v1::ZriverStatusManagerV1, zriver_output_status_v1, zriver_seat_status_v1, zriver_status_manager_v1::ZriverStatusManagerV1,
}; };
use wayland_client::protocol::{ use wayland_client::protocol::{
wl_seat,
wl_output::WlOutput, wl_output::WlOutput,
wl_seat::WlSeat, wl_seat::WlSeat,
wl_seat::Event
}; };
use wayland_client::{Display, GlobalManager, Main}; use wayland_client::{Display, GlobalManager, Main};
struct Globals { struct Globals {
seats: Vec<Main<WlSeat>>, seats: Vec<Main<WlSeat>>,
outputs: Vec<Main<WlOutput>>, outputs: Vec<Main<WlOutput>>,
// xdg_outputs: Vec<Main<WlOutput>>,
status_manager: Option<Main<ZriverStatusManagerV1>>, status_manager: Option<Main<ZriverStatusManagerV1>>,
} }
@ -25,6 +26,7 @@ fn main() {
Globals { Globals {
seats: Vec::new(), seats: Vec::new(),
outputs: Vec::new(), outputs: Vec::new(),
// xdg_outputs: Vec::new(),
status_manager: None, status_manager: None,
} }
}; };
@ -106,18 +108,13 @@ fn main() {
.get_river_seat_status(&seat); .get_river_seat_status(&seat);
seat.quick_assign(move |_, event, mut seat_name| { seat.quick_assign(move |_, event, mut seat_name| {
match event { match event {
Event::Name{ name } => if String::new().eq(seat_name.get::<String>().unwrap()) wl_seat::Event::Name{ name } => if enable_title && seat_name.get::<String>().unwrap().len() == 0 || name.eq(seat_name.get::<String>().unwrap()) {
|| name.eq(seat_name.get::<String>().unwrap()) {
seat_status.quick_assign(move |_, event, _| match event { seat_status.quick_assign(move |_, event, _| match event {
zriver_seat_status_v1::Event::FocusedView { title } => { zriver_seat_status_v1::Event::FocusedView { title } => println!("{}", title),
if enable_title {
println!("{}", title)
}
}
_ => {} _ => {}
}) })
}, },
_ => seat_status.quick_assign(move |_, _, _| {}) _ => {}
} }
}) })
} }

View File

@ -1,5 +1,6 @@
extern crate wayland_client; extern crate wayland_client;
extern crate wayland_commons; extern crate wayland_commons;
extern crate wayland_protocols;
// Re-export only the actual code, and then only use this re-export // Re-export only the actual code, and then only use this re-export
// The `generated` module below is just some boilerplate to properly isolate stuff // The `generated` module below is just some boilerplate to properly isolate stuff
@ -25,6 +26,7 @@ pub mod wayland {
pub(crate) use wayland_commons::smallvec; pub(crate) use wayland_commons::smallvec;
pub(crate) use wayland_commons::wire::{Argument, ArgumentType, Message, MessageDesc}; pub(crate) use wayland_commons::wire::{Argument, ArgumentType, Message, MessageDesc};
pub(crate) use wayland_commons::{Interface, MessageGroup}; pub(crate) use wayland_commons::{Interface, MessageGroup};
// pub(crate) use wayland_protocols::unstable::xdg_output::v1::client::zxdg_output_v1::Event;
// If you protocol interacts with objects from other protocols, you'll need to import // If you protocol interacts with objects from other protocols, you'll need to import
// their modules, like so: // their modules, like so:
pub(crate) use wayland_client::protocol::{wl_region, wl_seat, wl_surface}; pub(crate) use wayland_client::protocol::{wl_region, wl_seat, wl_surface};