input: add a default seat
This commit is contained in:
parent
8a73779cbd
commit
355a9eb240
10 changed files with 58 additions and 14 deletions
|
|
@ -62,3 +62,5 @@ impl WireMode {
|
|||
|
||||
#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct PollableId(pub u64);
|
||||
|
||||
pub const DEFAULT_SEAT_NAME: &str = "default";
|
||||
|
|
|
|||
|
|
@ -576,6 +576,10 @@ impl Client {
|
|||
self.send(&ClientMessage::SetDoubleClickDistance { dist });
|
||||
}
|
||||
|
||||
pub fn disable_default_seat(&self) {
|
||||
self.send(&ClientMessage::DisableDefaultSeat);
|
||||
}
|
||||
|
||||
pub fn connector_set_position(&self, connector: Connector, x: i32, y: i32) {
|
||||
self.send(&ClientMessage::ConnectorSetPosition { connector, x, y });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,6 +381,7 @@ pub enum ClientMessage<'a> {
|
|||
env: Vec<(String, String)>,
|
||||
fds: Vec<(i32, i32)>,
|
||||
},
|
||||
DisableDefaultSeat,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use {
|
|||
input::{acceleration::AccelProfile, capability::Capability},
|
||||
keyboard::Keymap,
|
||||
Axis, Direction, ModifiedKeySym, Workspace,
|
||||
_private::DEFAULT_SEAT_NAME,
|
||||
},
|
||||
serde::{Deserialize, Serialize},
|
||||
std::time::Duration,
|
||||
|
|
@ -319,10 +320,20 @@ pub fn input_devices() -> Vec<InputDevice> {
|
|||
/// Returns or creates a seat.
|
||||
///
|
||||
/// Seats are identified by their name. If no seat with the name exists, a new seat will be created.
|
||||
///
|
||||
/// NOTE: You should prefer [`get_default_seat`] instead. Most applications cannot handle more than
|
||||
/// one seat and will only process input from one of the seats.
|
||||
pub fn get_seat(name: &str) -> Seat {
|
||||
get!(Seat(0)).get_seat(name)
|
||||
}
|
||||
|
||||
/// Returns or creates the default seat.
|
||||
///
|
||||
/// This is equivalent to `get_seat("default")`.
|
||||
pub fn get_default_seat() -> Seat {
|
||||
get_seat(DEFAULT_SEAT_NAME)
|
||||
}
|
||||
|
||||
/// Sets a closure to run when a new seat has been created.
|
||||
pub fn on_new_seat<F: FnMut(Seat) + 'static>(f: F) {
|
||||
get!().on_new_seat(f)
|
||||
|
|
@ -357,3 +368,14 @@ pub fn set_double_click_time(duration: Duration) {
|
|||
pub fn set_double_click_distance(distance: i32) {
|
||||
get!().set_double_click_distance(distance)
|
||||
}
|
||||
|
||||
/// Disables the creation of a default seat.
|
||||
///
|
||||
/// Unless this function is called at startup of the compositor, a seat called `default`
|
||||
/// will automatically be created.
|
||||
///
|
||||
/// When a new input device is attached and a seat called `default` exists, the input
|
||||
/// device is initially attached to this seat.
|
||||
pub fn disable_default_seat() {
|
||||
get!().disable_default_seat();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,23 +12,19 @@
|
|||
//! config!(configure);
|
||||
//! ```
|
||||
//!
|
||||
//! This configuration will not allow you to interact with the compositor at all nor exit it.
|
||||
//! This configuration will not allow you to exit the compositor.
|
||||
//! To add at least that much functionality, add the following code to `configure`:
|
||||
//!
|
||||
//! ```rust
|
||||
//! use jay_config::{config, quit};
|
||||
//! use jay_config::input::{get_seat, input_devices, on_new_input_device};
|
||||
//! use jay_config::input::{get_default_seat, input_devices, on_new_input_device};
|
||||
//! use jay_config::keyboard::mods::ALT;
|
||||
//! use jay_config::keyboard::syms::SYM_q;
|
||||
//!
|
||||
//! fn configure() {
|
||||
//! // Create a seat.
|
||||
//! let seat = get_seat("default");
|
||||
//! let seat = get_default_seat();
|
||||
//! // Create a key binding to exit the compositor.
|
||||
//! seat.bind(ALT | SYM_q, || quit());
|
||||
//! // Assign all current and future input devices to this seat.
|
||||
//! input_devices().into_iter().for_each(move |d| d.set_seat(seat));
|
||||
//! on_new_input_device(move |d| d.set_seat(seat));
|
||||
//! }
|
||||
//!
|
||||
//! config!(configure);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue