Skip to content

Commit

Permalink
reset docked window focus after the last non-docked window is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
aarzilli committed Dec 27, 2018
1 parent 90d19e6 commit d1a9425
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func contextEnd(ctx *context) {
}

func (ctx *context) Reset() {
prevNumWindows := len(ctx.Windows)
for i := 0; i < len(ctx.Windows); i++ {
if ctx.Windows[i].close {
if i != len(ctx.Windows)-1 {
Expand All @@ -151,6 +152,21 @@ func (ctx *context) Reset() {
for i := range ctx.Windows {
ctx.Windows[i].idx = i
}
if prevNumWindows == 2 && len(ctx.Windows) == 1 && ctx.Input.Mouse.valid {
ctx.DockedWindows.Walk(func(w *Window) *Window {
if w.flags&windowDocked == 0 {
return w
}
for _, b := range []mouse.Button{mouse.ButtonLeft, mouse.ButtonRight, mouse.ButtonMiddle} {
btn := ctx.Input.Mouse.Buttons[b]
if btn.Clicked && w.Bounds.Contains(btn.ClickedPos) {
ctx.dockedWindowFocus = w.idx
return w
}
}
return w
})
}
ctx.activateEditor = nil
in := &ctx.Input
in.Mouse.Buttons[mouse.ButtonLeft].Clicked = false
Expand Down

0 comments on commit d1a9425

Please sign in to comment.