Skip to content

Commit

Permalink
minor: make idle timeout respect scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Nov 5, 2024
1 parent 1cb4586 commit f1db63e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.4-git
0.8.4
17 changes: 12 additions & 5 deletions internal/ui/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,6 @@ func closeAfterActivation(keepOpen, next bool) {
var cancel context.CancelFunc

func process() {
handleTimout()

if cfg.List.Placeholder != "" {
elements.listPlaceholder.SetVisible(false)
}
Expand Down Expand Up @@ -579,21 +577,30 @@ func process() {
var timoutTimer *time.Timer

func handleTimout() {
if cfg.Timeout > 0 {
fn := func() {
if timoutTimer != nil {
timoutTimer.Stop()
}

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
Expand Down
4 changes: 4 additions & 0 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -613,6 +615,8 @@ func reopen() {

elements.input.GrabFocus()

handleTimout()

process()
}

Expand Down

0 comments on commit f1db63e

Please sign in to comment.