From aeeddc72abcaf5c21f614b60c19c4807e6b804e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kenneth=20S=C3=B6derlund?= Date: Fri, 2 Jan 2026 13:44:25 +0200 Subject: [PATCH] feat: add new event and action models Add the new MaximizeWindowToEdges action, ScreenshotCaptured and WindowFocusTimestampChanged event models. --- actions/actions.go | 1 + actions/models.go | 8 ++++++++ events/events.go | 2 ++ events/models.go | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/actions/actions.go b/actions/actions.go index e655baa..a630dfa 100644 --- a/actions/actions.go +++ b/actions/actions.go @@ -163,6 +163,7 @@ var ActionRegistry = map[string]func() Action{ "FullscreenWindow": func() Action { return &FullscreenWindow{AName: AName{Name: "FullscreenWindow"}} }, "LoadConfigFile": func() Action { return &LoadConfigFile{AName: AName{Name: "LoadConfigFile"}} }, "MaximizeColumn": func() Action { return &MaximizeColumn{AName: AName{Name: "MaximizeColumn"}} }, + "MaximizeWindowToEdges": func() Action { return &MaximizeWindowToEdges{AName: AName{Name: "MaximizeWindowToEdges"}} }, "MoveColumnLeft": func() Action { return &MoveColumnLeft{AName: AName{Name: "MoveColumnLeft"}} }, "MoveColumnLeftOrToMonitorLeft": func() Action { return &MoveColumnLeftOrToMonitorLeft{AName: AName{Name: "MoveColumnLeftOrToMonitorLeft"}} diff --git a/actions/models.go b/actions/models.go index cc893a7..a87a27f 100644 --- a/actions/models.go +++ b/actions/models.go @@ -667,6 +667,14 @@ type MaximizeColumn struct { AName } +// MaximizeWindowToEdges toggles the maximized-to-edges state of the focused window. +type MaximizeWindowToEdges struct { + AName + + // ID of the window to maximize. + ID uint64 `json:"id,omitempty"` +} + // SetColumnWidth changes the width of the focused column. type SetColumnWidth struct { AName diff --git a/events/events.go b/events/events.go index 0074ae3..2788f1a 100644 --- a/events/events.go +++ b/events/events.go @@ -326,8 +326,10 @@ var EventRegistry = map[string]func() Event{ "KeyboardLayoutSwitched": func() Event { return &KeyboardLayoutSwitched{EName: EName{Name: "KeyboardLayoutSwitched"}} }, "KeyboardLayoutsChanged": func() Event { return &KeyboardLayoutsChanged{EName: EName{Name: "KeyboardLayoutsChanged"}} }, "OverviewOpenedOrClosed": func() Event { return &OverviewOpenedOrClosed{EName: EName{Name: "OverviewOpenedOrClosed"}} }, + "ScreenshotCaptured": func() Event { return &ScreenshotCaptured{EName: EName{Name: "ScreenshotCaptured"}} }, "WindowClosed": func() Event { return &WindowClosed{EName: EName{Name: "WindowClosed"}} }, "WindowFocusChanged": func() Event { return &WindowFocusChanged{EName: EName{Name: "WindowFocusChanged"}} }, + "WindowFocusTimestampChanged": func() Event { return &WindowFocusTimestampChanged{EName: EName{Name: "WindowFocusTimestampChanged"}} }, "WindowLayoutsChanged": func() Event { return &WindowLayoutsChanged{EName: EName{Name: "WindowLayoutsChanged"}} }, "WindowOpenedOrChanged": func() Event { return &WindowOpenedOrChanged{EName: EName{Name: "WindowOpenedOrChanged"}} }, "WindowUrgencyChanged": func() Event { return &WindowUrgencyChanged{EName: EName{Name: "WindowUrgencyChanged"}} }, diff --git a/events/models.go b/events/models.go index 6adc6bf..832eba9 100644 --- a/events/models.go +++ b/events/models.go @@ -237,3 +237,41 @@ type ConfigLoaded struct { // fails. Failed bool `json:"failed"` } + +// ScreenshotCaptured when a screenshot was captured. +type ScreenshotCaptured struct { + EName + // Path indicates the file path where the screenshot was saved, if it was written to disk. + // + // If None, the screenshot was wither only copied to the clipboard, or the path couldn't be + // converted to a String (e.g. contained invalid UTF-8 bytes). + Path string `json:"path,omitempty"` +} + +// Timestamp is a moment in time +type Timestamp struct { + // Secs is the number of whole seconds. + Secs uint64 `json:"secs,omitempty"` + // Nanos is the fractional part of the timestamp in nanoseconds. + Nanos uint32 `json:"nanos,omitempty"` +} + +// WindowFocusTimestampChanged when the window focus timestamp changed. +// +// This event is separate from WindowFocusChanged because the focus timestamp only updates after some +// debounce time so that quick window switching doesn't mark intermediate windows as recently focused. +type WindowFocusTimestampChanged struct { + EName + // Id is the window ID. + ID uint64 `json:"id"` + // FocusTimestamp is the new focus timestamp. + FocusTimestamp Timestamp `json:"focus_timestamp"` +} + +// GetPossibleKeys extracts the window ID from this event. +func (w WindowFocusTimestampChanged) GetPossibleKeys() models.PossibleKeys { + return models.PossibleKeys{ + ID: w.ID, + WindowID: w.ID, + } +}