Check cursor is in-bounds before resizing panes
This commit is contained in:
parent
31aaf207d6
commit
33f33ed4e3
@ -467,48 +467,53 @@ where
|
|||||||
&& self.pressed_modifiers.matches(self.modifier_keys) =>
|
&& self.pressed_modifiers.matches(self.modifier_keys) =>
|
||||||
{
|
{
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
let relative_cursor = Point::new(
|
|
||||||
cursor_position.x - bounds.x,
|
|
||||||
cursor_position.y - bounds.y,
|
|
||||||
);
|
|
||||||
|
|
||||||
let splits = self.state.splits(
|
if bounds.contains(cursor_position) {
|
||||||
f32::from(self.spacing),
|
let relative_cursor = Point::new(
|
||||||
Size::new(bounds.width, bounds.height),
|
cursor_position.x - bounds.x,
|
||||||
);
|
cursor_position.y - bounds.y,
|
||||||
|
);
|
||||||
|
|
||||||
let mut sorted_splits: Vec<_> = splits
|
let splits = self.state.splits(
|
||||||
.iter()
|
f32::from(self.spacing),
|
||||||
.filter(|(_, (axis, rectangle, _))| match axis {
|
Size::new(bounds.width, bounds.height),
|
||||||
Axis::Horizontal => {
|
);
|
||||||
relative_cursor.x > rectangle.x
|
|
||||||
&& relative_cursor.x
|
|
||||||
< rectangle.x + rectangle.width
|
|
||||||
}
|
|
||||||
Axis::Vertical => {
|
|
||||||
relative_cursor.y > rectangle.y
|
|
||||||
&& relative_cursor.y
|
|
||||||
< rectangle.y + rectangle.height
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
sorted_splits.sort_by_key(|(_, (axis, rectangle, ratio))| {
|
let mut sorted_splits: Vec<_> = splits
|
||||||
let distance = match axis {
|
.iter()
|
||||||
Axis::Horizontal => (relative_cursor.y
|
.filter(|(_, (axis, rectangle, _))| match axis {
|
||||||
- (rectangle.y + rectangle.height * ratio))
|
Axis::Horizontal => {
|
||||||
.abs(),
|
relative_cursor.x > rectangle.x
|
||||||
Axis::Vertical => (relative_cursor.x
|
&& relative_cursor.x
|
||||||
- (rectangle.x + rectangle.width * ratio))
|
< rectangle.x + rectangle.width
|
||||||
.abs(),
|
}
|
||||||
};
|
Axis::Vertical => {
|
||||||
|
relative_cursor.y > rectangle.y
|
||||||
|
&& relative_cursor.y
|
||||||
|
< rectangle.y + rectangle.height
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
distance.round() as u32
|
sorted_splits.sort_by_key(
|
||||||
});
|
|(_, (axis, rectangle, ratio))| {
|
||||||
|
let distance = match axis {
|
||||||
|
Axis::Horizontal => (relative_cursor.y
|
||||||
|
- (rectangle.y + rectangle.height * ratio))
|
||||||
|
.abs(),
|
||||||
|
Axis::Vertical => (relative_cursor.x
|
||||||
|
- (rectangle.x + rectangle.width * ratio))
|
||||||
|
.abs(),
|
||||||
|
};
|
||||||
|
|
||||||
if let Some((split, (axis, _, _))) = sorted_splits.first() {
|
distance.round() as u32
|
||||||
self.state.pick_split(split, *axis);
|
},
|
||||||
self.trigger_resize(layout, cursor_position, messages);
|
);
|
||||||
|
|
||||||
|
if let Some((split, (axis, _, _))) = sorted_splits.first() {
|
||||||
|
self.state.pick_split(split, *axis);
|
||||||
|
self.trigger_resize(layout, cursor_position, messages);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse::Event::Input {
|
Event::Mouse(mouse::Event::Input {
|
||||||
|
Loading…
Reference in New Issue
Block a user