XI2 Smooth Scrolling for X11 - Attempt 2 (#11110)

This should have fixed the problems that some users were reporting with
https://github.com/zed-industries/zed/pull/10695 .

The problem was with devices which send more than one valuator axis in a
single event whereas the original PR assumed there would only ever be
one axis per event. This version also does away with the complicated
device selection and instead just uses the master pointer device, which
automatically uses all sub-pointers.

Edit: Confirmed working for one of the user's which the first attempt
was broken for.

Release Notes:

- Added smooth scrolling for X11 on Linux
- Added horizontal scrolling for X11 on Linux
This commit is contained in:
Owen Law 2024-04-29 12:40:42 -04:00 committed by GitHub
parent ff8e7f91c1
commit ec95605fec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 157 additions and 20 deletions

View file

@ -13,7 +13,10 @@ use raw_window_handle as rwh;
use util::ResultExt;
use x11rb::{
connection::Connection,
protocol::xproto::{self, ConnectionExt as _, CreateWindowAux},
protocol::{
xinput,
xproto::{self, ConnectionExt as _, CreateWindowAux},
},
wrapper::ConnectionExt,
xcb_ffi::XCBConnection,
};
@ -153,8 +156,6 @@ impl X11WindowState {
| xproto::EventMask::BUTTON1_MOTION
| xproto::EventMask::BUTTON2_MOTION
| xproto::EventMask::BUTTON3_MOTION
| xproto::EventMask::BUTTON4_MOTION
| xproto::EventMask::BUTTON5_MOTION
| xproto::EventMask::BUTTON_MOTION,
);
@ -174,6 +175,18 @@ impl X11WindowState {
)
.unwrap();
xinput::ConnectionExt::xinput_xi_select_events(
&xcb_connection,
x_window,
&[xinput::EventMask {
deviceid: 1,
mask: vec![xinput::XIEventMask::MOTION],
}],
)
.unwrap()
.check()
.unwrap();
if let Some(titlebar) = params.titlebar {
if let Some(title) = titlebar.title {
xcb_connection