Skip to content

Commit

Permalink
Limit recent windows to amount of physical keys
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed May 27, 2021
1 parent c57acc2 commit c4cdf90
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
brightness = flag.Uint("brightness", 80, "brightness in percent")
)

func handleActiveWindowChanged(_ streamdeck.Device, event ActiveWindowChangedEvent) {
func handleActiveWindowChanged(dev streamdeck.Device, event ActiveWindowChangedEvent) {
fmt.Printf("Active window changed to %s (%d, %s)\n",
event.Window.Class, event.Window.ID, event.Window.Name)

Expand All @@ -43,14 +43,15 @@ func handleActiveWindowChanged(_ streamdeck.Device, event ActiveWindowChangedEve
}
recentWindows = recentWindows[:i]

keys := int(dev.Rows * dev.Columns)
recentWindows = append([]Window{event.Window}, recentWindows...)
if len(recentWindows) > 15 {
recentWindows = recentWindows[0:15]
if len(recentWindows) > keys {
recentWindows = recentWindows[0:keys]
}
deck.updateWidgets()
}

func handleWindowClosed(dev streamdeck.Device, event WindowClosedEvent) {
func handleWindowClosed(_ streamdeck.Device, event WindowClosedEvent) {
i := 0
for _, rw := range recentWindows {
if rw.ID == event.Window.ID {
Expand Down

0 comments on commit c4cdf90

Please sign in to comment.