Skip to content

Commit 5b80bc7

Browse files
hajimehoshicodex
andcommitted
debugui: fix hit testing for collapsed windows
Restrict collapsed window hit testing to the title bar so exposed windows can receive input and move to the front. Share the visible bounds calculation with input capture detection to track moved titles. Closes #55 Co-Authored-By: Codex <noreply@openai.com>
1 parent c584723 commit 5b80bc7

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎container.go‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,21 @@ func (c *Context) bringToFront(cnt *container) {
369369

370370
func (c *Context) hoveringRootContainer() *container {
371371
p := c.pointingPosition()
372-
for i := len(c.rootContainers) - 1; i >= 0; i-- {
373-
cnt := c.rootContainers[i]
372+
for _, cnt := range slices.Backward(c.rootContainers) {
374373
if !cnt.open {
375374
continue
376375
}
377-
if p.In(cnt.layout.Bounds) {
376+
if p.In(cnt.visibleBounds(c.style().titleHeight)) {
378377
return cnt
379378
}
380379
}
381380
return nil
382381
}
382+
383+
func (c *container) visibleBounds(titleHeight int) image.Rectangle {
384+
bounds := c.layout.Bounds
385+
if c.collapsed {
386+
bounds.Max.Y = bounds.Min.Y + titleHeight
387+
}
388+
return bounds
389+
}

‎context.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ func (c *Context) update(f func(ctx *Context) error) (inputCapturingState InputC
113113
// Check whether the cursor is on any of the root containers.
114114
pt := c.pointingPosition()
115115
for _, cnt := range c.rootContainers {
116-
bounds := cnt.layout.Bounds
117-
if cnt.collapsed {
118-
bounds.Max.Y = cnt.layout.BodyBounds.Min.Y
119-
}
120-
if pt.In(bounds) {
116+
if pt.In(cnt.visibleBounds(c.style().titleHeight)) {
121117
inputCapturingState |= InputCapturingStateHover
122118
}
123119
}

0 commit comments

Comments
 (0)