aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-30 11:31:41 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-30 11:31:41 +0400
commita413f3e91d3538cc16d82880129732df7e31ec86 (patch)
tree529d361951a4c2f23ec734b8bb4c44fd3c1e0c2c /src/input.rs
parentf381db8354f249d828c9cb030e1f39b2bd20bb00 (diff)
downloadniri-a413f3e91d3538cc16d82880129732df7e31ec86.tar.gz
niri-a413f3e91d3538cc16d82880129732df7e31ec86.tar.bz2
niri-a413f3e91d3538cc16d82880129732df7e31ec86.zip
input: Simplify logic when cursor is outside outputs
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs29
1 files changed, 5 insertions, 24 deletions
diff --git a/src/input.rs b/src/input.rs
index 52b65937..9d46eb28 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -17,7 +17,7 @@ use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
use crate::config::{Action, Config, Modifiers};
use crate::niri::State;
-use crate::utils::{get_monotonic_time, spawn};
+use crate::utils::{center, get_monotonic_time, spawn};
pub enum CompositorMod {
Super,
@@ -335,29 +335,10 @@ impl State {
.clamp(geom.loc.y as f64, (geom.loc.y + geom.size.h - 1) as f64);
} else {
// The pointer was not on any output in the first place. Find one for it.
- // Start by clamping the X coordinate.
- let mut min_x = i32::MAX;
- let mut max_x = 0;
- for output in self.niri.global_space.outputs() {
- let geom = self.niri.global_space.output_geometry(output).unwrap();
- min_x = min_x.min(geom.loc.x);
- max_x = max_x.max(geom.loc.x + geom.size.w);
- }
-
- new_pos.x = new_pos.x.clamp(min_x as f64, (max_x - 1) as f64);
-
- // Now clamp the Y coordinate. Assume every X from min to max has some
- // output.
- let geom = self
- .niri
- .global_space
- .outputs()
- .map(|output| self.niri.global_space.output_geometry(output).unwrap())
- .find(|geom| geom.contains((new_pos.x as i32, geom.loc.y)))
- .unwrap();
- new_pos.y = new_pos
- .y
- .clamp(geom.loc.y as f64, (geom.loc.y + geom.size.h - 1) as f64);
+ // Let's do the simple thing and just put it on the first output.
+ let output = self.niri.global_space.outputs().next().unwrap();
+ let geom = self.niri.global_space.output_geometry(output).unwrap();
+ new_pos = center(geom).to_f64();
}
}