---
title: "Recipe: the displays and the pointer"
description: "@exact/window-management (LLP 1178): the displays by the web's Window Management API, and where the pointer is, which the web cannot ask."
modificationDate: "2026-11-24"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: the displays and the pointer

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/displays: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

`@exact/window-management` (LLP 1178): the displays by the web's
[Window Management API](https://w3c.github.io/window-management/), and
where the pointer is, which the web cannot ask:

```prompt Read the displays and the pointer position
Make the Exact app in this folder read the displays and where the pointer is, and place its UI by them. Use https://github.com/expo/exact/blob/main/docs/recipes/displays.md as the source for each step. The Exact checkout has the same page at docs/recipes/displays.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. If I did not say what the app does with the displays or the pointer, propose it (for example, a toolbar on the display that holds the pointer) and ask me before you write code. The web cannot ask where the pointer is.
3. Install the package: `bun exact.mjs add @exact/window-management`. In app.ts, add `device.window-management` to the grants.
4. In app.contract, read `getScreenDetails()` and `windowManagementStatus()` as resources, and send `getPointerPosition()` from an action. `getScreenDetails()` is a live source: it answers again when a display or the window's display changes, so do not poll it. Coordinates are CSS pixels whose origin is the primary display's top left.
5. On the web the browser asks the person, and Chrome asks only from a press. While `state` is `prompt`, show a button that refreshes the resource: a read at load fails `NotAllowedError` there.
6. To place UI on the display that holds the pointer, ask once and place it inside that display's `clientRect`, as the recipe's `Overlay` shows. Handle `none` for the pointer's answer and for `clientRect` (no window).
7. In app.test.contract, use `test "…" on web` for the display list, led by `prefer permission.window-management granted`. Expect one 1440 by 900 display at scale 2. Use `test "…" on macos, linux, windows` for the same display and a pointer at its centre, with the window at its top left. Only the web test sets the permission. For other answers, use `prefer extension window-management.getScreenDetails={…}` or `prefer extension window-management.getPointerPosition={…}` in a drive on a host that supports the call, with each answer supplied as a whole value.
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me what the app reads and where it places its UI, what the tests, the drive and the checks reported, and how a drive reads the real displays: `--bind window-management` (macOS, Linux and Windows).
```

- `getScreenDetails()`: `screens`, each a `ScreenDetailed` (`left`, `top`,
  `width`, `height`, the work area `availLeft` … `availHeight`,
  `devicePixelRatio`, `isPrimary`, `isInternal`, `label`), and
  `currentScreen`, the one holding most of the app's window. Coordinates
  are CSS pixels whose origin is the primary display's top left, y
  downward, as `window.screenX` is. It is a live source: it answers again
  when a display is added, removed, rearranged or rescaled, and when the
  window moves to another display.
- `getPointerPosition()`: a send answering `MouseEvent`'s `screenX`,
  `screenY` (that space) and `clientX`, `clientY` (the viewport's CSS
  pixels, negative or past the viewport's size outside it), and `screen`,
  the display holding the pointer, with `clientRect`: that display's
  rectangle in the viewport.
- `windowManagementStatus()`: `{available, state}`.

The app declares `device.window-management` in its grants (`app.ts`).
Natively nothing asks the person. On the web the browser asks, and Chrome
asks only from a press: a read at load while the state is `prompt` fails
`NotAllowedError`, so offer a button that refreshes the resource.

To put a toolbar on the display that holds the pointer, in a window that
spans several, ask once and place it inside that display's `clientRect`:

```text
use getScreenDetails, getPointerPosition, windowManagementStatus, ScreenDetails, PointerPosition, WindowManagementStatus from "@exact/window-management"

component Overlay
  resource details = getScreenDetails() as shape ScreenDetails else empty()
  resource status = windowManagementStatus() as shape WindowManagementStatus else empty(available=false, state="denied")
  mutation at as shape PointerPosition
  action open
    send at = getPointerPosition()
  action allow
    refresh details
  view
    main
      if status.state == "prompt"
        button press=allow
          text "Show the displays"
      match at
        case some(p)
          match p.screen.clientRect
            case some(r)
              row position="absolute" left=(r.x + r.width / 2 - 160) top=(r.y + 24) width=320
                button press=open
                  text "Crop"
            case none
              text "No window"
        case none
          button press=open
            text "Start"
```

See [host support](https://exact.expo.dev/reference/developer/generate-typescript-data-source-types.md#the-displays-and-the-pointer-exactwindow-management) and [window bounds](https://exact.expo.dev/recipes/window-bounds.md).

The agent supplies one 1440 × 900 display at scale 2, the pointer centred
and the window at its top left. A drive replaces
either with `prefer extension window-management.getScreenDetails={…}` or
`window-management.getPointerPosition={…}`, each a whole value; on the web
the first read raises a permission ticket. `--bind window-management`
reads the platform (macOS, Linux, Windows).
