Resize floating windows by dragging their corners and side edges
CI / test (push) Failing after 15s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-25 00:44:34 -08:00
1 parent 8a3ea16b1c
commit a9417fbccf
2 files changed
+117 -21

No files matched your search

+87 -21
View File
@@ -614,6 +614,66 @@ fn MoonPlasmaCompositor::window_at(self : MoonPlasmaCompositor, x : Int, y : Int
None
}
///| Resize zone under (x, y) on a floating window: its corners (12px) and left/right/bottom
/// edges. The first window whose outer box contains the point decides; tiled windows resize
/// through the dividers instead.
fn MoonPlasmaCompositor::resize_at(
self : MoonPlasmaCompositor,
x : Int,
y : Int,
) -> (UInt64, @wm.DragMode)? {
let order = self.wm.stacking_order()
let mut i = order.length() - 1
while i >= 0 {
let id = order[i]
match (self.windows.get(id), self.wm.windows.get(id)) {
(Some(win), Some(rec)) => {
let g = win.geometry
let l = g.x
let r = g.x + g.w
let t = g.y - 32
let b = g.y + g.h
if x >= l - 6 && x < r + 6 && y >= t - 6 && y < b + 6 {
if !rec.is_floating || rec.maximized || rec.fullscreen {
return None
}
let nl = x < l + 12
let nr = x >= r - 12
let in_l = x < l + 2
let in_r = x >= r - 2
let in_b = y >= b - 2
let in_t = y < t + 4
if in_t && nl {
return Some((id, @wm.DragMode::ResizeNW))
}
if in_t && nr {
return Some((id, @wm.DragMode::ResizeNE))
}
if in_b && nl {
return Some((id, @wm.DragMode::ResizeSW))
}
if in_b && nr {
return Some((id, @wm.DragMode::ResizeSE))
}
if in_b {
return Some((id, @wm.DragMode::ResizeS))
}
if in_l {
return Some((id, if y >= b - 12 { @wm.DragMode::ResizeSW } else { @wm.DragMode::ResizeW }))
}
if in_r {
return Some((id, if y >= b - 12 { @wm.DragMode::ResizeSE } else { @wm.DragMode::ResizeE }))
}
return None
}
}
_ => ()
}
i = i - 1
}
None
}
///| Title-bar button under (x, y) for window `wid`: 1 minimize, 2 maximize, 3 close, 0 none.
/// Mirrors the layout in `build_breeze_decoration` (18px buttons, 8px apart, 10px from the right edge).
fn MoonPlasmaCompositor::title_button_at(
@@ -828,18 +888,7 @@ pub fn MoonPlasmaCompositor::handle_input(
}
None => ()
}
if self.handle_at(xi, yi) is Some(_) {
self.leave_pointer()
return
}
match self.split_drag {
Some(h) => {
self.apply_actions(self.wm.drag_split(h, xi, yi, self.work_area))
return
}
None => ()
}
if self.handle_at(xi, yi) is Some(_) {
if self.handle_at(xi, yi) is Some(_) || self.resize_at(xi, yi) is Some(_) {
self.leave_pointer()
return
}
@@ -922,7 +971,7 @@ pub fn MoonPlasmaCompositor::handle_input(
self.press_title_button(wid, btn)
return
}
if button == 272U {
if button == 272U && self.resize_at(xi, yi) is None {
// Drag the window by its title bar; a tiled window becomes floating first.
self.leave_pointer()
self.apply_actions([@wm.WmAction::Focus(wid), @wm.WmAction::Raise(wid)])
@@ -933,13 +982,16 @@ pub fn MoonPlasmaCompositor::handle_input(
}
_ => ()
}
match self.handle_at(xi, yi) {
Some(h) => {
self.split_drag = Some(h)
self.leave_pointer()
return
if button == 272U {
match self.resize_at(xi, yi) {
Some((wid, mode)) => {
self.leave_pointer()
self.apply_actions([@wm.WmAction::Focus(wid), @wm.WmAction::Raise(wid)])
ignore(self.wm.start_drag(wid, mode, xi, yi))
return
}
None => ()
}
None => ()
}
match self.handle_at(xi, yi) {
Some(h) => {
@@ -1024,8 +1076,22 @@ pub fn MoonPlasmaCompositor::desired_cursor(self : MoonPlasmaCompositor) -> UInt
if shell_shape != 0U {
return shell_shape
}
if self.wm.drag is Some(_) {
return 4U
fn mode_cursor(m : @wm.DragMode) -> UInt {
match m {
Move => 4U
ResizeE | ResizeW => 26U
ResizeN | ResizeS => 27U
ResizeNW | ResizeSE => 29U
ResizeNE | ResizeSW => 28U
}
}
match self.wm.drag {
Some(d) => return mode_cursor(d.mode)
None => ()
}
match self.resize_at(self.ptr_x.to_int(), self.ptr_y.to_int()) {
Some((_, m)) => return mode_cursor(m)
None => ()
}
let handle = match self.split_drag {
Some(h) => Some(h)