Skip to content

Commit

Permalink
Add missing window.go
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jun 8, 2021
1 parent 6f28df5 commit cee39d0
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions window.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"log"

"github.com/muesli/streamdeck"
)

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

// remove dupes
i := 0
for _, rw := range recentWindows {
if rw.ID == event.Window.ID {
continue
}

recentWindows[i] = rw
i++
}
recentWindows = recentWindows[:i]

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

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

recentWindows[i] = rw
i++
}
recentWindows = recentWindows[:i]
deck.updateWidgets(dev)
}

0 comments on commit cee39d0

Please sign in to comment.