Skip to content

Commit

Permalink
Close window when long-pressing a RecentWindowWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jun 8, 2021
1 parent 5e9cd17 commit ec3a10c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deck.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (d *Deck) triggerAction(dev *streamdeck.Device, index uint8, hold bool) {
go executeCommand(a.Exec)
}
} else {
w.TriggerAction()
w.TriggerAction(hold)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Widget interface {
Update(dev *streamdeck.Device) error
Action() *ActionConfig
ActionHold() *ActionConfig
TriggerAction()
TriggerAction(hold bool)
}

// BaseWidget provides common functionality required by all widgets.
Expand Down Expand Up @@ -52,7 +52,7 @@ func (w *BaseWidget) ActionHold() *ActionConfig {
}

// TriggerAction gets called when a button is pressed.
func (w *BaseWidget) TriggerAction() {
func (w *BaseWidget) TriggerAction(_ bool) {
// just a stub
}

Expand Down
7 changes: 6 additions & 1 deletion widget_recent_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ func (w *RecentWindowWidget) Update(dev *streamdeck.Device) error {
}

// TriggerAction gets called when a button is pressed.
func (w *RecentWindowWidget) TriggerAction() {
func (w *RecentWindowWidget) TriggerAction(hold bool) {
if xorg == nil {
log.Println("xorg support is disabled!")
return
}

if int(w.window) < len(recentWindows) {
if hold {
_ = xorg.CloseWindow(recentWindows[w.window])
return
}

_ = xorg.RequestActivation(recentWindows[w.window])
}
}

0 comments on commit ec3a10c

Please sign in to comment.