forked from muesli/deckmaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.go
43 lines (36 loc) · 860 Bytes
/
window.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"github.com/muesli/streamdeck"
)
func handleActiveWindowChanged(dev *streamdeck.Device, event ActiveWindowChangedEvent) {
verbosef("Active window changed to %s (%d, %s)",
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.Keys)
recentWindows = append([]Window{event.Window}, recentWindows...)
if len(recentWindows) > keys {
recentWindows = recentWindows[0:keys]
}
deck.updateWidgets()
}
func handleWindowClosed(event WindowClosedEvent) {
i := 0
for _, rw := range recentWindows {
if rw.ID == event.Window.ID {
continue
}
recentWindows[i] = rw
i++
}
recentWindows = recentWindows[:i]
deck.updateWidgets()
}