gpui_linux: Discard stale Wayland file drag reads (#64122)

## Objective

Prevent canceled external file drags on Linux Wayland from becoming
active again after the native drag session has already left the Zed
window.

This is a rare timing-sensitive race. When it occurs, the stale external
drag remains active inside GPUI. Ordinary mouse movement then behaves
like drag movement throughout Zed, and a later unrelated click can drop
or copy the previously dragged file into the project panel.

The issue was observed on Fedora 44 with GNOME Wayland, with the drag
originating in GNOME Files.

## Cause

The Wayland destination path reads the drag's `text/uri-list` payload
asynchronously.

Before this change, `state.drag.window` and `state.drag.data_offer` were
installed only after that asynchronous read completed. If
`wl_data_device::Event::Leave` arrived first, it found no installed
destination and returned. The detached read could then complete and
dispatch a stale `FileDropEvent::Entered` after the native drag had
already ended.

Rapidly entering and leaving Zed could also create multiple overlapping
URI reads whose stale completions replaced one another.

With a temporary delay added to make the timing deterministic, the
failing sequence was:

```text
entered: offer=81
left: active_offer=None, had_window=false
paths ready: offer=81
installing destination: offer=81, previous_offer=None
```

Two overlapping stale completions produced:

```text
installing destination: offer=80,
    previous_offer=Some(offer=81),
    had_window=true
```

The temporary delay and diagnostics are not included in this PR.

## Solution

Associate each asynchronous drag URI read with a monotonically
increasing generation.

- A new `Enter` begins a new generation and invalidates an older pending
read.
- `Leave` invalidates the current pending read.
- `Drop` invalidates the current pending read.
- Before installing the destination and dispatching
`FileDropEvent::Entered`, the asynchronous task verifies that its
generation is still current.
- Stale completions destroy their data offer and return without creating
an active GPUI drag.

Normal drags whose URI reads complete before a terminal event continue
through the existing path unchanged.

## Testing

- Added a unit test covering:
  - A newer drag invalidating an older URI read.
  - A terminal drag event invalidating the current URI read.
- Reproduced the race deterministically with a temporary two-second
delay before destination installation.
- Verified that stale completions are discarded with the fix and no
longer cause ordinary mouse movement or clicks to act on the old file.
- Ran:

```text
cargo test -p gpui_linux invalidates_stale_drag_uri_reads
cargo check -p gpui_linux
cargo build -p zed
git diff --check
```

Release Notes:

- Fixed canceled external file drags on Linux Wayland sometimes
remaining active and causing later clicks to copy the dragged file.
87a1ea30e8itsfuad committed on 9/12/2026, 6:16:10 PM· committed by GitHubparenta2651e3
1 file changedLine totals unavailable