Skip to content

Bring back partial wheel tracking#5391

Merged
Tyriar merged 12 commits intoxtermjs:masterfrom
Tyriar:tyriar/mouse_events
Sep 10, 2025
Merged

Bring back partial wheel tracking#5391
Tyriar merged 12 commits intoxtermjs:masterfrom
Tyriar:tyriar/mouse_events

Conversation

@Tyriar
Copy link
Copy Markdown
Member

@Tyriar Tyriar commented Aug 28, 2025

@Tyriar Tyriar added this to the 6.0.0 milestone Aug 28, 2025
@Tyriar
Copy link
Copy Markdown
Member Author

Tyriar commented Aug 28, 2025

@anthonykim1 can you pull the partial wheel tracking into CoreMouseService?

@anthonykim1
Copy link
Copy Markdown
Member

anthonykim1 commented Aug 29, 2025

I just realized the scrolling experience differs alot when using trackpad vs. mouse when scrolling.
My scrolling speed for both mouse and trackpad is set to the median/middle in Mac system device setting.

I'm aggressively scrolling with mouse in the two videos:

Screen.Recording.2025-08-28.at.9.17.39.PM.mov
Screen.Recording.2025-08-28.at.9.16.29.PM.mov

Seems like better experience with mac trackpad, but bit too slow imo with mouse scrolling.

    // Fallback to WheelEvent.DOM_DELTA_LINE
    const targetWheelEventPixels = this._renderService.dimensions.device.cell.height / this._coreBrowserService.dpr;
    let amount = 1;
    if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
      amount /= targetWheelEventPixels + 0.0; // Prevent integer division
      this._wheelPartialScroll += amount;
      amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
      this._wheelPartialScroll %= 1;
    } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
      amount *= this._bufferService.rows;
    }
    return amount;

Maybe the amount should be somewhere around 2 instead of 1? or wondering how should we handle mouse scroll vs. trackpad scroll.

@Tyriar
Copy link
Copy Markdown
Member Author

Tyriar commented Aug 29, 2025

@anthonykim1 I think you have vim mouse events off which is why it's scrolling more slowly? As discussed "1 line" scrolled ends up translating into 4 lines when vim mouse support is on, which was 4 times faster than how it should be scrolling.

The first video doesn't look great, could you look into what deltaY, deltaMode and targetWheelEventPixels are in your case? Different mouses/OSs behave differently.

@anthonykim1
Copy link
Copy Markdown
Member

anthonykim1 commented Sep 8, 2025

@Tyriar I'm not sure, I just added set mouse=a to my .vimrc, but it still feels bit sluggish.

Two constant thing I found is that targetWhellEventPixel seems to always be 14 and deltaMode always seem 0

Here are more findings with mouse scroll:

  • It also seems like deltaY should at least be absolute value of 103 in order to scroll to next element.
  • If its a small scroll (deltaY abs(13)), then it seems to take MANY attempts to scroll to next).

Video for reference (only used mouse scroll):
https://github.com/user-attachments/assets/16fb95ee-999c-411e-acff-0251d8fdcbd8

I noticed that on trackpad where I have good experience, the deltaY is contained around MAX absolute value of 30, otherwise btw absolute value of 10.

@anthonykim1
Copy link
Copy Markdown
Member

Update: I think I got it.
Now mouse scrolling is very similar experience to trackpad

Screen.Recording.2025-09-08.at.9.03.52.PM.mov

@anthonykim1 anthonykim1 marked this pull request as ready for review September 9, 2025 04:15
@anthonykim1 anthonykim1 marked this pull request as draft September 9, 2025 17:57
@anthonykim1 anthonykim1 closed this Sep 9, 2025
@anthonykim1 anthonykim1 reopened this Sep 9, 2025
@anthonykim1 anthonykim1 marked this pull request as ready for review September 10, 2025 01:21
@anthonykim1 anthonykim1 requested review from anthonykim1 and removed request for anthonykim1 September 10, 2025 01:21
@anthonykim1 anthonykim1 assigned Tyriar and anthonykim1 and unassigned Tyriar and anthonykim1 Sep 10, 2025
@Tyriar Tyriar merged commit d7d7f1b into xtermjs:master Sep 10, 2025
20 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants