diff --git a/src/browser/CoreBrowserTerminal.ts b/src/browser/CoreBrowserTerminal.ts index 23e4a560..c6f12b52 100644 --- a/src/browser/CoreBrowserTerminal.ts +++ b/src/browser/CoreBrowserTerminal.ts @@ -630,15 +630,11 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal { if (self._customWheelEventHandler && self._customWheelEventHandler(ev as WheelEvent) === false) { return false; } - // TODO: Implement - const amount = 0; - // const amount = self.viewport!.getLinesScrolled(ev as WheelEvent); - - if (amount === 0) { + const deltaY = (ev as WheelEvent).deltaY; + if (deltaY === 0) { return false; } - - action = (ev as WheelEvent).deltaY < 0 ? CoreMouseAction.UP : CoreMouseAction.DOWN; + action = deltaY < 0 ? CoreMouseAction.UP : CoreMouseAction.DOWN; but = CoreMouseButton.WHEEL; break; default: @@ -798,7 +794,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal { if (!this.buffer.hasScrollback) { // Convert wheel events into up/down events when the buffer does not have scrollback, this // enables scrolling in apps hosted in the alt buffer such as vim or tmux. - // TODSO: Impl + // TODO: Impl const amount = 0; // this.viewport!.getLinesScrolled(ev); // Do nothing if there's no vertical scroll diff --git a/src/browser/Viewport.ts b/src/browser/Viewport.ts index f339d969..0bf51f0f 100644 --- a/src/browser/Viewport.ts +++ b/src/browser/Viewport.ts @@ -7,7 +7,8 @@ import { ICoreBrowserService, IRenderService, IThemeService } from 'browser/serv import { ViewportConstants } from 'browser/shared/Constants'; import { EventEmitter, runAndSubscribe } from 'common/EventEmitter'; import { Disposable, toDisposable } from 'common/Lifecycle'; -import { IBufferService, IOptionsService } from 'common/services/Services'; +import { IBufferService, ICoreMouseService, IOptionsService } from 'common/services/Services'; +import { CoreMouseEventType } from 'common/Types'; import { scheduleAtNextAnimationFrame } from 'vs/base/browser/dom'; import { SmoothScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import type { ScrollableElementChangeOptions } from 'vs/base/browser/ui/scrollbar/scrollableElementOptions'; @@ -32,6 +33,7 @@ export class Viewport extends Disposable { screenElement: HTMLElement, @IBufferService private readonly _bufferService: IBufferService, @ICoreBrowserService coreBrowserService: ICoreBrowserService, + @ICoreMouseService coreMouseService: ICoreMouseService, @IThemeService themeService: IThemeService, @IOptionsService private readonly _optionsService: IOptionsService, @IRenderService private readonly _renderService: IRenderService @@ -62,6 +64,12 @@ export class Viewport extends Disposable { 'fastScrollSensitivity', 'overviewRulerWidth' ], () => this._scrollableElement.updateOptions(this._getChangeOptions()))); + // Don't handle mouse wheel if wheel events are supported by the current mouse prototcol + this.register(coreMouseService.onProtocolChange(type => { + this._scrollableElement.updateOptions({ + handleMouseWheel: !(type & CoreMouseEventType.WHEEL) + }); + })); this._scrollableElement.setScrollDimensions({ height: 0, scrollHeight: 0 }); this.register(runAndSubscribe(themeService.onChangeColors, () => {