Skip to content

gpui: Implement pinch event support for X11 and Windows#51354

Merged
reflectronic merged 12 commits intozed-industries:mainfrom
MostlyKIGuess:feature/cross-platform-gesture
Mar 28, 2026
Merged

gpui: Implement pinch event support for X11 and Windows#51354
reflectronic merged 12 commits intozed-industries:mainfrom
MostlyKIGuess:feature/cross-platform-gesture

Conversation

@MostlyKIGuess
Copy link
Copy Markdown
Contributor

Closes #51312

  • Remove platform-specific #[cfg] gates from PinchEvent, event
    listeners, and dispatch logic in GPUI

  • Windows: Intercept Ctrl+ScrollWheel (emitted by precision trackpads
    for pinch gestures) and convert them to GPUI PinchEvents

  • Image Viewer: remove redundant platform-specific blocks

  • X11: Bump XInput version to 2.4 and implement handlers for
    XinputGesturePinch events

  • Added a solid test coverage and/or screenshots from doing manual testing

  • Done a self-review taking into account security and performance aspects

  • Aligned any UI changes with the UI checklist

Release Notes:

  • Pinching gestures now available on all devices.

- Remove platform-specific #[cfg] gates from PinchEvent, event
  listeners, and dispatch logic in GPUI
- Windows: Intercept Ctrl+ScrollWheel (emitted by precision trackpads
  for pinch gestures) and convert them to GPUI PinchEvents
- Image Viewer: remove redundant platform-specific blocks
- X11: Bump XInput version to 2.4 and implement handlers for
  XinputGesturePinch events
x11rb 0.13 lacks XIEventMask constants for gesture events, so
construct the masks from the gesture event opcodes (mask bit N = 1 << N)
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 12, 2026
@maxdeviant maxdeviant changed the title gpui: implement pinch event support for X11 and Windows gpui: Implement pinch event support for X11 and Windows Mar 12, 2026
@zelenenka zelenenka added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 19, 2026
@reflectronic
Copy link
Copy Markdown
Member

Thank you for the pull request. I think the implementation on Windows needs some work. The proposed change treats any mouse wheel event with Ctrl held down as a pinch. So, scrolling with the mouse wheel while holding down Ctrl also generates pinch events. I don't think this is want; for example, it means that you can't scroll the editor if you have Ctrl held down.

I think I'd rather implement the pinch support using the Direct Manipulation API, which lets us get information about pan and zoom gestures for both touch and precision trackpad. There is some code in Chromium that you can try to adapt: https://github.com/chromium/chromium/blob/cb795b0a659ac5b082237dacc02e9f37dc48374b/content/browser/renderer_host/direct_manipulation_event_handler_win.cc. It's not the most convenient API for this purpose but I don't think there's another way to get these events.

@MostlyKIGuess
Copy link
Copy Markdown
Contributor Author

Thank you for the pull request. I think the implementation on Windows needs some work. The proposed change treats any mouse wheel event with Ctrl held down as a pinch. So, scrolling with the mouse wheel while holding down Ctrl also generates pinch events. I don't think this is want; for example, it means that you can't scroll the editor if you have Ctrl held down.

I think I'd rather implement the pinch support using the Direct Manipulation API, which lets us get information about pan and zoom gestures for both touch and precision trackpad. There is some code in Chromium that you can try to adapt: https://github.com/chromium/chromium/blob/cb795b0a659ac5b082237dacc02e9f37dc48374b/content/browser/renderer_host/direct_manipulation_event_handler_win.cc. It's not the most convenient API for this purpose but I don't think there's another way to get these events.

Makes sense, thanks for the find as well, I will adapt it similarly!

@reflectronic
Copy link
Copy Markdown
Member

The code broke scrolling on Windows, so I pushed an update to fix that and simplify the code in a few other ways.

@reflectronic reflectronic merged commit 6694a3b into zed-industries:main Mar 28, 2026
30 checks passed
@MostlyKIGuess
Copy link
Copy Markdown
Contributor Author

The code broke scrolling on Windows, so I pushed an update to fix that and simplify the code in a few other ways.

Thanks!

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

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPUI: Add pinch event support for X11 and Windows

5 participants