Allow Shift + Scroll to Horizontally Scroll in X11 and Wayland (#13676)

Release Notes:

- Allows shift + scroll horizontal scrolling on X11 and Wayland.

[Screencast from 2024-06-29
17-17-59.webm](https://github.com/zed-industries/zed/assets/14155062/2cac77b9-ecc8-4ddb-b08d-b5d964c8dc84)
This commit is contained in:
Keenan Wresch 2024-07-04 10:22:42 -04:00 committed by GitHub
parent d450a1d9e6
commit b1f8fc88a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -1508,6 +1508,11 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
if state.axis_source == AxisSource::Wheel {
return;
}
let axis = if state.modifiers.shift {
wl_pointer::Axis::HorizontalScroll
} else {
axis
};
let axis_modifier = match axis {
wl_pointer::Axis::VerticalScroll => state.vertical_modifier,
wl_pointer::Axis::HorizontalScroll => state.horizontal_modifier,
@ -1533,6 +1538,11 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
discrete,
} => {
state.scroll_event_received = true;
let axis = if state.modifiers.shift {
wl_pointer::Axis::HorizontalScroll
} else {
axis
};
let axis_modifier = match axis {
wl_pointer::Axis::VerticalScroll => state.vertical_modifier,
wl_pointer::Axis::HorizontalScroll => state.horizontal_modifier,
@ -1555,6 +1565,11 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
value120,
} => {
state.scroll_event_received = true;
let axis = if state.modifiers.shift {
wl_pointer::Axis::HorizontalScroll
} else {
axis
};
let axis_modifier = match axis {
wl_pointer::Axis::VerticalScroll => state.vertical_modifier,
wl_pointer::Axis::HorizontalScroll => state.horizontal_modifier,

View File

@ -817,10 +817,15 @@ impl X11Client {
if let Some(old_scroll) = old_scroll {
let delta_scroll = old_scroll - new_scroll;
let (x, y) = if !modifiers.shift {
(0.0, delta_scroll)
} else {
(delta_scroll, 0.0)
};
window.handle_input(PlatformInput::ScrollWheel(
crate::ScrollWheelEvent {
position,
delta: ScrollDelta::Lines(Point::new(0.0, delta_scroll)),
delta: ScrollDelta::Lines(Point::new(x, y)),
modifiers,
touch_phase: TouchPhase::default(),
},