Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: Various X11 scroll improvements #18484

Merged
merged 3 commits into from
Oct 1, 2024

Conversation

mgsloan
Copy link
Contributor

@mgsloan mgsloan commented Sep 28, 2024

Closes #14089, #14416, #15970, #17230, #18485

Release Notes:

Change details:

Also includes the commit from PR #18317 so I don't have to deal with merge conflicts.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Sep 28, 2024
@mgsloan mgsloan force-pushed the x11-scroll-improvements branch 5 times, most recently from 66566cb to 7288186 Compare September 28, 2024 19:37
@zed-industries-bot
Copy link

zed-industries-bot commented Sep 29, 2024

Messages
📖

This PR includes links to the following GitHub Issues: #14089, #15970, #17230, #14416
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against 4e01c06

@mgsloan mgsloan force-pushed the x11-scroll-improvements branch 2 times, most recently from 6cbe2f3 to a7ab256 Compare September 29, 2024 21:05
@mrnugget
Copy link
Member

Hey, thanks for this! I'm going to take a look, try this out, and review code. @apricotbucket28 I'd appreciate a second set of eyes, since you know this area pretty well — if you have the time :)

@mrnugget mrnugget changed the title X11 scroll improvements linux: Various X11 scroll improvements Sep 30, 2024
Copy link
Member

@mrnugget mrnugget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me (left some improvement suggestions). Appreciate the tests and pulling out into functions.

I also tried it locally on my Linux/X11 machine, and it didn't break anything, but I also can't confirm/deny that it fixed anything. I trust you here.

So, let me know what you think about the suggested changes and then, pending input from @apricotbucket28, I think we can merge this.

delta_scroll
}

fn get_valuator_axis_index(valuator_mask: &Vec<u32>, valuator_number: u16) -> Option<usize> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the following 3-4 methods made me wonder whether we shouldn't introduce a ValuatorMask type (that might just wrap Vec<u32>) and define the methods on that type.

Copy link
Contributor Author

@mgsloan mgsloan Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these to event.rs since that seems to be where event-related utilities go. It does seem weird to even put them in the platform crate, though. I imagine there is probably a cleaner way to do them with some library.

Could do the ValuatorMask newtype thing (I'm a big fan of newtypes!), but I'm leaning towards not making that change. Rationale is:

  1. The other 2 methods aren't really specific to valuators, these are operations that are general bitmask operations on Vec<u32>.

  2. Would only be constructed in one spot and not passed around, so there are no type safety benefits

crates/gpui/src/platform/linux/x11/client.rs Outdated Show resolved Hide resolved
crates/gpui/src/platform/linux/x11/client.rs Outdated Show resolved Hide resolved
crates/gpui/src/platform/linux/x11/client.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@apricotbucket28 apricotbucket28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good and it seems to work well on my machine! Don't have a trackpad right now to retest it there, but I don't see why it would break.

The behavior also seems to be more stable than before, since I haven't had the mouse not work randomly.

Great work! 😄

@mgsloan mgsloan force-pushed the x11-scroll-improvements branch 2 times, most recently from c006f4a to 2052be9 Compare October 1, 2024 00:58
@mgsloan
Copy link
Contributor Author

mgsloan commented Oct 1, 2024

@mrnugget Thanks for reviewing!! Made some changes based on your feedback.

@apricotbucket28 Thanks for taking a look, glad it's working well for you!!

* Now uses valuator info from slave pointers rather than master. This
hopefully fixes remaining cases where scrolling is fully
broken. zed-industries#14089, zed-industries#15970, zed-industries#17230

* Per-device recording of "last scroll position" used to calculate
deltas. This meant that swithing scroll devices would cause a sudden
jump of scroll position, often to the beginning or end of the
file (zed-industries#14416).

* Re-queries device metadata when devices change, so that newly
plugged in devices will work, and re-use of device-ids don't use old
metadata with a new device.

* xinput 2 documentation describes support for multiple master
devices. I believe this implementation will support that, since now it
just uses `DeviceInfo` from slave devices. The concept of master
devices is only used in registering for events.

* Uses popcount+bit masking to resolve axis indexes, instead of
iterating bit indices.
u32 can't be less than 0.
@mrnugget mrnugget merged commit 527c909 into zed-industries:main Oct 1, 2024
9 checks passed
@mrnugget
Copy link
Member

mrnugget commented Oct 1, 2024

Thank you! Hopped on the branch to fix a clippy issue

@codehd7
Copy link

codehd7 commented Oct 2, 2024

Just grabbed 0.156.0 build with this fix... On my openSUSE 15.6 system it's working well, and it's so nice to scroll with my mouse wheel! Thx @mgsloan 😃

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scroll completely broken (Linux Mint)
5 participants