# `Plushie.Command.Window`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/command/window.ex#L1)

Window operation commands.

## Lifecycle

`close_window/1`

## Sizing and position

`resize_window/3`, `move_window/3`, `set_min_size/3`, `set_max_size/3`,
`set_resize_increments/3`, `set_resizable/2`

## Window state

`maximize_window/2`, `minimize_window/2`, `toggle_maximize/1`,
`set_window_mode/2`, `toggle_decorations/1`, `set_window_level/2`

## Focus and interaction

`focus_window/1`, `drag_window/1`, `drag_resize_window/2`,
`request_attention/2`, `show_system_menu/1`

## Input

`enable_mouse_passthrough/1`, `disable_mouse_passthrough/1`

## Visuals

`set_icon/4`, `screenshot/2`

# `close_window`

```elixir
@spec close_window(window_id :: Plushie.Command.window_id()) :: Plushie.Command.t()
```

Close the window identified by `window_id`.

# `disable_mouse_passthrough`

```elixir
@spec disable_mouse_passthrough(window_id :: Plushie.Command.window_id()) ::
  Plushie.Command.t()
```

Disable mouse passthrough on a window.

# `drag_resize_window`

```elixir
@spec drag_resize_window(
  window_id :: Plushie.Command.window_id(),
  direction :: atom() | String.t()
) ::
  Plushie.Command.t()
```

Start drag-resizing the window from the given edge/corner direction.

# `drag_window`

```elixir
@spec drag_window(window_id :: Plushie.Command.window_id()) :: Plushie.Command.t()
```

Start dragging the window.

# `enable_mouse_passthrough`

```elixir
@spec enable_mouse_passthrough(window_id :: Plushie.Command.window_id()) ::
  Plushie.Command.t()
```

Enable mouse passthrough on a window (clicks pass through to windows below).

# `focus_window`

```elixir
@spec focus_window(window_id :: Plushie.Command.window_id()) :: Plushie.Command.t()
```

Give focus to a window, bringing it to the front.

# `maximize_window`

```elixir
@spec maximize_window(
  window_id :: Plushie.Command.window_id(),
  maximized :: boolean()
) ::
  Plushie.Command.t()
```

Maximize or restore a window.

# `minimize_window`

```elixir
@spec minimize_window(
  window_id :: Plushie.Command.window_id(),
  minimized :: boolean()
) ::
  Plushie.Command.t()
```

Minimize or restore a window.

# `move_window`

```elixir
@spec move_window(
  window_id :: Plushie.Command.window_id(),
  x :: number(),
  y :: number()
) ::
  Plushie.Command.t()
```

Move a window to the given position.

# `request_attention`

```elixir
@spec request_attention(
  window_id :: Plushie.Command.window_id(),
  urgency :: atom() | nil
) ::
  Plushie.Command.t()
```

Request user attention for a window. Urgency can be :informational or :critical.

# `resize_window`

```elixir
@spec resize_window(
  window_id :: Plushie.Command.window_id(),
  width :: number(),
  height :: number()
) ::
  Plushie.Command.t()
```

Resize a window to the given dimensions.

# `screenshot`

```elixir
@spec screenshot(
  window_id :: Plushie.Command.window_id(),
  tag :: Plushie.Command.event_tag()
) ::
  Plushie.Command.t()
```

Take a screenshot of a window. Result arrives as a tagged event.

# `set_icon`

```elixir
@spec set_icon(
  window_id :: Plushie.Command.window_id(),
  rgba_data :: binary(),
  width :: pos_integer(),
  height :: pos_integer()
) :: Plushie.Command.t()
```

Sets the window icon from raw RGBA pixel data.

The `rgba_data` must be a binary of `width * height * 4` bytes (one byte
each for R, G, B, A per pixel, row-major). The raw binary is stored as-is
in the command payload. The protocol layer handles format-specific encoding
(native binary for msgpack via Msgpax.Bin, base64 for JSON).

## Example

    icon_data = File.read!("icon_32x32.rgba")
    Plushie.Command.set_icon("main", icon_data, 32, 32)

# `set_max_size`

```elixir
@spec set_max_size(
  window_id :: Plushie.Command.window_id(),
  width :: number(),
  height :: number()
) ::
  Plushie.Command.t()
```

Set the maximum size of a window.

# `set_min_size`

```elixir
@spec set_min_size(
  window_id :: Plushie.Command.window_id(),
  width :: number(),
  height :: number()
) ::
  Plushie.Command.t()
```

Set the minimum size of a window.

# `set_resizable`

```elixir
@spec set_resizable(window_id :: Plushie.Command.window_id(), resizable :: boolean()) ::
  Plushie.Command.t()
```

Set whether a window is resizable.

# `set_resize_increments`

```elixir
@spec set_resize_increments(
  window_id :: Plushie.Command.window_id(),
  width :: number() | nil,
  height :: number() | nil
) :: Plushie.Command.t()
```

Sets the resize increment size for a window.

When set, the window will only resize in multiples of the given width and
height. Pass `nil` for both to clear the constraint. Useful for terminal
emulators and grid-aligned apps.

# `set_window_level`

```elixir
@spec set_window_level(
  window_id :: Plushie.Command.window_id(),
  level :: atom() | String.t()
) ::
  Plushie.Command.t()
```

Set window stacking level (:normal, :always_on_top, :always_on_bottom).

On Wayland, window stacking is compositor-controlled and this command may
be silently ignored.

# `set_window_mode`

```elixir
@spec set_window_mode(
  window_id :: Plushie.Command.window_id(),
  mode :: atom() | String.t()
) ::
  Plushie.Command.t()
```

Set window mode (windowed, fullscreen, etc.).

# `show_system_menu`

```elixir
@spec show_system_menu(window_id :: Plushie.Command.window_id()) ::
  Plushie.Command.t()
```

Show the system menu for a window.

# `toggle_decorations`

```elixir
@spec toggle_decorations(window_id :: Plushie.Command.window_id()) ::
  Plushie.Command.t()
```

Toggle window decorations (title bar, borders).

# `toggle_maximize`

```elixir
@spec toggle_maximize(window_id :: Plushie.Command.window_id()) :: Plushie.Command.t()
```

Toggle window maximized state.

---

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