# `MingaEditor.WindowFocus`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/window_focus.ex#L1)

Focused workflow for window focus, buffer cursor calls, and shell focus presentation.

# `focus_failure`

```elixir
@type focus_failure() ::
  :window_not_found | :cursor_source_mismatch | :buffer_unavailable
```

# `focus_result`

```elixir
@type focus_result() :: {:ok, state()} | {:error, focus_failure()}
```

# `state`

```elixir
@type state() :: MingaEditor.State.t()
```

# `focus`

```elixir
@spec focus(state(), MingaEditor.Window.id()) :: state()
```

Focuses a window after saving and restoring its buffer cursor state.

# `focus_result`

```elixir
@spec focus_result(state(), MingaEditor.Window.id()) :: focus_result()
```

Focuses a window and reports why an ownership-safe transition was rejected.

# `focus_surviving_window`

```elixir
@spec focus_surviving_window(
  state(),
  MingaEditor.State.Windows.t(),
  MingaEditor.Window.id()
) :: state()
```

Focuses a surviving window after the active split was removed.

# `remember_active_cursor`

```elixir
@spec remember_active_cursor(state()) :: state()
```

Snapshots the active cursor only when the active window owns its buffer source.

# `remember_active_cursor_result`

```elixir
@spec remember_active_cursor_result(state()) :: focus_result()
```

Snapshots the active cursor and reports ownership failures without changing state.

# `repair_focus`

```elixir
@spec repair_focus(state(), MingaEditor.Window.id()) :: {:ok, state()} | :error
```

Repairs a window with a viable buffer or empty surface, then restores focus to it.

# `restore_focus`

```elixir
@spec restore_focus(state(), MingaEditor.Window.id()) :: {:ok, state()} | :error
```

Restores focus without reading the outgoing window's buffer, for popup dismissal.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
