Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions core/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default class Display {
}

this._targetCtx = this._target.getContext('2d');
this._visibleCtx = this._targetCtx; // persistent ref to visible canvas, never reassigned

Log.Debug("User Agent: " + navigator.userAgent);

Expand Down Expand Up @@ -151,21 +152,21 @@ export default class Display {
if (value === this._enableCanvasBuffer) { return; }

this._enableCanvasBuffer = value;
this._targetCtx = value ? this._drawCtx : this._targetCtx;
this._targetCtx = value ? this._drawCtx : this._visibleCtx;

if (value && this._target)
{
//copy current visible canvas to backbuffer
let saveImg = this._targetCtx.getImageData(0, 0, this._target.width, this._target.height);
let saveImg = this._visibleCtx.getImageData(0, 0, this._target.width, this._target.height);
this._drawCtx.putImageData(saveImg, 0, 0);

if (this._transparentOverlayImg) {
this.drawImage(this._transparentOverlayImg, this._transparentOverlayRect.x, this._transparentOverlayRect.y, this._transparentOverlayRect.width, this._transparentOverlayRect.height, true);
}
} else if (!value && this._target) {
//copy backbuffer to canvas to clear any overlays
let saveImg = this._targetCtx.getImageData(0, 0, this._target.width, this._target.height);
this._drawCtx.putImageData(saveImg, 0, 0);
let saveImg = this._drawCtx.getImageData(0, 0, this._target.width, this._target.height);
this._visibleCtx.putImageData(saveImg, 0, 0);
}
}

Expand Down Expand Up @@ -544,7 +545,7 @@ export default class Display {
if (canvas.width !== width || canvas.height !== height) {
let saveImg = null;
if (canvas.width > 0 && canvas.height > 0) {
saveImg = this._targetCtx.getImageData(0, 0, canvas.width, canvas.height);
saveImg = this._visibleCtx.getImageData(0, 0, canvas.width, canvas.height);
}

vp.serverWidth = width;
Expand All @@ -554,7 +555,7 @@ export default class Display {
canvas.height = height;

if (saveImg) {
this._targetCtx.putImageData(saveImg, 0, 0);
this._visibleCtx.putImageData(saveImg, 0, 0);
}

// The position might need to be updated if we've grown
Expand Down Expand Up @@ -673,8 +674,8 @@ export default class Display {
dispose() {
clearInterval(this._frameStatsInterval);
this.clear();
if (this._targetCtx && this._target) {
this._targetCtx.clearRect(0,0, this._target.width, this._target.height);
if (this._visibleCtx && this._target) {
this._visibleCtx.clearRect(0,0, this._target.width, this._target.height);
}
}

Expand Down Expand Up @@ -930,10 +931,11 @@ export default class Display {

drawImage(img, x, y, w, h, overlay=false) {
try {
const ctx = (overlay && this._enableCanvasBuffer) ? this._visibleCtx : this._targetCtx;
if (img.width !== w || img.height !== h) {
this._targetCtx.drawImage(img, x, y, w, h);
ctx.drawImage(img, x, y, w, h);
} else {
this._targetCtx.drawImage(img, x, y);
ctx.drawImage(img, x, y);
}
} catch (error) {
Log.Error('Invalid image received.'); //KASM-2090
Expand Down Expand Up @@ -1002,7 +1004,7 @@ export default class Display {
_writeCtxBuffer() {
//TODO: KASM-5450 Damage tracking with transparent rect overlay support
if (this._backbuffer.width > 0) {
this._targetCtx.drawImage(this._backbuffer, 0, 0);
this._visibleCtx.drawImage(this._backbuffer, 0, 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/input/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class Keyboard {
break;
case "AltLeft":
case "AltRight":
if (!event.altKey) {
if (!event.altKey && !event.key == "AltGraph") {
Log.Error("A alt key is stuck down, sending up. ");
this._sendKeyEvent(value, key, false);
}
Expand Down
Loading