199 lines
5.4 KiB
Go
199 lines
5.4 KiB
Go
package niri
|
|
|
|
import "encoding/json"
|
|
|
|
type Event interface {
|
|
private()
|
|
}
|
|
|
|
type eventContainer struct {
|
|
EventWorkspacesChanged *EventWorkspacesChanged `json:"WorkspacesChanged"`
|
|
EventWorkspaceUrgencyChanged *EventWorkspaceUrgencyChanged `json:"WorkspaceUrgencyChanged"`
|
|
EventWorkspaceActivated *EventWorkspaceActivated `json:"WorkspaceActivated"`
|
|
EventWorkspaceActiveWindowChanged *EventWorkspaceActiveWindowChanged `json:"WorkspaceActiveWindowChanged"`
|
|
EventWindowsChanged *EventWindowsChanged `json:"WindowsChanged"`
|
|
EventWindowOpenedOrChanged *EventWindowOpenedOrChanged `json:"WindowOpenedOrChanged"`
|
|
EventWindowClosed *EventWindowClosed `json:"WindowClosed"`
|
|
EventWindowFocusChanged *EventWindowFocusChanged `json:"WindowFocusChanged"`
|
|
EventWindowUrgencyChanged *EventWindowUrgencyChanged `json:"WindowUrgencyChanged"`
|
|
EventKeyboardLayoutsChanged *EventKeyboardLayoutsChanged `json:"KeyboardLayoutsChanged"`
|
|
EventKeyboardLayoutSwitched *EventKeyboardLayoutSwitched `json:"KeyboardLayoutSwitched"`
|
|
EventOverviewOpenedOrClosed *EventOverviewOpenedOrClosed `json:"OverviewOpenedOrClosed"`
|
|
}
|
|
|
|
func (c *eventContainer) event() Event {
|
|
if c.EventWorkspacesChanged != nil {
|
|
return c.EventWorkspacesChanged
|
|
} else if c.EventWorkspaceUrgencyChanged != nil {
|
|
return c.EventWorkspaceUrgencyChanged
|
|
} else if c.EventWorkspaceActivated != nil {
|
|
return c.EventWorkspaceActivated
|
|
} else if c.EventWorkspaceActiveWindowChanged != nil {
|
|
return c.EventWorkspaceActiveWindowChanged
|
|
} else if c.EventWindowsChanged != nil {
|
|
return c.EventWindowsChanged
|
|
} else if c.EventWindowOpenedOrChanged != nil {
|
|
return c.EventWindowOpenedOrChanged
|
|
} else if c.EventWindowClosed != nil {
|
|
return c.EventWindowClosed
|
|
} else if c.EventWindowFocusChanged != nil {
|
|
return c.EventWindowFocusChanged
|
|
} else if c.EventWindowUrgencyChanged != nil {
|
|
return c.EventWindowUrgencyChanged
|
|
} else if c.EventKeyboardLayoutsChanged != nil {
|
|
return c.EventKeyboardLayoutsChanged
|
|
} else if c.EventKeyboardLayoutSwitched != nil {
|
|
return c.EventKeyboardLayoutSwitched
|
|
} else if c.EventOverviewOpenedOrClosed != nil {
|
|
return c.EventOverviewOpenedOrClosed
|
|
}
|
|
|
|
return &EventInvalid{}
|
|
}
|
|
|
|
type EventInvalid struct {
|
|
}
|
|
|
|
func (m *EventInvalid) private() {}
|
|
|
|
func (m *EventInvalid) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWorkspacesChanged struct {
|
|
Workspaces []Workspace `json:"workspaces"`
|
|
}
|
|
|
|
func (m *EventWorkspacesChanged) private() {}
|
|
|
|
func (m *EventWorkspacesChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWorkspaceUrgencyChanged struct {
|
|
ID WorkspaceID `json:"id"`
|
|
Urgent bool `json:"urgent"`
|
|
}
|
|
|
|
func (m *EventWorkspaceUrgencyChanged) private() {}
|
|
|
|
func (m *EventWorkspaceUrgencyChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWorkspaceActivated struct {
|
|
ID WorkspaceID `json:"id"`
|
|
Focused bool `json:"focused"`
|
|
}
|
|
|
|
func (m *EventWorkspaceActivated) private() {}
|
|
|
|
func (m *EventWorkspaceActivated) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWorkspaceActiveWindowChanged struct {
|
|
WorkspaceID WorkspaceID `json:"workspace_id"`
|
|
ActiveWindowID Option[WindowID] `json:"active_window_id"`
|
|
}
|
|
|
|
func (m *EventWorkspaceActiveWindowChanged) private() {}
|
|
|
|
func (m *EventWorkspaceActiveWindowChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWindowsChanged struct {
|
|
Windows []Window `json:"windows"`
|
|
}
|
|
|
|
func (m *EventWindowsChanged) private() {}
|
|
|
|
func (m *EventWindowsChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWindowOpenedOrChanged struct {
|
|
Window Window `json:"window"`
|
|
}
|
|
|
|
func (m *EventWindowOpenedOrChanged) private() {}
|
|
|
|
func (m *EventWindowOpenedOrChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWindowClosed struct {
|
|
ID WindowID `json:"id"`
|
|
}
|
|
|
|
func (m *EventWindowClosed) private() {}
|
|
|
|
func (m *EventWindowClosed) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWindowFocusChanged struct {
|
|
ID Option[WindowID] `json:"id"`
|
|
}
|
|
|
|
func (m *EventWindowFocusChanged) private() {}
|
|
|
|
func (m *EventWindowFocusChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventWindowUrgencyChanged struct {
|
|
ID WindowID `json:"id"`
|
|
Urgent bool `json:"urgent"`
|
|
}
|
|
|
|
func (m *EventWindowUrgencyChanged) private() {}
|
|
|
|
func (m *EventWindowUrgencyChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventKeyboardLayoutsChanged struct {
|
|
KeyboardLayouts KeyboardLayouts `json:"keyboard_layouts"`
|
|
}
|
|
|
|
func (m *EventKeyboardLayoutsChanged) private() {}
|
|
|
|
func (m *EventKeyboardLayoutsChanged) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventKeyboardLayoutSwitched struct {
|
|
Index int `json:"idx"`
|
|
}
|
|
|
|
func (m *EventKeyboardLayoutSwitched) private() {}
|
|
|
|
func (m *EventKeyboardLayoutSwitched) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|
|
|
|
type EventOverviewOpenedOrClosed struct {
|
|
IsOpen bool `json:"is_open"`
|
|
}
|
|
|
|
func (m *EventOverviewOpenedOrClosed) private() {}
|
|
|
|
func (m *EventOverviewOpenedOrClosed) String() string {
|
|
data, _ := json.Marshal(m)
|
|
return string(data)
|
|
}
|