From f1db63e8831074194062e0f4b0ec82b193c2dc84 Mon Sep 17 00:00:00 2001 From: Andrej Benz Date: Tue, 5 Nov 2024 08:17:12 +0100 Subject: [PATCH] minor: make idle timeout respect scrolling --- cmd/version.txt | 2 +- internal/ui/interactions.go | 17 ++++++++++++----- internal/ui/ui.go | 4 ++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cmd/version.txt b/cmd/version.txt index a6637ab..b60d719 100644 --- a/cmd/version.txt +++ b/cmd/version.txt @@ -1 +1 @@ -0.8.4-git +0.8.4 diff --git a/internal/ui/interactions.go b/internal/ui/interactions.go index 92dd206..bc2409a 100644 --- a/internal/ui/interactions.go +++ b/internal/ui/interactions.go @@ -535,8 +535,6 @@ func closeAfterActivation(keepOpen, next bool) { var cancel context.CancelFunc func process() { - handleTimout() - if cfg.List.Placeholder != "" { elements.listPlaceholder.SetVisible(false) } @@ -579,7 +577,7 @@ func process() { var timoutTimer *time.Timer func handleTimout() { - if cfg.Timeout > 0 { + fn := func() { if timoutTimer != nil { timoutTimer.Stop() } @@ -587,13 +585,22 @@ func handleTimout() { timoutTimer = time.AfterFunc(time.Duration(cfg.Timeout)*time.Second, func() { if appstate.IsRunning { if appstate.IsService { - quit() + glib.IdleAdd(quit) } else { - exit() + glib.IdleAdd(exit) } } }) } + + if cfg.Timeout > 0 { + elements.input.Connect("search-changed", fn) + + scrollController := gtk.NewEventControllerScroll(gtk.EventControllerScrollBothAxes) + scrollController.Connect("scroll", fn) + + elements.scroll.AddController(scrollController) + } } var mut sync.Mutex diff --git a/internal/ui/ui.go b/internal/ui/ui.go index 83f0b2e..d9fbb70 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -169,6 +169,8 @@ func Activate(state *state.AppState) func(app *gtk.Application) { appstate.HasUI = true appstate.IsRunning = true + handleTimout() + if appstate.Benchmark { fmt.Println("Visible (first ui)", time.Now().UnixMilli()) } @@ -613,6 +615,8 @@ func reopen() { elements.input.GrabFocus() + handleTimout() + process() }