Skip to content

Commit

Permalink
Fix #14
Browse files Browse the repository at this point in the history
  • Loading branch information
diogox committed May 14, 2021
1 parent d8da34b commit 4f2a042
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 9 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/diogox/bspm
go 1.16

require (
github.com/diogox/bspc-go v0.0.0-20210302164947-8846a31c3273
github.com/diogox/bspc-go v0.0.0-20210514160037-5a5903da7ba2
github.com/fatih/color v1.10.0
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.4.3
github.com/golang/protobuf v1.5.2
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
go.uber.org/zap v1.16.0
google.golang.org/grpc v1.36.0
google.golang.org/protobuf v1.25.0
google.golang.org/protobuf v1.26.0
)
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ github.com/diogox/bspc-go v0.0.0-20210223003857-a374b109650b h1:Z61d3aWQYD7DyngM
github.com/diogox/bspc-go v0.0.0-20210223003857-a374b109650b/go.mod h1:d4jYBJhdGS8dxKhiT6+AMbjjUE3jIr3+SfG190UUMKk=
github.com/diogox/bspc-go v0.0.0-20210302164947-8846a31c3273 h1:xMT4BtYMMDaMg5y58BrondplTEia5nokyTAYH6Hul9Q=
github.com/diogox/bspc-go v0.0.0-20210302164947-8846a31c3273/go.mod h1:d4jYBJhdGS8dxKhiT6+AMbjjUE3jIr3+SfG190UUMKk=
github.com/diogox/bspc-go v0.0.0-20210514150622-4991467b2a50 h1:ejzbj0HYlxFCmHQD3CtWseCNCWT3mQRsvlCZEE42zNo=
github.com/diogox/bspc-go v0.0.0-20210514150622-4991467b2a50/go.mod h1:d4jYBJhdGS8dxKhiT6+AMbjjUE3jIr3+SfG190UUMKk=
github.com/diogox/bspc-go v0.0.0-20210514151947-04e6e669773b h1:qv3BNQVYFEMm0Y3ufliZZKxnLrCGqidl2swBcFF6O7A=
github.com/diogox/bspc-go v0.0.0-20210514151947-04e6e669773b/go.mod h1:d4jYBJhdGS8dxKhiT6+AMbjjUE3jIr3+SfG190UUMKk=
github.com/diogox/bspc-go v0.0.0-20210514160037-5a5903da7ba2 h1:lQFx9jHXfA83GQLtfhmU+UAcyFRJDatvLDI+8kLmN+4=
github.com/diogox/bspc-go v0.0.0-20210514160037-5a5903da7ba2/go.mod h1:d4jYBJhdGS8dxKhiT6+AMbjjUE3jIr3+SfG190UUMKk=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
Expand All @@ -35,12 +41,16 @@ github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down Expand Up @@ -141,6 +151,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
42 changes: 42 additions & 0 deletions internal/feature/transparent_monocle/transparent_monocle.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,48 @@ func Start(
return nil
})

service.Events().On(bspc.EventTypeNodeState, func(eventPayload interface{}) error {
payload, ok := eventPayload.(bspc.EventNodeState)
if !ok {
return errors.New("invalid event payload")
}

if payload.State != bspc.StateTypeFloating {
// Ignore state change
return nil
}

if _, ok := desktops.Get(payload.DesktopID); !ok {
return nil
}

switch payload.WasEnabled {
case true:
err := handleNodeRemoved(logger, service, desktops, payload.DesktopID, payload.NodeID)
if err != nil {
logger.Error("failed to handle removing floating node",
zap.Uint("desktop_id", uint(payload.DesktopID)),
zap.Error(err),
)

return err
}

case false:
err := handleNodeAdded(logger, service, desktops, payload.DesktopID, payload.NodeID)
if err != nil {
logger.Error("failed to handle adding un-floated node",
zap.Uint("desktop_id", uint(payload.DesktopID)),
zap.Error(err),
)

return err
}
}

return nil
})

cancelFunc, err := service.Events().Start()
if err != nil {
return nil, nil, fmt.Errorf("failed to start event manager")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestNewTransparentMonocle(t *testing.T) {
mockService.EXPECT().
Events().
Return(mockEventManager).
Times(6)
Times(7)
mockEventManager.EXPECT().
On(bspc.EventTypeNodeAdd, gomock.Any())
mockEventManager.EXPECT().
Expand All @@ -45,6 +45,8 @@ func TestNewTransparentMonocle(t *testing.T) {
On(bspc.EventTypeNodeSwap, gomock.Any())
mockEventManager.EXPECT().
On(bspc.EventTypeDesktopFocus, gomock.Any())
mockEventManager.EXPECT().
On(bspc.EventTypeNodeState, gomock.Any())
mockEventManager.EXPECT().
Start().
Return(nil, nil)
Expand Down
8 changes: 4 additions & 4 deletions internal/grpc/bspm/bspm.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/grpc/bspm/bspm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package ipc;

option go_package = ".;bspm";
option go_package = "./;bspm";

import "google/protobuf/empty.proto";

Expand Down

0 comments on commit 4f2a042

Please sign in to comment.