GTK windows (Gajim, GNOME apps) resize from their shadow and all four edges
CI / test (push) Successful in 3m44s
CI / test (push) Successful in 3m44s
GTK draws no border, only a shadow, and resizes only from a press in that shadow, which Chandra never hands to the client. Chandra's own zones were ~4px wide around the visible edge and there was none on the top edge, so Gajim (GTK 4) looked unresizable. Client-decorated windows now get zones that reach up to 12px into the shadow (GTK's own handle size, at least 6px) plus 3px over their edge, with 16px corners, top edge included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hiu4r7mEXBdKY6cgv6
This commit is contained in:
2 files changed
+148
No files matched your search
@@ -1208,6 +1208,79 @@ fn ChandraCompositor::window_at(self : ChandraCompositor, x : Int, y : Int) -> (
|
||||
None
|
||||
}
|
||||
|
||||
///| How far a client-decorated window's resize zones reach out past its visible edge, at most:
|
||||
/// GTK puts its resize handles in its shadow (12px, `RESIZE_HANDLE_SIZE` in gtkwindow.c).
|
||||
let csd_grip_out : Int = 12
|
||||
|
||||
///| ... and at least, for a client with a thin or no shadow.
|
||||
let csd_grip_min : Int = 6
|
||||
|
||||
///| ... and how far in over the client's own pixels (its header bar and borders).
|
||||
let csd_grip_in : Int = 3
|
||||
|
||||
///| Corner zones: this far along each edge from a corner.
|
||||
let csd_grip_corner : Int = 16
|
||||
|
||||
///| The resize zone a client-decorated window has at (x, y), if any. GTK (Gajim, GNOME apps)
|
||||
/// draws no border at all, only a shadow, and only resizes from a press in that shadow, which
|
||||
/// Chandra doesn't hand to the client: the shadow (up to 12px of it) plus a few pixels of the
|
||||
/// window's own edge resize it from Chandra instead, on all four sides and corners.
|
||||
fn csd_resize_zone(win : HostWindow, x : Int, y : Int) -> @wm.DragMode? {
|
||||
let c = win.client_rect()
|
||||
// The shadow the client draws on each side (buffer pixels around its window geometry).
|
||||
let (bw, bh) = match win.surface {
|
||||
Some(s) => (s.width, s.height)
|
||||
None => (c.w, c.h)
|
||||
}
|
||||
let reach = fn(shadow : Int) {
|
||||
if shadow > csd_grip_out {
|
||||
csd_grip_out
|
||||
} else if shadow < csd_grip_min {
|
||||
csd_grip_min
|
||||
} else {
|
||||
shadow
|
||||
}
|
||||
}
|
||||
let ol = reach(win.geo_x)
|
||||
let ot = reach(win.geo_y)
|
||||
let or_ = reach(bw - win.geo_x - c.w)
|
||||
let ob = reach(bh - win.geo_y - c.h)
|
||||
let l = c.x
|
||||
let t = c.y
|
||||
let r = c.x + c.w
|
||||
let b = c.y + c.h
|
||||
if x < l - ol || x >= r + or_ || y < t - ot || y >= b + ob {
|
||||
return None
|
||||
}
|
||||
let on_l = x < l + csd_grip_in
|
||||
let on_r = x >= r - csd_grip_in
|
||||
let on_t = y < t + csd_grip_in
|
||||
let on_b = y >= b - csd_grip_in
|
||||
let near_l = x < l + csd_grip_corner
|
||||
let near_r = x >= r - csd_grip_corner
|
||||
let near_t = y < t + csd_grip_corner
|
||||
let near_b = y >= b - csd_grip_corner
|
||||
if (on_t && near_l) || (on_l && near_t) {
|
||||
Some(@wm.DragMode::ResizeNW)
|
||||
} else if (on_t && near_r) || (on_r && near_t) {
|
||||
Some(@wm.DragMode::ResizeNE)
|
||||
} else if (on_b && near_l) || (on_l && near_b) {
|
||||
Some(@wm.DragMode::ResizeSW)
|
||||
} else if (on_b && near_r) || (on_r && near_b) {
|
||||
Some(@wm.DragMode::ResizeSE)
|
||||
} else if on_t {
|
||||
Some(@wm.DragMode::ResizeN)
|
||||
} else if on_b {
|
||||
Some(@wm.DragMode::ResizeS)
|
||||
} else if on_l {
|
||||
Some(@wm.DragMode::ResizeW)
|
||||
} else if on_r {
|
||||
Some(@wm.DragMode::ResizeE)
|
||||
} else {
|
||||
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.
|
||||
@@ -1221,6 +1294,18 @@ fn ChandraCompositor::resize_at(
|
||||
while i >= 0 {
|
||||
let id = order[i]
|
||||
match (self.windows.get(id), self.wm.windows.get(id)) {
|
||||
(Some(win), Some(rec)) if win.csd && !win.fullscreen => {
|
||||
let floating = rec.is_floating && !rec.maximized
|
||||
match csd_resize_zone(win, x, y) {
|
||||
Some(mode) if floating => return Some((id, mode))
|
||||
_ => {
|
||||
let c = win.client_rect()
|
||||
if x >= c.x && x < c.x + c.w && y >= c.y && y < c.y + c.h {
|
||||
return None // over the window itself: windows below don't count
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(Some(win), Some(rec)) => {
|
||||
let g = win.geometry
|
||||
let l = g.x
|
||||
|
||||
Reference in new issue
Block a user