Skip to content

[0.30] X11: ignore mouse scroll button releases - #4823

Open
shtse8 wants to merge 1 commit into
rust-windowing:v0.30.xfrom
shtse8:fix/x11-wheel-release
Open

shtse8 wants to merge 1 commit into
rust-windowing:v0.30.xfrom
shtse8:fix/x11-wheel-release

Conversation

@shtse8

@shtse8 shtse8 commented Nov 7, 2026

Copy link
Copy Markdown

Backport #4386 (03dad26) to v0.30.x so one legacy X11 wheel notch emits one MouseWheel event instead of two.

The diff keeps the original direction and LineDelta magnitude and ignores the release for buttons 4–7. Ordinary mouse buttons, XIPointerEmulated filtering and XI2 scroll valuators are unchanged.

Reproduction on a real remote-desktop input path

I reproduced this with TigerVNC 1.12.0, using RFB PointerEvent messages rather than XTEST. A downward wheel notch is button mask 16 followed by 0. TigerVNC queues ButtonPress and ButtonRelease through vncPointerButtonAction.

  1. Run Xtigervnc :91 -geometry 1280x1024 -depth 24 -localhost yes -SecurityTypes None -rfbport 5991 on a private local display. Do not expose a no-authentication server externally.
  2. On DISPLAY=:91, run the small winit event-printing application in X11: KeyboardInput is dropped with PointerRoot focus #4822. Give its window explicit focus and keep (100,100) inside its client area.
  3. Send one RFB notch with the following client:
import socket
import struct
import time

with socket.create_connection(('127.0.0.1', 5991), timeout=5) as s:
    def read(n):
        data = b''
        while len(data) < n:
            part = s.recv(n - len(data))
            if not part:
                raise RuntimeError('RFB connection closed')
            data += part
        return data

    assert read(12) == b'RFB 003.008\n'
    s.sendall(b'RFB 003.008\n')
    types = read(read(1)[0])
    assert 1 in types
    s.sendall(b'\x01')
    assert read(4) == b'\0' * 4
    s.sendall(b'\x01')
    init = read(24)
    read(struct.unpack('>I', init[20:])[0])

    def pointer(mask):
        s.sendall(struct.pack('>BBHH', 5, mask, 100, 100))

    pointer(0)
    time.sleep(0.1)
    pointer(16)
    pointer(0)
    time.sleep(0.2)

Unmodified 0.30.13, event log after one notch:

MouseWheel { device_id: DeviceId(X(DeviceId(2))), delta: LineDelta(0.0, -1.0), phase: Moved }
MouseWheel { device_id: DeviceId(X(DeviceId(2))), delta: LineDelta(0.0, -1.0), phase: Moved }

The same RFB sequence with this backport:

MouseWheel { device_id: DeviceId(X(DeviceId(2))), delta: LineDelta(0.0, -1.0), phase: Moved }

The original result also reproduces with one XTEST button-5 click under Xvfb. Press-only injection is not an equivalent workaround: six consecutive downs produce only one press because the server keeps the button held.

Verification

  • cargo test -p winit --lib --no-default-features --features x11,rwh_06: 8 passed.
  • TigerVNC/RFB before/after reproduction above: two events before, one after.
  • git diff --check: passed.
  • cargo +nightly fmt -- --check did not pass locally: the installed formatter identifies as stable and reports unrelated existing formatting differences. The changed match arm follows x11: ignore mouse scroll button release events #4386 exactly.

This is for the 0.30 patch-release line; master already contains #4386. No API change.

Backport the button press/release handling from 03dad26 (rust-windowing#4386).
@shtse8
shtse8 requested a review from kchibisov as a code owner November 7, 2026 01:12
@shtse8

shtse8 commented Nov 7, 2026

Copy link
Copy Markdown
Author

The upstream formatting check passed. The test matrix did not reach compilation of the changed code: the stable Linux and nightly X11 logs both stop in Generate lockfile with error: specification 'syn' is ambiguous, listing [email protected] and [email protected].

Examples from run 42322767369:

Linux cargo-deny also reports the two syn versions and the existing ttf-parser unmaintained advisory RUSTSEC-2026-0192. This backport changes neither manifests nor dependency resolution. I have left the dependency/CI changes out of this small backport; the local X11 library tests and TigerVNC before/after result remain as described above.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant