From 57fe84508cb43291d508e546ed5130174ee5a141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 14 Nov 2019 22:29:46 +0100 Subject: [PATCH] apply empty report rule to all encodings; comments added --- src/common/Types.d.ts | 3 +++ src/common/services/CoreMouseService.ts | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index 2f742038..2dcc704b 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -249,5 +249,8 @@ export interface ICoreMouseProtocol { * The tracking encoding can be registered and activated at the CoreMouseService. * If a ICoreMouseEvent passes all procotol restrictions it will be encoded * with the active encoding and sent out. + * Note: Returning an empty string will supress sending a mouse report, + * which can be used to skip creating falsey reports in limited encodings + * (DEFAULT only supports up to 223 1-based as coord value). */ export type CoreMouseEncoding = (event: ICoreMouseEvent) => string; diff --git a/src/common/services/CoreMouseService.ts b/src/common/services/CoreMouseService.ts index 5c9d3944..0bd25dd0 100644 --- a/src/common/services/CoreMouseService.ts +++ b/src/common/services/CoreMouseService.ts @@ -125,6 +125,10 @@ const DEFAULT_ENCODINGS: {[key: string]: CoreMouseEncoding} = { */ DEFAULT: (e: ICoreMouseEvent) => { const params = [eventCode(e, false) + 32, e.col + 32, e.row + 32]; + // supress mouse report if we exceed addressible range + // Note this is handled differently by emulators + // - xterm: sends 0;0 coords instead + // - vte, konsole: no report if (params[0] > 255 || params[1] > 255 || params[2] > 255) { return ''; } @@ -264,13 +268,13 @@ export class CoreMouseService implements ICoreMouseService { // encode report and send const report = this._encodings[this._activeEncoding](e); - if (this._activeEncoding === 'DEFAULT') { + if (report) { // always send DEFAULT as binary data - if (report) { + if (this._activeEncoding === 'DEFAULT') { this._coreService.triggerBinaryEvent(report); + } else { + this._coreService.triggerDataEvent(report, true); } - } else { - this._coreService.triggerDataEvent(report, true); } this._lastEvent = e;