Use XI2 for Scrolling on X11 (#10695)
Changes the X11 platform code to use the xinput extension which allows for smooth scrolling and horizontal scrolling. Release Notes: - Added smooth scrolling to X11 on Linux - Added horizontal scrolling to X11 on Linux
This commit is contained in:
parent
bd5473a582
commit
98db7fa61e
3 changed files with 135 additions and 17 deletions
|
@ -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,
|
||||
};
|
||||
|
@ -140,6 +143,7 @@ impl X11WindowState {
|
|||
x_main_screen_index: usize,
|
||||
x_window: xproto::Window,
|
||||
atoms: &XcbAtoms,
|
||||
scroll_devices: &Vec<xinput::DeviceInfo>,
|
||||
) -> Self {
|
||||
let x_screen_index = params
|
||||
.display_id
|
||||
|
@ -160,8 +164,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,
|
||||
);
|
||||
|
||||
|
@ -181,6 +183,20 @@ impl X11WindowState {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
for device in scroll_devices {
|
||||
xinput::ConnectionExt::xinput_xi_select_events(
|
||||
&xcb_connection,
|
||||
x_window,
|
||||
&[xinput::EventMask {
|
||||
deviceid: device.device_id as u16,
|
||||
mask: vec![xinput::XIEventMask::MOTION],
|
||||
}],
|
||||
)
|
||||
.unwrap()
|
||||
.check()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if let Some(titlebar) = params.titlebar {
|
||||
if let Some(title) = titlebar.title {
|
||||
xcb_connection
|
||||
|
@ -262,6 +278,7 @@ impl X11Window {
|
|||
x_main_screen_index: usize,
|
||||
x_window: xproto::Window,
|
||||
atoms: &XcbAtoms,
|
||||
scroll_devices: &Vec<xinput::DeviceInfo>,
|
||||
) -> Self {
|
||||
X11Window {
|
||||
state: Rc::new(RefCell::new(X11WindowState::new(
|
||||
|
@ -270,6 +287,7 @@ impl X11Window {
|
|||
x_main_screen_index,
|
||||
x_window,
|
||||
atoms,
|
||||
scroll_devices,
|
||||
))),
|
||||
callbacks: Rc::new(RefCell::new(Callbacks::default())),
|
||||
xcb_connection: xcb_connection.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue