apply empty report rule to all encodings; comments added

This commit is contained in:
Jörg Breitbart
2019-11-14 22:29:46 +01:00
parent f1f103850c
commit 57fe84508c
2 changed files with 11 additions and 4 deletions
+3
View File
@@ -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;
+8 -4
View File
@@ -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;