gpui: Implement pinch event support for X11 and Windows#51354
gpui: Implement pinch event support for X11 and Windows#51354reflectronic merged 12 commits intozed-industries:mainfrom
Conversation
- 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)
|
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! |
Add DirectManipulationHandler and event handler to handle trackpad pinch/scroll gestures on Windows. The implementation is adapted from Chromium's approach: - https://github.com/chromium/chromium/blob/main/content/browser/renderer_host/direct_manipulation_helper_win.cc - https://github.com/chromium/chromium/blob/main/content/browser/renderer_host/direct_manipulation_event_handler_win.cc
|
The code broke scrolling on Windows, so I pushed an update to fix that and simplify the code in a few other ways. |
Thanks! |
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: