mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Add tablet map-to-output setting
This commit is contained in:
@@ -18,13 +18,20 @@ input {
|
|||||||
// repeat-rate 25
|
// repeat-rate 25
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next sections contain libinput settings.
|
// Next sections include libinput settings.
|
||||||
// Omitting settings disables them, or leaves them at their default values.
|
// Omitting settings disables them, or leaves them at their default values.
|
||||||
touchpad {
|
touchpad {
|
||||||
tap
|
tap
|
||||||
natural-scroll
|
natural-scroll
|
||||||
// accel-speed 0.2
|
// accel-speed 0.2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tablet {
|
||||||
|
// Set the name of the output (see below) which the tablet will map to.
|
||||||
|
// If this is unset or the output doesn't exist, the tablet maps to one of the
|
||||||
|
// existing outputs.
|
||||||
|
map-to-output "eDP-1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can configure outputs by their name, which you can find with wayland-info(1).
|
// You can configure outputs by their name, which you can find with wayland-info(1).
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ pub struct Input {
|
|||||||
pub keyboard: Keyboard,
|
pub keyboard: Keyboard,
|
||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
pub touchpad: Touchpad,
|
pub touchpad: Touchpad,
|
||||||
|
#[knuffel(child, default)]
|
||||||
|
pub tablet: Tablet,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)]
|
#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)]
|
||||||
@@ -73,6 +75,12 @@ pub struct Touchpad {
|
|||||||
pub accel_speed: f64,
|
pub accel_speed: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
|
||||||
|
pub struct Tablet {
|
||||||
|
#[knuffel(child, unwrap(argument))]
|
||||||
|
pub map_to_output: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(knuffel::Decode, Debug, Clone, PartialEq)]
|
#[derive(knuffel::Decode, Debug, Clone, PartialEq)]
|
||||||
pub struct Output {
|
pub struct Output {
|
||||||
#[knuffel(argument)]
|
#[knuffel(argument)]
|
||||||
@@ -478,6 +486,10 @@ mod tests {
|
|||||||
tap
|
tap
|
||||||
accel-speed 0.2
|
accel-speed 0.2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tablet {
|
||||||
|
map-to-output "eDP-1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output "eDP-1" {
|
output "eDP-1" {
|
||||||
@@ -530,6 +542,9 @@ mod tests {
|
|||||||
natural_scroll: false,
|
natural_scroll: false,
|
||||||
accel_speed: 0.2,
|
accel_speed: 0.2,
|
||||||
},
|
},
|
||||||
|
tablet: Tablet {
|
||||||
|
map_to_output: Some("eDP-1".to_owned()),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
outputs: vec![Output {
|
outputs: vec![Output {
|
||||||
name: "eDP-1".to_owned(),
|
name: "eDP-1".to_owned(),
|
||||||
|
|||||||
+2
-4
@@ -472,8 +472,7 @@ impl State {
|
|||||||
pointer.frame(self);
|
pointer.frame(self);
|
||||||
}
|
}
|
||||||
InputEvent::TabletToolAxis { event, .. } => {
|
InputEvent::TabletToolAxis { event, .. } => {
|
||||||
// FIXME: allow mapping tablet to different outputs.
|
let Some(output) = self.niri.output_for_tablet() else {
|
||||||
let Some(output) = self.niri.global_space.outputs().next() else {
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -560,8 +559,7 @@ impl State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
InputEvent::TabletToolProximity { event, .. } => {
|
InputEvent::TabletToolProximity { event, .. } => {
|
||||||
// FIXME: allow mapping tablet to different outputs.
|
let Some(output) = self.niri.output_for_tablet() else {
|
||||||
let Some(output) = self.niri.global_space.outputs().next() else {
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+15
-1
@@ -105,6 +105,7 @@ pub struct Niri {
|
|||||||
pub unmapped_windows: HashMap<WlSurface, Window>,
|
pub unmapped_windows: HashMap<WlSurface, Window>,
|
||||||
|
|
||||||
pub output_state: HashMap<Output, OutputState>,
|
pub output_state: HashMap<Output, OutputState>,
|
||||||
|
pub output_by_name: HashMap<String, Output>,
|
||||||
|
|
||||||
// Smithay state.
|
// Smithay state.
|
||||||
pub compositor_state: CompositorState,
|
pub compositor_state: CompositorState,
|
||||||
@@ -679,6 +680,7 @@ impl Niri {
|
|||||||
monitor_set: MonitorSet::new(),
|
monitor_set: MonitorSet::new(),
|
||||||
global_space: Space::default(),
|
global_space: Space::default(),
|
||||||
output_state: HashMap::new(),
|
output_state: HashMap::new(),
|
||||||
|
output_by_name: HashMap::new(),
|
||||||
unmapped_windows: HashMap::new(),
|
unmapped_windows: HashMap::new(),
|
||||||
|
|
||||||
compositor_state,
|
compositor_state,
|
||||||
@@ -787,7 +789,9 @@ impl Niri {
|
|||||||
frame_clock: FrameClock::new(refresh_interval),
|
frame_clock: FrameClock::new(refresh_interval),
|
||||||
current_estimated_sequence: None,
|
current_estimated_sequence: None,
|
||||||
};
|
};
|
||||||
let rv = self.output_state.insert(output, state);
|
let rv = self.output_state.insert(output.clone(), state);
|
||||||
|
assert!(rv.is_none(), "output was already tracked");
|
||||||
|
let rv = self.output_by_name.insert(name, output);
|
||||||
assert!(rv.is_none(), "output was already tracked");
|
assert!(rv.is_none(), "output was already tracked");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,6 +801,8 @@ impl Niri {
|
|||||||
// FIXME: reposition outputs so they are adjacent.
|
// FIXME: reposition outputs so they are adjacent.
|
||||||
|
|
||||||
let state = self.output_state.remove(output).unwrap();
|
let state = self.output_state.remove(output).unwrap();
|
||||||
|
self.output_by_name.remove(&output.name()).unwrap();
|
||||||
|
|
||||||
match state.redraw_state {
|
match state.redraw_state {
|
||||||
RedrawState::Idle => (),
|
RedrawState::Idle => (),
|
||||||
RedrawState::Queued(idle) => idle.cancel(),
|
RedrawState::Queued(idle) => idle.cancel(),
|
||||||
@@ -950,6 +956,14 @@ impl Niri {
|
|||||||
.cloned()
|
.cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn output_for_tablet(&self) -> Option<&Output> {
|
||||||
|
let config = self.config.borrow();
|
||||||
|
let map_to_output = config.input.tablet.map_to_output.as_ref();
|
||||||
|
map_to_output
|
||||||
|
.and_then(|name| self.output_by_name.get(name))
|
||||||
|
.or_else(|| self.global_space.outputs().next())
|
||||||
|
}
|
||||||
|
|
||||||
fn layer_surface_focus(&self) -> Option<WlSurface> {
|
fn layer_surface_focus(&self) -> Option<WlSurface> {
|
||||||
let output = self.monitor_set.active_output()?;
|
let output = self.monitor_set.active_output()?;
|
||||||
let layers = layer_map_for_output(output);
|
let layers = layer_map_for_output(output);
|
||||||
|
|||||||
Reference in New Issue
Block a user