Commit 03dbb4ae1e89
tarball1 file changed+19-5
@@ -576,22 +576,30 @@ fn begin_drag(state: &mut State, id: WindowId, edges: Option<Edges>, button: Opt
576576
}577577
578578
/// Moves the dragged edges of an axis, keeping them between lo and hi unless579
-/// the window started beyond them, and the size above the minimum.579
+/// the window started beyond them, and the size between `limits`, whose580
+/// minimum wins over its maximum.580581
fn resized(581582
start: f64,582583
len: f64,583584
delta: f64,584585
edges: (bool, bool),585586
(lo, hi): (f64, f64),587
+ (min, max): (f64, f64),586588
) -> (f64, f64) {587589
let end = start + len;588590
match edges {589591
(true, _) => {590
- let edge = (start + delta).max(lo.min(start)).min(end - MIN_FLOAT_SIZE);592
+ let edge = (start + delta)593
+ .max(lo.min(start))594
+ .max(end - max)595
+ .min(end - min);591596
(edge, end - edge)592597
}593598
(_, true) => {594
- let edge = (end + delta).min(hi.max(end)).max(start + MIN_FLOAT_SIZE);599
+ let edge = (end + delta)600
+ .min(hi.max(end))601
+ .min(start + max)602
+ .max(start + min);595603
(start, edge - start)596604
}597605
_ => (start, len),@@ -623,8 +631,14 @@ fn drag_to(state: &mut State, pos: Point<f64, Logical>) -> bool {
623631
let rect = match d.edges {624632
Some(e) => {625633
let b = d.bounds;626
- let (x, w) = resized(r.x, r.w, dx, (e.left, e.right), (b.x, b.right()));627
- let (y, h) = resized(r.y, r.h, dy, (e.top, e.bottom), (b.y, b.bottom()));634
+ let rule = state.wm.get(d.window).map(|s| &s.rule);635
+ let (min_w, min_h) = rule.map_or((0.0, 0.0), |r| r.clamp_size(0.0, 0.0));636
+ let (max_w, max_h) = rule.map_or((f64::INFINITY, f64::INFINITY), |r| {637
+ r.clamp_size(f64::INFINITY, f64::INFINITY)638
+ });639
+ let min = (min_w.max(MIN_FLOAT_SIZE), min_h.max(MIN_FLOAT_SIZE));640
+ let (x, w) = resized(r.x, r.w, dx, (e.left, e.right), (b.x, b.right()), (min.0, max_w));641
+ let (y, h) = resized(r.y, r.h, dy, (e.top, e.bottom), (b.y, b.bottom()), (min.1, max_h));628642
Rect::new(x, y, w, h)629643
}630644
None => clamp_float(Rect::new(r.x + dx, r.y + dy, r.w, r.h), d.bounds),