232 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			232 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package niri
 | |
| 
 | |
| import "encoding/json"
 | |
| 
 | |
| type Event interface {
 | |
| 	private()
 | |
| }
 | |
| 
 | |
| type eventContainer struct {
 | |
| 	EventWorkspacesChanged            *EventWorkspacesChanged            `json:"WorkspacesChanged,omitempty"`
 | |
| 	EventWorkspaceUrgencyChanged      *EventWorkspaceUrgencyChanged      `json:"WorkspaceUrgencyChanged,omitempty"`
 | |
| 	EventWorkspaceActivated           *EventWorkspaceActivated           `json:"WorkspaceActivated,omitempty"`
 | |
| 	EventWorkspaceActiveWindowChanged *EventWorkspaceActiveWindowChanged `json:"WorkspaceActiveWindowChanged,omitempty"`
 | |
| 	EventWindowsChanged               *EventWindowsChanged               `json:"WindowsChanged,omitempty"`
 | |
| 	EventWindowOpenedOrChanged        *EventWindowOpenedOrChanged        `json:"WindowOpenedOrChanged,omitempty"`
 | |
| 	EventWindowClosed                 *EventWindowClosed                 `json:"WindowClosed,omitempty"`
 | |
| 	EventWindowFocusChanged           *EventWindowFocusChanged           `json:"WindowFocusChanged,omitempty"`
 | |
| 	EventWindowUrgencyChanged         *EventWindowUrgencyChanged         `json:"WindowUrgencyChanged,omitempty"`
 | |
| 	EventWindowLayoutsChanged         *EventWindowLayoutsChanged         `json:"WindowLayoutsChanged,omitempty"`
 | |
| 	EventKeyboardLayoutsChanged       *EventKeyboardLayoutsChanged       `json:"KeyboardLayoutsChanged,omitempty"`
 | |
| 	EventKeyboardLayoutSwitched       *EventKeyboardLayoutSwitched       `json:"KeyboardLayoutSwitched,omitempty"`
 | |
| 	EventOverviewOpenedOrClosed       *EventOverviewOpenedOrClosed       `json:"OverviewOpenedOrClosed,omitempty"`
 | |
| 	EventConfigLoaded                 *EventConfigLoaded                 `json:"ConfigLoaded,omitempty"`
 | |
| }
 | |
| 
 | |
| func (m *eventContainer) String() string {
 | |
| 	data, _ := json.Marshal(m)
 | |
| 	return string(data)
 | |
| }
 | |
| 
 | |
| 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.EventWindowLayoutsChanged != nil {
 | |
| 		return c.EventWindowLayoutsChanged
 | |
| 	} else if c.EventKeyboardLayoutsChanged != nil {
 | |
| 		return c.EventKeyboardLayoutsChanged
 | |
| 	} else if c.EventKeyboardLayoutSwitched != nil {
 | |
| 		return c.EventKeyboardLayoutSwitched
 | |
| 	} else if c.EventOverviewOpenedOrClosed != nil {
 | |
| 		return c.EventOverviewOpenedOrClosed
 | |
| 	} else if c.EventConfigLoaded != nil {
 | |
| 		return c.EventConfigLoaded
 | |
| 	}
 | |
| 
 | |
| 	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 EventWindowLayoutsChanged struct {
 | |
| 	Changes []WindowLayoutChange `json:"changes"`
 | |
| }
 | |
| 
 | |
| func (m *EventWindowLayoutsChanged) private() {}
 | |
| 
 | |
| func (m *EventWindowLayoutsChanged) 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)
 | |
| }
 | |
| 
 | |
| type EventConfigLoaded struct {
 | |
| 	Failed bool `json:"failed"`
 | |
| }
 | |
| 
 | |
| func (m *EventConfigLoaded) private() {}
 | |
| 
 | |
| func (m *EventConfigLoaded) String() string {
 | |
| 	data, _ := json.Marshal(m)
 | |
| 	return string(data)
 | |
| }
 |