@novnc/novnc 1.2.0-beta → 1.3.0-g99cf540
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +0 -6
- package/README.md +4 -4
- package/core/decoders/copyrect.js +5 -0
- package/core/decoders/hextile.js +57 -3
- package/core/decoders/raw.js +12 -2
- package/core/decoders/tight.js +24 -8
- package/core/display.js +9 -151
- package/core/input/domkeytable.js +25 -21
- package/core/input/keyboard.js +12 -127
- package/core/input/util.js +18 -35
- package/core/input/vkeys.js +0 -1
- package/core/input/xtscancodes.js +5 -3
- package/core/rfb.js +113 -106
- package/core/util/browser.js +0 -17
- package/core/util/cursor.js +1 -11
- package/core/util/events.js +0 -4
- package/core/websock.js +76 -17
- package/docs/API.md +2 -2
- package/docs/LIBRARY.md +3 -7
- package/lib/base64.js +4 -4
- package/lib/decoders/copyrect.js +7 -2
- package/lib/decoders/hextile.js +63 -7
- package/lib/decoders/raw.js +13 -4
- package/lib/decoders/rre.js +2 -2
- package/lib/decoders/tight.js +38 -20
- package/lib/decoders/tightpng.js +8 -8
- package/lib/deflator.js +4 -4
- package/lib/des.js +2 -2
- package/lib/display.js +45 -212
- package/lib/inflator.js +4 -4
- package/lib/input/domkeytable.js +197 -194
- package/lib/input/fixedkeys.js +2 -2
- package/lib/input/gesturehandler.js +2 -2
- package/lib/input/keyboard.js +38 -158
- package/lib/input/keysym.js +2 -2
- package/lib/input/keysymdef.js +2 -2
- package/lib/input/util.js +34 -79
- package/lib/input/vkeys.js +2 -4
- package/lib/input/xtscancodes.js +11 -5
- package/lib/rfb.js +287 -283
- package/lib/util/browser.js +8 -26
- package/lib/util/cursor.js +4 -16
- package/lib/util/events.js +3 -5
- package/lib/util/eventtarget.js +3 -3
- package/lib/util/int.js +1 -1
- package/lib/util/logging.js +2 -2
- package/lib/vendor/pako/lib/utils/common.js +2 -2
- package/lib/vendor/pako/lib/zlib/adler32.js +1 -1
- package/lib/vendor/pako/lib/zlib/constants.js +2 -2
- package/lib/vendor/pako/lib/zlib/crc32.js +1 -1
- package/lib/vendor/pako/lib/zlib/deflate.js +113 -112
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -1
- package/lib/vendor/pako/lib/zlib/inffast.js +5 -5
- package/lib/vendor/pako/lib/zlib/inflate.js +50 -48
- package/lib/vendor/pako/lib/zlib/inftrees.js +3 -3
- package/lib/vendor/pako/lib/zlib/messages.js +2 -2
- package/lib/vendor/pako/lib/zlib/trees.js +4 -4
- package/lib/vendor/pako/lib/zlib/zstream.js +1 -1
- package/lib/websock.js +105 -44
- package/package.json +2 -7
- package/core/util/polyfill.js +0 -61
- package/lib/util/polyfill.js +0 -72
- package/lib/vendor/promise.js +0 -255
package/LICENSE.txt
CHANGED
|
@@ -42,12 +42,6 @@ licenses (all MPL 2.0 compatible):
|
|
|
42
42
|
|
|
43
43
|
vendor/pako/ : MIT
|
|
44
44
|
|
|
45
|
-
vendor/browser-es-module-loader/src/ : MIT
|
|
46
|
-
|
|
47
|
-
vendor/browser-es-module-loader/dist/ : Various BSD style licenses
|
|
48
|
-
|
|
49
|
-
vendor/promise.js : MIT
|
|
50
|
-
|
|
51
45
|
Any other files not mentioned above are typically marked with
|
|
52
46
|
a copyright/license header at the top of the file. The default noVNC
|
|
53
47
|
license is MPL-2.0.
|
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ noVNC uses many modern web technologies so a formal requirement list is
|
|
|
91
91
|
not available. However these are the minimum versions we are currently
|
|
92
92
|
aware of:
|
|
93
93
|
|
|
94
|
-
* Chrome
|
|
94
|
+
* Chrome 64, Firefox 79, Safari 13.4, Opera 51, Edge 79
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
### Server Requirements
|
|
@@ -108,13 +108,13 @@ proxy.
|
|
|
108
108
|
|
|
109
109
|
### Quick Start
|
|
110
110
|
|
|
111
|
-
* Use the
|
|
111
|
+
* Use the `novnc_proxy` script to automatically download and start websockify, which
|
|
112
112
|
includes a mini-webserver and the WebSockets proxy. The `--vnc` option is
|
|
113
113
|
used to specify the location of a running VNC server:
|
|
114
114
|
|
|
115
|
-
`./utils/
|
|
115
|
+
`./utils/novnc_proxy --vnc localhost:5901`
|
|
116
116
|
|
|
117
|
-
* Point your browser to the cut-and-paste URL that is output by the
|
|
117
|
+
* Point your browser to the cut-and-paste URL that is output by the `novnc_proxy`
|
|
118
118
|
script. Hit the Connect button, enter a password if the VNC server has one
|
|
119
119
|
configured, and enjoy!
|
|
120
120
|
|
|
@@ -15,6 +15,11 @@ export default class CopyRectDecoder {
|
|
|
15
15
|
|
|
16
16
|
let deltaX = sock.rQshift16();
|
|
17
17
|
let deltaY = sock.rQshift16();
|
|
18
|
+
|
|
19
|
+
if ((width === 0) || (height === 0)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
display.copyImage(deltaX, deltaY, x, y, width, height);
|
|
19
24
|
|
|
20
25
|
return true;
|
package/core/decoders/hextile.js
CHANGED
|
@@ -13,6 +13,7 @@ export default class HextileDecoder {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
this._tiles = 0;
|
|
15
15
|
this._lastsubencoding = 0;
|
|
16
|
+
this._tileBuffer = new Uint8Array(16 * 16 * 4);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
decodeRect(x, y, width, height, sock, display, depth) {
|
|
@@ -87,6 +88,11 @@ export default class HextileDecoder {
|
|
|
87
88
|
display.fillRect(tx, ty, tw, th, this._background);
|
|
88
89
|
}
|
|
89
90
|
} else if (subencoding & 0x01) { // Raw
|
|
91
|
+
let pixels = tw * th;
|
|
92
|
+
// Max sure the image is fully opaque
|
|
93
|
+
for (let i = 0;i < pixels;i++) {
|
|
94
|
+
rQ[rQi + i * 4 + 3] = 255;
|
|
95
|
+
}
|
|
90
96
|
display.blitImage(tx, ty, tw, th, rQ, rQi);
|
|
91
97
|
rQi += bytes - 1;
|
|
92
98
|
} else {
|
|
@@ -99,7 +105,7 @@ export default class HextileDecoder {
|
|
|
99
105
|
rQi += 4;
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
|
|
108
|
+
this._startTile(tx, ty, tw, th, this._background);
|
|
103
109
|
if (subencoding & 0x08) { // AnySubrects
|
|
104
110
|
let subrects = rQ[rQi];
|
|
105
111
|
rQi++;
|
|
@@ -122,10 +128,10 @@ export default class HextileDecoder {
|
|
|
122
128
|
const sw = (wh >> 4) + 1;
|
|
123
129
|
const sh = (wh & 0x0f) + 1;
|
|
124
130
|
|
|
125
|
-
|
|
131
|
+
this._subTile(sx, sy, sw, sh, color);
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
|
-
|
|
134
|
+
this._finishTile(display);
|
|
129
135
|
}
|
|
130
136
|
sock.rQi = rQi;
|
|
131
137
|
this._lastsubencoding = subencoding;
|
|
@@ -134,4 +140,52 @@ export default class HextileDecoder {
|
|
|
134
140
|
|
|
135
141
|
return true;
|
|
136
142
|
}
|
|
143
|
+
|
|
144
|
+
// start updating a tile
|
|
145
|
+
_startTile(x, y, width, height, color) {
|
|
146
|
+
this._tileX = x;
|
|
147
|
+
this._tileY = y;
|
|
148
|
+
this._tileW = width;
|
|
149
|
+
this._tileH = height;
|
|
150
|
+
|
|
151
|
+
const red = color[0];
|
|
152
|
+
const green = color[1];
|
|
153
|
+
const blue = color[2];
|
|
154
|
+
|
|
155
|
+
const data = this._tileBuffer;
|
|
156
|
+
for (let i = 0; i < width * height * 4; i += 4) {
|
|
157
|
+
data[i] = red;
|
|
158
|
+
data[i + 1] = green;
|
|
159
|
+
data[i + 2] = blue;
|
|
160
|
+
data[i + 3] = 255;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// update sub-rectangle of the current tile
|
|
165
|
+
_subTile(x, y, w, h, color) {
|
|
166
|
+
const red = color[0];
|
|
167
|
+
const green = color[1];
|
|
168
|
+
const blue = color[2];
|
|
169
|
+
const xend = x + w;
|
|
170
|
+
const yend = y + h;
|
|
171
|
+
|
|
172
|
+
const data = this._tileBuffer;
|
|
173
|
+
const width = this._tileW;
|
|
174
|
+
for (let j = y; j < yend; j++) {
|
|
175
|
+
for (let i = x; i < xend; i++) {
|
|
176
|
+
const p = (i + (j * width)) * 4;
|
|
177
|
+
data[p] = red;
|
|
178
|
+
data[p + 1] = green;
|
|
179
|
+
data[p + 2] = blue;
|
|
180
|
+
data[p + 3] = 255;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// draw the current tile to the screen
|
|
186
|
+
_finishTile(display) {
|
|
187
|
+
display.blitImage(this._tileX, this._tileY,
|
|
188
|
+
this._tileW, this._tileH,
|
|
189
|
+
this._tileBuffer, 0);
|
|
190
|
+
}
|
|
137
191
|
}
|
package/core/decoders/raw.js
CHANGED
|
@@ -13,6 +13,10 @@ export default class RawDecoder {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
decodeRect(x, y, width, height, sock, display, depth) {
|
|
16
|
+
if ((width === 0) || (height === 0)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
if (this._lines === 0) {
|
|
17
21
|
this._lines = height;
|
|
18
22
|
}
|
|
@@ -27,23 +31,29 @@ export default class RawDecoder {
|
|
|
27
31
|
const curY = y + (height - this._lines);
|
|
28
32
|
const currHeight = Math.min(this._lines,
|
|
29
33
|
Math.floor(sock.rQlen / bytesPerLine));
|
|
34
|
+
const pixels = width * currHeight;
|
|
35
|
+
|
|
30
36
|
let data = sock.rQ;
|
|
31
37
|
let index = sock.rQi;
|
|
32
38
|
|
|
33
39
|
// Convert data if needed
|
|
34
40
|
if (depth == 8) {
|
|
35
|
-
const pixels = width * currHeight;
|
|
36
41
|
const newdata = new Uint8Array(pixels * 4);
|
|
37
42
|
for (let i = 0; i < pixels; i++) {
|
|
38
43
|
newdata[i * 4 + 0] = ((data[index + i] >> 0) & 0x3) * 255 / 3;
|
|
39
44
|
newdata[i * 4 + 1] = ((data[index + i] >> 2) & 0x3) * 255 / 3;
|
|
40
45
|
newdata[i * 4 + 2] = ((data[index + i] >> 4) & 0x3) * 255 / 3;
|
|
41
|
-
newdata[i * 4 +
|
|
46
|
+
newdata[i * 4 + 3] = 255;
|
|
42
47
|
}
|
|
43
48
|
data = newdata;
|
|
44
49
|
index = 0;
|
|
45
50
|
}
|
|
46
51
|
|
|
52
|
+
// Max sure the image is fully opaque
|
|
53
|
+
for (let i = 0; i < pixels; i++) {
|
|
54
|
+
data[i * 4 + 3] = 255;
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
display.blitImage(x, curY, width, currHeight, data, index);
|
|
48
58
|
sock.rQskipBytes(currHeight * bytesPerLine);
|
|
49
59
|
this._lines -= currHeight;
|
package/core/decoders/tight.js
CHANGED
|
@@ -56,7 +56,7 @@ export default class TightDecoder {
|
|
|
56
56
|
} else if (this._ctl === 0x0A) {
|
|
57
57
|
ret = this._pngRect(x, y, width, height,
|
|
58
58
|
sock, display, depth);
|
|
59
|
-
} else if ((this._ctl &
|
|
59
|
+
} else if ((this._ctl & 0x08) == 0) {
|
|
60
60
|
ret = this._basicRect(this._ctl, x, y, width, height,
|
|
61
61
|
sock, display, depth);
|
|
62
62
|
} else {
|
|
@@ -80,7 +80,7 @@ export default class TightDecoder {
|
|
|
80
80
|
const rQ = sock.rQ;
|
|
81
81
|
|
|
82
82
|
display.fillRect(x, y, width, height,
|
|
83
|
-
[rQ[rQi
|
|
83
|
+
[rQ[rQi], rQ[rQi + 1], rQ[rQi + 2]], false);
|
|
84
84
|
sock.rQskipBytes(3);
|
|
85
85
|
|
|
86
86
|
return true;
|
|
@@ -148,6 +148,10 @@ export default class TightDecoder {
|
|
|
148
148
|
const uncompressedSize = width * height * 3;
|
|
149
149
|
let data;
|
|
150
150
|
|
|
151
|
+
if (uncompressedSize === 0) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
151
155
|
if (uncompressedSize < 12) {
|
|
152
156
|
if (sock.rQwait("TIGHT", uncompressedSize)) {
|
|
153
157
|
return false;
|
|
@@ -165,7 +169,15 @@ export default class TightDecoder {
|
|
|
165
169
|
this._zlibs[streamId].setInput(null);
|
|
166
170
|
}
|
|
167
171
|
|
|
168
|
-
|
|
172
|
+
let rgbx = new Uint8Array(width * height * 4);
|
|
173
|
+
for (let i = 0, j = 0; i < width * height * 4; i += 4, j += 3) {
|
|
174
|
+
rgbx[i] = data[j];
|
|
175
|
+
rgbx[i + 1] = data[j + 1];
|
|
176
|
+
rgbx[i + 2] = data[j + 2];
|
|
177
|
+
rgbx[i + 3] = 255; // Alpha
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
display.blitImage(x, y, width, height, rgbx, 0, false);
|
|
169
181
|
|
|
170
182
|
return true;
|
|
171
183
|
}
|
|
@@ -195,6 +207,10 @@ export default class TightDecoder {
|
|
|
195
207
|
|
|
196
208
|
let data;
|
|
197
209
|
|
|
210
|
+
if (uncompressedSize === 0) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
|
|
198
214
|
if (uncompressedSize < 12) {
|
|
199
215
|
if (sock.rQwait("TIGHT", uncompressedSize)) {
|
|
200
216
|
return false;
|
|
@@ -237,7 +253,7 @@ export default class TightDecoder {
|
|
|
237
253
|
for (let b = 7; b >= 0; b--) {
|
|
238
254
|
dp = (y * width + x * 8 + 7 - b) * 4;
|
|
239
255
|
sp = (data[y * w + x] >> b & 1) * 3;
|
|
240
|
-
dest[dp]
|
|
256
|
+
dest[dp] = palette[sp];
|
|
241
257
|
dest[dp + 1] = palette[sp + 1];
|
|
242
258
|
dest[dp + 2] = palette[sp + 2];
|
|
243
259
|
dest[dp + 3] = 255;
|
|
@@ -247,14 +263,14 @@ export default class TightDecoder {
|
|
|
247
263
|
for (let b = 7; b >= 8 - width % 8; b--) {
|
|
248
264
|
dp = (y * width + x * 8 + 7 - b) * 4;
|
|
249
265
|
sp = (data[y * w + x] >> b & 1) * 3;
|
|
250
|
-
dest[dp]
|
|
266
|
+
dest[dp] = palette[sp];
|
|
251
267
|
dest[dp + 1] = palette[sp + 1];
|
|
252
268
|
dest[dp + 2] = palette[sp + 2];
|
|
253
269
|
dest[dp + 3] = 255;
|
|
254
270
|
}
|
|
255
271
|
}
|
|
256
272
|
|
|
257
|
-
display.
|
|
273
|
+
display.blitImage(x, y, width, height, dest, 0, false);
|
|
258
274
|
}
|
|
259
275
|
|
|
260
276
|
_paletteRect(x, y, width, height, data, palette, display) {
|
|
@@ -263,13 +279,13 @@ export default class TightDecoder {
|
|
|
263
279
|
const total = width * height * 4;
|
|
264
280
|
for (let i = 0, j = 0; i < total; i += 4, j++) {
|
|
265
281
|
const sp = data[j] * 3;
|
|
266
|
-
dest[i]
|
|
282
|
+
dest[i] = palette[sp];
|
|
267
283
|
dest[i + 1] = palette[sp + 1];
|
|
268
284
|
dest[i + 2] = palette[sp + 2];
|
|
269
285
|
dest[i + 3] = 255;
|
|
270
286
|
}
|
|
271
287
|
|
|
272
|
-
display.
|
|
288
|
+
display.blitImage(x, y, width, height, dest, 0, false);
|
|
273
289
|
}
|
|
274
290
|
|
|
275
291
|
_gradientFilter(streamId, x, y, width, height, sock, display, depth) {
|
package/core/display.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
import * as Log from './util/logging.js';
|
|
10
10
|
import Base64 from "./base64.js";
|
|
11
|
-
import { supportsImageMetadata } from './util/browser.js';
|
|
12
11
|
import { toSigned32bit } from './util/int.js';
|
|
13
12
|
|
|
14
13
|
export default class Display {
|
|
@@ -23,10 +22,6 @@ export default class Display {
|
|
|
23
22
|
this._fbHeight = 0;
|
|
24
23
|
|
|
25
24
|
this._prevDrawStyle = "";
|
|
26
|
-
this._tile = null;
|
|
27
|
-
this._tile16x16 = null;
|
|
28
|
-
this._tileX = 0;
|
|
29
|
-
this._tileY = 0;
|
|
30
25
|
|
|
31
26
|
Log.Debug(">> Display.constructor");
|
|
32
27
|
|
|
@@ -60,12 +55,6 @@ export default class Display {
|
|
|
60
55
|
|
|
61
56
|
Log.Debug("User Agent: " + navigator.userAgent);
|
|
62
57
|
|
|
63
|
-
// Check canvas features
|
|
64
|
-
if (!('createImageData' in this._drawCtx)) {
|
|
65
|
-
throw new Error("Canvas does not support createImageData");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
this._tile16x16 = this._drawCtx.createImageData(16, 16);
|
|
69
58
|
Log.Debug("<< Display.constructor");
|
|
70
59
|
|
|
71
60
|
// ===== PROPERTIES =====
|
|
@@ -378,57 +367,6 @@ export default class Display {
|
|
|
378
367
|
});
|
|
379
368
|
}
|
|
380
369
|
|
|
381
|
-
// start updating a tile
|
|
382
|
-
startTile(x, y, width, height, color) {
|
|
383
|
-
this._tileX = x;
|
|
384
|
-
this._tileY = y;
|
|
385
|
-
if (width === 16 && height === 16) {
|
|
386
|
-
this._tile = this._tile16x16;
|
|
387
|
-
} else {
|
|
388
|
-
this._tile = this._drawCtx.createImageData(width, height);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const red = color[2];
|
|
392
|
-
const green = color[1];
|
|
393
|
-
const blue = color[0];
|
|
394
|
-
|
|
395
|
-
const data = this._tile.data;
|
|
396
|
-
for (let i = 0; i < width * height * 4; i += 4) {
|
|
397
|
-
data[i] = red;
|
|
398
|
-
data[i + 1] = green;
|
|
399
|
-
data[i + 2] = blue;
|
|
400
|
-
data[i + 3] = 255;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// update sub-rectangle of the current tile
|
|
405
|
-
subTile(x, y, w, h, color) {
|
|
406
|
-
const red = color[2];
|
|
407
|
-
const green = color[1];
|
|
408
|
-
const blue = color[0];
|
|
409
|
-
const xend = x + w;
|
|
410
|
-
const yend = y + h;
|
|
411
|
-
|
|
412
|
-
const data = this._tile.data;
|
|
413
|
-
const width = this._tile.width;
|
|
414
|
-
for (let j = y; j < yend; j++) {
|
|
415
|
-
for (let i = x; i < xend; i++) {
|
|
416
|
-
const p = (i + (j * width)) * 4;
|
|
417
|
-
data[p] = red;
|
|
418
|
-
data[p + 1] = green;
|
|
419
|
-
data[p + 2] = blue;
|
|
420
|
-
data[p + 3] = 255;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// draw the current tile to the screen
|
|
426
|
-
finishTile() {
|
|
427
|
-
this._drawCtx.putImageData(this._tile, this._tileX, this._tileY);
|
|
428
|
-
this._damage(this._tileX, this._tileY,
|
|
429
|
-
this._tile.width, this._tile.height);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
370
|
blitImage(x, y, width, height, arr, offset, fromQueue) {
|
|
433
371
|
if (this._renderQ.length !== 0 && !fromQueue) {
|
|
434
372
|
// NB(directxman12): it's technically more performant here to use preallocated arrays,
|
|
@@ -445,47 +383,13 @@ export default class Display {
|
|
|
445
383
|
'height': height,
|
|
446
384
|
});
|
|
447
385
|
} else {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
// but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
|
|
456
|
-
// this probably isn't getting called *nearly* as much
|
|
457
|
-
const newArr = new Uint8Array(width * height * 3);
|
|
458
|
-
newArr.set(new Uint8Array(arr.buffer, 0, newArr.length));
|
|
459
|
-
this._renderQPush({
|
|
460
|
-
'type': 'blitRgb',
|
|
461
|
-
'data': newArr,
|
|
462
|
-
'x': x,
|
|
463
|
-
'y': y,
|
|
464
|
-
'width': width,
|
|
465
|
-
'height': height,
|
|
466
|
-
});
|
|
467
|
-
} else {
|
|
468
|
-
this._rgbImageData(x, y, width, height, arr, offset);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
blitRgbxImage(x, y, width, height, arr, offset, fromQueue) {
|
|
473
|
-
if (this._renderQ.length !== 0 && !fromQueue) {
|
|
474
|
-
// NB(directxman12): it's technically more performant here to use preallocated arrays,
|
|
475
|
-
// but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
|
|
476
|
-
// this probably isn't getting called *nearly* as much
|
|
477
|
-
const newArr = new Uint8Array(width * height * 4);
|
|
478
|
-
newArr.set(new Uint8Array(arr.buffer, 0, newArr.length));
|
|
479
|
-
this._renderQPush({
|
|
480
|
-
'type': 'blitRgbx',
|
|
481
|
-
'data': newArr,
|
|
482
|
-
'x': x,
|
|
483
|
-
'y': y,
|
|
484
|
-
'width': width,
|
|
485
|
-
'height': height,
|
|
486
|
-
});
|
|
487
|
-
} else {
|
|
488
|
-
this._rgbxImageData(x, y, width, height, arr, offset);
|
|
386
|
+
// NB(directxman12): arr must be an Type Array view
|
|
387
|
+
let data = new Uint8ClampedArray(arr.buffer,
|
|
388
|
+
arr.byteOffset + offset,
|
|
389
|
+
width * height * 4);
|
|
390
|
+
let img = new ImageData(data, width, height);
|
|
391
|
+
this._drawCtx.putImageData(img, x, y);
|
|
392
|
+
this._damage(x, y, width, height);
|
|
489
393
|
}
|
|
490
394
|
}
|
|
491
395
|
|
|
@@ -537,52 +441,13 @@ export default class Display {
|
|
|
537
441
|
}
|
|
538
442
|
|
|
539
443
|
_setFillColor(color) {
|
|
540
|
-
const newStyle = 'rgb(' + color[
|
|
444
|
+
const newStyle = 'rgb(' + color[0] + ',' + color[1] + ',' + color[2] + ')';
|
|
541
445
|
if (newStyle !== this._prevDrawStyle) {
|
|
542
446
|
this._drawCtx.fillStyle = newStyle;
|
|
543
447
|
this._prevDrawStyle = newStyle;
|
|
544
448
|
}
|
|
545
449
|
}
|
|
546
450
|
|
|
547
|
-
_rgbImageData(x, y, width, height, arr, offset) {
|
|
548
|
-
const img = this._drawCtx.createImageData(width, height);
|
|
549
|
-
const data = img.data;
|
|
550
|
-
for (let i = 0, j = offset; i < width * height * 4; i += 4, j += 3) {
|
|
551
|
-
data[i] = arr[j];
|
|
552
|
-
data[i + 1] = arr[j + 1];
|
|
553
|
-
data[i + 2] = arr[j + 2];
|
|
554
|
-
data[i + 3] = 255; // Alpha
|
|
555
|
-
}
|
|
556
|
-
this._drawCtx.putImageData(img, x, y);
|
|
557
|
-
this._damage(x, y, img.width, img.height);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
_bgrxImageData(x, y, width, height, arr, offset) {
|
|
561
|
-
const img = this._drawCtx.createImageData(width, height);
|
|
562
|
-
const data = img.data;
|
|
563
|
-
for (let i = 0, j = offset; i < width * height * 4; i += 4, j += 4) {
|
|
564
|
-
data[i] = arr[j + 2];
|
|
565
|
-
data[i + 1] = arr[j + 1];
|
|
566
|
-
data[i + 2] = arr[j];
|
|
567
|
-
data[i + 3] = 255; // Alpha
|
|
568
|
-
}
|
|
569
|
-
this._drawCtx.putImageData(img, x, y);
|
|
570
|
-
this._damage(x, y, img.width, img.height);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
_rgbxImageData(x, y, width, height, arr, offset) {
|
|
574
|
-
// NB(directxman12): arr must be an Type Array view
|
|
575
|
-
let img;
|
|
576
|
-
if (supportsImageMetadata) {
|
|
577
|
-
img = new ImageData(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4), width, height);
|
|
578
|
-
} else {
|
|
579
|
-
img = this._drawCtx.createImageData(width, height);
|
|
580
|
-
img.data.set(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4));
|
|
581
|
-
}
|
|
582
|
-
this._drawCtx.putImageData(img, x, y);
|
|
583
|
-
this._damage(x, y, img.width, img.height);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
451
|
_renderQPush(action) {
|
|
587
452
|
this._renderQ.push(action);
|
|
588
453
|
if (this._renderQ.length === 1) {
|
|
@@ -616,15 +481,8 @@ export default class Display {
|
|
|
616
481
|
case 'blit':
|
|
617
482
|
this.blitImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
|
618
483
|
break;
|
|
619
|
-
case 'blitRgb':
|
|
620
|
-
this.blitRgbImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
|
621
|
-
break;
|
|
622
|
-
case 'blitRgbx':
|
|
623
|
-
this.blitRgbxImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
|
624
|
-
break;
|
|
625
484
|
case 'img':
|
|
626
|
-
|
|
627
|
-
if (a.img.complete && (a.img.width !== 0) && (a.img.height !== 0)) {
|
|
485
|
+
if (a.img.complete) {
|
|
628
486
|
if (a.img.width !== a.width || a.img.height !== a.height) {
|
|
629
487
|
Log.Error("Decoded image has incorrect dimensions. Got " +
|
|
630
488
|
a.img.width + "x" + a.img.height + ". Expected " +
|
|
@@ -35,7 +35,7 @@ function addNumpad(key, standard, numpad) {
|
|
|
35
35
|
DOMKeyTable[key] = [standard, standard, standard, numpad];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
//
|
|
38
|
+
// 3.2. Modifier Keys
|
|
39
39
|
|
|
40
40
|
addLeftRight("Alt", KeyTable.XK_Alt_L, KeyTable.XK_Alt_R);
|
|
41
41
|
addStandard("AltGraph", KeyTable.XK_ISO_Level3_Shift);
|
|
@@ -49,25 +49,27 @@ addStandard("ScrollLock", KeyTable.XK_Scroll_Lock);
|
|
|
49
49
|
addLeftRight("Shift", KeyTable.XK_Shift_L, KeyTable.XK_Shift_R);
|
|
50
50
|
// - Symbol
|
|
51
51
|
// - SymbolLock
|
|
52
|
+
// - Hyper
|
|
53
|
+
// - Super
|
|
52
54
|
|
|
53
|
-
//
|
|
55
|
+
// 3.3. Whitespace Keys
|
|
54
56
|
|
|
55
57
|
addNumpad("Enter", KeyTable.XK_Return, KeyTable.XK_KP_Enter);
|
|
56
58
|
addStandard("Tab", KeyTable.XK_Tab);
|
|
57
59
|
addNumpad(" ", KeyTable.XK_space, KeyTable.XK_KP_Space);
|
|
58
60
|
|
|
59
|
-
//
|
|
61
|
+
// 3.4. Navigation Keys
|
|
60
62
|
|
|
61
63
|
addNumpad("ArrowDown", KeyTable.XK_Down, KeyTable.XK_KP_Down);
|
|
62
|
-
addNumpad("ArrowUp", KeyTable.XK_Up, KeyTable.XK_KP_Up);
|
|
63
64
|
addNumpad("ArrowLeft", KeyTable.XK_Left, KeyTable.XK_KP_Left);
|
|
64
65
|
addNumpad("ArrowRight", KeyTable.XK_Right, KeyTable.XK_KP_Right);
|
|
66
|
+
addNumpad("ArrowUp", KeyTable.XK_Up, KeyTable.XK_KP_Up);
|
|
65
67
|
addNumpad("End", KeyTable.XK_End, KeyTable.XK_KP_End);
|
|
66
68
|
addNumpad("Home", KeyTable.XK_Home, KeyTable.XK_KP_Home);
|
|
67
69
|
addNumpad("PageDown", KeyTable.XK_Next, KeyTable.XK_KP_Next);
|
|
68
70
|
addNumpad("PageUp", KeyTable.XK_Prior, KeyTable.XK_KP_Prior);
|
|
69
71
|
|
|
70
|
-
//
|
|
72
|
+
// 3.5. Editing Keys
|
|
71
73
|
|
|
72
74
|
addStandard("Backspace", KeyTable.XK_BackSpace);
|
|
73
75
|
// Browsers send "Clear" for the numpad 5 without NumLock because
|
|
@@ -85,7 +87,7 @@ addStandard("Paste", KeyTable.XF86XK_Paste);
|
|
|
85
87
|
addStandard("Redo", KeyTable.XK_Redo);
|
|
86
88
|
addStandard("Undo", KeyTable.XK_Undo);
|
|
87
89
|
|
|
88
|
-
//
|
|
90
|
+
// 3.6. UI Keys
|
|
89
91
|
|
|
90
92
|
// - Accept
|
|
91
93
|
// - Again (could just be XK_Redo)
|
|
@@ -103,7 +105,7 @@ addStandard("Select", KeyTable.XK_Select);
|
|
|
103
105
|
addStandard("ZoomIn", KeyTable.XF86XK_ZoomIn);
|
|
104
106
|
addStandard("ZoomOut", KeyTable.XF86XK_ZoomOut);
|
|
105
107
|
|
|
106
|
-
//
|
|
108
|
+
// 3.7. Device Keys
|
|
107
109
|
|
|
108
110
|
addStandard("BrightnessDown", KeyTable.XF86XK_MonBrightnessDown);
|
|
109
111
|
addStandard("BrightnessUp", KeyTable.XF86XK_MonBrightnessUp);
|
|
@@ -116,10 +118,10 @@ addStandard("Hibernate", KeyTable.XF86XK_Hibernate);
|
|
|
116
118
|
addStandard("Standby", KeyTable.XF86XK_Standby);
|
|
117
119
|
addStandard("WakeUp", KeyTable.XF86XK_WakeUp);
|
|
118
120
|
|
|
119
|
-
//
|
|
121
|
+
// 3.8. IME and Composition Keys
|
|
120
122
|
|
|
121
123
|
addStandard("AllCandidates", KeyTable.XK_MultipleCandidate);
|
|
122
|
-
addStandard("Alphanumeric", KeyTable.
|
|
124
|
+
addStandard("Alphanumeric", KeyTable.XK_Eisu_toggle);
|
|
123
125
|
addStandard("CodeInput", KeyTable.XK_Codeinput);
|
|
124
126
|
addStandard("Compose", KeyTable.XK_Multi_key);
|
|
125
127
|
addStandard("Convert", KeyTable.XK_Henkan);
|
|
@@ -137,7 +139,7 @@ addStandard("PreviousCandidate", KeyTable.XK_PreviousCandidate);
|
|
|
137
139
|
addStandard("SingleCandidate", KeyTable.XK_SingleCandidate);
|
|
138
140
|
addStandard("HangulMode", KeyTable.XK_Hangul);
|
|
139
141
|
addStandard("HanjaMode", KeyTable.XK_Hangul_Hanja);
|
|
140
|
-
addStandard("
|
|
142
|
+
addStandard("JunjaMode", KeyTable.XK_Hangul_Jeonja);
|
|
141
143
|
addStandard("Eisu", KeyTable.XK_Eisu_toggle);
|
|
142
144
|
addStandard("Hankaku", KeyTable.XK_Hankaku);
|
|
143
145
|
addStandard("Hiragana", KeyTable.XK_Hiragana);
|
|
@@ -147,9 +149,9 @@ addStandard("KanjiMode", KeyTable.XK_Kanji);
|
|
|
147
149
|
addStandard("Katakana", KeyTable.XK_Katakana);
|
|
148
150
|
addStandard("Romaji", KeyTable.XK_Romaji);
|
|
149
151
|
addStandard("Zenkaku", KeyTable.XK_Zenkaku);
|
|
150
|
-
addStandard("
|
|
152
|
+
addStandard("ZenkakuHankaku", KeyTable.XK_Zenkaku_Hankaku);
|
|
151
153
|
|
|
152
|
-
//
|
|
154
|
+
// 3.9. General-Purpose Function Keys
|
|
153
155
|
|
|
154
156
|
addStandard("F1", KeyTable.XK_F1);
|
|
155
157
|
addStandard("F2", KeyTable.XK_F2);
|
|
@@ -188,7 +190,7 @@ addStandard("F34", KeyTable.XK_F34);
|
|
|
188
190
|
addStandard("F35", KeyTable.XK_F35);
|
|
189
191
|
// - Soft1...
|
|
190
192
|
|
|
191
|
-
//
|
|
193
|
+
// 3.10. Multimedia Keys
|
|
192
194
|
|
|
193
195
|
// - ChannelDown
|
|
194
196
|
// - ChannelUp
|
|
@@ -200,6 +202,7 @@ addStandard("MailSend", KeyTable.XF86XK_Send);
|
|
|
200
202
|
addStandard("MediaFastForward", KeyTable.XF86XK_AudioForward);
|
|
201
203
|
addStandard("MediaPause", KeyTable.XF86XK_AudioPause);
|
|
202
204
|
addStandard("MediaPlay", KeyTable.XF86XK_AudioPlay);
|
|
205
|
+
// - MediaPlayPause
|
|
203
206
|
addStandard("MediaRecord", KeyTable.XF86XK_AudioRecord);
|
|
204
207
|
addStandard("MediaRewind", KeyTable.XF86XK_AudioRewind);
|
|
205
208
|
addStandard("MediaStop", KeyTable.XF86XK_AudioStop);
|
|
@@ -211,12 +214,12 @@ addStandard("Print", KeyTable.XK_Print);
|
|
|
211
214
|
addStandard("Save", KeyTable.XF86XK_Save);
|
|
212
215
|
addStandard("SpellCheck", KeyTable.XF86XK_Spell);
|
|
213
216
|
|
|
214
|
-
//
|
|
217
|
+
// 3.11. Multimedia Numpad Keys
|
|
215
218
|
|
|
216
219
|
// - Key11
|
|
217
220
|
// - Key12
|
|
218
221
|
|
|
219
|
-
//
|
|
222
|
+
// 3.12. Audio Keys
|
|
220
223
|
|
|
221
224
|
// - AudioBalanceLeft
|
|
222
225
|
// - AudioBalanceRight
|
|
@@ -236,16 +239,17 @@ addStandard("AudioVolumeMute", KeyTable.XF86XK_AudioMute);
|
|
|
236
239
|
// - MicrophoneVolumeUp
|
|
237
240
|
addStandard("MicrophoneVolumeMute", KeyTable.XF86XK_AudioMicMute);
|
|
238
241
|
|
|
239
|
-
//
|
|
242
|
+
// 3.13. Speech Keys
|
|
240
243
|
|
|
241
244
|
// - SpeechCorrectionList
|
|
242
245
|
// - SpeechInputToggle
|
|
243
246
|
|
|
244
|
-
//
|
|
247
|
+
// 3.14. Application Keys
|
|
245
248
|
|
|
246
249
|
addStandard("LaunchApplication1", KeyTable.XF86XK_MyComputer);
|
|
247
250
|
addStandard("LaunchApplication2", KeyTable.XF86XK_Calculator);
|
|
248
251
|
addStandard("LaunchCalendar", KeyTable.XF86XK_Calendar);
|
|
252
|
+
// - LaunchContacts
|
|
249
253
|
addStandard("LaunchMail", KeyTable.XF86XK_Mail);
|
|
250
254
|
addStandard("LaunchMediaPlayer", KeyTable.XF86XK_AudioMedia);
|
|
251
255
|
addStandard("LaunchMusicPlayer", KeyTable.XF86XK_Music);
|
|
@@ -256,7 +260,7 @@ addStandard("LaunchWebBrowser", KeyTable.XF86XK_WWW);
|
|
|
256
260
|
addStandard("LaunchWebCam", KeyTable.XF86XK_WebCam);
|
|
257
261
|
addStandard("LaunchWordProcessor", KeyTable.XF86XK_Word);
|
|
258
262
|
|
|
259
|
-
//
|
|
263
|
+
// 3.15. Browser Keys
|
|
260
264
|
|
|
261
265
|
addStandard("BrowserBack", KeyTable.XF86XK_Back);
|
|
262
266
|
addStandard("BrowserFavorites", KeyTable.XF86XK_Favorites);
|
|
@@ -266,15 +270,15 @@ addStandard("BrowserRefresh", KeyTable.XF86XK_Refresh);
|
|
|
266
270
|
addStandard("BrowserSearch", KeyTable.XF86XK_Search);
|
|
267
271
|
addStandard("BrowserStop", KeyTable.XF86XK_Stop);
|
|
268
272
|
|
|
269
|
-
//
|
|
273
|
+
// 3.16. Mobile Phone Keys
|
|
270
274
|
|
|
271
275
|
// - A whole bunch...
|
|
272
276
|
|
|
273
|
-
//
|
|
277
|
+
// 3.17. TV Keys
|
|
274
278
|
|
|
275
279
|
// - A whole bunch...
|
|
276
280
|
|
|
277
|
-
//
|
|
281
|
+
// 3.18. Media Controller Keys
|
|
278
282
|
|
|
279
283
|
// - A whole bunch...
|
|
280
284
|
addStandard("Dimmer", KeyTable.XF86XK_BrightnessAdjust);
|