-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
event: import event code from labi-le/hyprland-ipc-client
- Loading branch information
1 parent
ca14584
commit 5ef89fc
Showing
4 changed files
with
379 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package event | ||
|
||
type DummyEvHandler struct{} | ||
|
||
func (e *DummyEvHandler) Workspace(WorkspaceName) {} | ||
func (e *DummyEvHandler) FocusedMonitor(FocusedMonitor) {} | ||
func (e *DummyEvHandler) ActiveWindow(ActiveWindow) {} | ||
func (e *DummyEvHandler) Fullscreen(bool) {} | ||
func (e *DummyEvHandler) MonitorRemoved(MonitorName) {} | ||
func (e *DummyEvHandler) MonitorAdded(MonitorName) {} | ||
func (e *DummyEvHandler) CreateWorkspace(WorkspaceName) {} | ||
func (e *DummyEvHandler) DestroyWorkspace(WorkspaceName) {} | ||
func (e *DummyEvHandler) MoveWorkspace(MoveWorkspace) {} | ||
func (e *DummyEvHandler) ActiveLayout(ActiveLayout) {} | ||
func (e *DummyEvHandler) OpenWindow(OpenWindow) {} | ||
func (e *DummyEvHandler) CloseWindow(CloseWindow) {} | ||
func (e *DummyEvHandler) MoveWindow(MoveWindow) {} | ||
func (e *DummyEvHandler) OpenLayer(OpenLayer) {} | ||
func (e *DummyEvHandler) CloseLayer(CloseLayer) {} | ||
func (e *DummyEvHandler) SubMap(SubMap) {} | ||
func (e *DummyEvHandler) Screencast(Screencast) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,119 @@ | ||
package hyprland | ||
package event | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
var ec *EventClient | ||
|
||
func init() { | ||
if os.Getenv("HYPRLAND_INSTANCE_SIGNATURE") != "" { | ||
ec = MustEventClient() | ||
} | ||
var ( | ||
h = &FakeEventHandler{} | ||
c = &FakeEventClient{} | ||
) | ||
|
||
type FakeEventClient struct { | ||
EventClient | ||
} | ||
|
||
func TestReceive(t *testing.T) { | ||
t.Skip("temporary disabled") | ||
type FakeEventHandler struct { | ||
DummyEvHandler | ||
} | ||
|
||
func (f *FakeEventClient) Receive() ([]ReceivedData, error) { | ||
return []ReceivedData{ | ||
{ | ||
Type: EventWorkspace, | ||
Data: "1", | ||
}, | ||
{ | ||
Type: EventFocusedMonitor, | ||
Data: "1,1", | ||
// TODO I only have one monitor, so I didn't check this | ||
}, | ||
{ | ||
Type: EventActiveWindow, | ||
Data: "jetbrains-goland,hyprland-ipc-ipc – ipc.go", | ||
}, | ||
{ | ||
Type: EventFullscreen, | ||
Data: "1", | ||
}, | ||
{ | ||
Type: EventMonitorRemoved, | ||
Data: "1", | ||
// TODO I only have one monitor, so I didn't check this | ||
}, | ||
{ | ||
Type: EventMonitorAdded, | ||
Data: "1", | ||
// TODO I only have one monitor, so I didn't check this | ||
}, | ||
{ | ||
Type: EventCreateWorkspace, | ||
Data: "1", | ||
}, | ||
{ | ||
Type: EventDestroyWorkspace, | ||
Data: "1", | ||
}, | ||
|
||
{ | ||
Type: EventMoveWorkspace, | ||
Data: "1,1", | ||
// TODO I only have one monitor, so I didn't check this | ||
}, | ||
{ | ||
Type: EventActiveLayout, | ||
Data: "AT Translated Set 2 keyboard,Russian", | ||
}, | ||
{ | ||
Type: EventOpenWindow, | ||
Data: "80e62df0,2,jetbrains-goland,win430", | ||
}, | ||
{ | ||
Type: EventCloseWindow, | ||
Data: "80e62df0", | ||
}, | ||
{ | ||
Type: EventMoveWindow, | ||
Data: "80e62df0,1", | ||
}, | ||
{ | ||
Type: EventOpenLayer, | ||
Data: "wofi", | ||
}, | ||
{ | ||
Type: EventCloseLayer, | ||
Data: "wofi", | ||
}, | ||
{ | ||
Type: EventSubMap, | ||
Data: "1", | ||
// idk | ||
}, | ||
{ | ||
Type: EventScreencast, | ||
Data: "1,0", | ||
}, | ||
}, nil | ||
} | ||
|
||
msg, err := ec.Receive() | ||
func TestSubscribe(t *testing.T) { | ||
err := c.SubscribeWithoutLoop(h, GetAllEvents()...) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Log(msg) | ||
} | ||
|
||
func (c *FakeEventClient) SubscribeWithoutLoop(ev EventHandler, events ...EventType) error { | ||
msg, err := c.Receive() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, data := range msg { | ||
processEvent(ev, data, events) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.