Skip to content

Commit

Permalink
allow root window to take focus when there are popups
Browse files Browse the repository at this point in the history
Fixes #81
  • Loading branch information
aarzilli committed Oct 2, 2024
1 parent 65980df commit e3acdb2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type context struct {

dockedWindowFocus int
floatWindowFocus int
rootWindowFocus bool
scrollwheelFocus int
dockedCnt int

Expand Down Expand Up @@ -237,6 +238,7 @@ func (ctx *context) Restack() {
return
}
ctx.dockedWindowFocus = 0
ctx.rootWindowFocus = false
nonmodalToplevel := false
var toplevelIdx int
for i := len(ctx.Windows) - 1; i >= 0; i-- {
Expand Down Expand Up @@ -285,14 +287,19 @@ func (ctx *context) Restack() {
}
return w
})
if ctx.dockedWindowFocus == 0 {
ctx.rootWindowFocus = true
}
}

func (ctx *context) FindFocus() {
ctx.floatWindowFocus = 0
for i := len(ctx.Windows) - 1; i >= 0; i-- {
if ctx.Windows[i].flags&windowTooltip == 0 {
ctx.floatWindowFocus = i
break
if !ctx.rootWindowFocus {
for i := len(ctx.Windows) - 1; i >= 0; i-- {
if ctx.Windows[i].flags&windowTooltip == 0 {
ctx.floatWindowFocus = i
break
}
}
}
ctx.scrollwheelFocus = 0
Expand Down

0 comments on commit e3acdb2

Please sign in to comment.