From e3acdb25e5d3ab579e5b427419add774ccca7804 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Wed, 2 Oct 2024 14:32:38 +0200 Subject: [PATCH] allow root window to take focus when there are popups Fixes #81 --- context.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/context.go b/context.go index 2272691..e772bbd 100644 --- a/context.go +++ b/context.go @@ -36,6 +36,7 @@ type context struct { dockedWindowFocus int floatWindowFocus int + rootWindowFocus bool scrollwheelFocus int dockedCnt int @@ -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-- { @@ -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