# gpui: Add input region support for Wayland windows \(\#60161\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/a29c0d41f4787d7cd268d4f8ad1a706af86042c7)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: a29c0d41f4787d7cd268d4f8ad1a706af86042c7

Requested commit: a29c0d41f4787d7cd268d4f8ad1a706af86042c7

Commit: a29c0d41f4787d7cd268d4f8ad1a706af86042c7

Tree: 6b021a0c7643bac8950799c47786a5cc42bd2e2f

Author: Philipp Schaffrath

Committer: GitHub

## Message

```
gpui: Add input region support for Wayland windows (#60161)

# Objective

Wayland windows have no way to restrict which parts of the surface
accept pointer and touch input. This adds support for setting an input
region, so events outside it pass through to whatever is below the
window. This is useful for shaped or partially click-through windows.


Clicks in green area can pass through the window, clicks in red area do
not:
<img width="1057" height="395" alt="image"
src="https://github.com/user-attachments/assets/2039af62-e43b-4834-b877-edad2a8f5ccf"
/>

## Solution

Add `Window::set_input_region`, which takes `Option<&[Bounds<Pixels>]>`:

- `Some(rects)` restricts pointer and touch input to the union of the
rectangles, in window coordinates.
- `Some(&[])` is an empty region, so the window receives no input at all
and is fully click-through.
- `None` resets the region to the default, so the whole window receives
input again.

On Wayland this maps to `wl_surface.set_input_region`, building a
`wl_region` from the rectangles or clearing it for `None`, and commits
so the change applies immediately rather than waiting for the next
frame. The method is a no-op on other platforms.


## Testing

Tested on Linux with Wayland.

- Tested in my own GPUI application, which uses a fullscreen layer for
overlays while allowing clicks outside of the rendered elements to be
passed through to the underlying windows.
- No automated test was added, since this calls through to the
compositor and is checked by observing input routing.


## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- N/A
```

## Parents

- [fcd0f769521884e71b9b54ab964bd88cf057a276](https://git.cafe/gitcafe/zed/commit/fcd0f769521884e71b9b54ab964bd88cf057a276?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/a29c0d41f4787d7cd268d4f8ad1a706af86042c7?format=markdown)
