Search documentation of Plushie

# Plushie.Command.Window (Plushie v0.7.2)

Copy Markdown View Source

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`

## Summary

### Functions

close_window(window_id)

Close the window identified by `window_id`.

disable_mouse_passthrough(window_id)

Disable mouse passthrough on a window.

drag_resize_window(window_id, direction)

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

drag_window(window_id)

Start dragging the window.

enable_mouse_passthrough(window_id)

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

focus_window(window_id)

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

maximize_window(window_id, maximized \\ true)

Maximize or restore a window.

minimize_window(window_id, minimized \\ true)

Minimize or restore a window.

move_window(window_id, x, y)

Move a window to the given position.

request_attention(window_id, urgency \\ nil)

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

resize_window(window_id, width, height)

Resize a window to the given dimensions.

screenshot(window_id, tag)

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

set_icon(window_id, rgba_data, width, height)

Sets the window icon from raw RGBA pixel data.

set_max_size(window_id, width, height)

Set the maximum size of a window.

set_min_size(window_id, width, height)

Set the minimum size of a window.

set_resizable(window_id, resizable)

Set whether a window is resizable.

set_resize_increments(window_id, width, height)

Sets the resize increment size for a window.

set_window_level(window_id, level)

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

set_window_mode(window_id, mode)

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

show_system_menu(window_id)

Show the system menu for a window.

toggle_decorations(window_id)

Toggle window decorations (title bar, borders).

toggle_maximize(window_id)

Toggle window maximized state.

## Functions

# close_window(window_id)

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

Close the window identified by `window_id`.

# disable_mouse_passthrough(window_id)

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

Disable mouse passthrough on a window.

# drag_resize_window(window_id, direction)

    @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(window_id)

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

Start dragging the window.

# enable_mouse_passthrough(window_id)

    @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(window_id)

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

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

# maximize_window(window_id, maximized \\ true)

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

Maximize or restore a window.

# minimize_window(window_id, minimized \\ true)

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

Minimize or restore a window.

# move_window(window_id, x, y)

    @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(window_id, urgency \\ nil)

    @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(window_id, width, height)

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

Resize a window to the given dimensions.

# screenshot(window_id, tag)

    @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(window_id, rgba_data, width, height)

    @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(window_id, width, height)

    @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(window_id, width, height)

    @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(window_id, resizable)

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

Set whether a window is resizable.

# set_resize_increments(window_id, width, height)

    @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(window_id, level)

    @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(window_id, mode)

    @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(window_id)

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

Show the system menu for a window.

# toggle_decorations(window_id)

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

Toggle window decorations (title bar, borders).

# toggle_maximize(window_id)

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

Toggle window maximized state.