return true;
}
- if (this._qemuExtKeyEventSupported) {
- var scancode = XtScancode[code];
-
- if (scancode === undefined) {
- Log.Error('Unable to find a xt scancode for code: ' + code);
- // FIXME: not in the spec, but this is what
- // gtk-vnc does
- scancode = 0;
- }
+ var scancode = XtScancode[code];
+
+ if (this._qemuExtKeyEventSupported && scancode) {
+ // 0 is NoSymbol
+ keysym = keysym || 0;
Log.Info("Sending key (" + (down ? "down" : "up") + "): keysym " + keysym + ", scancode " + scancode);
RFB.messages.QEMUExtendedKeyEvent(this._sock, keysym, down, scancode);
} else {
+ if (!keysym) {
+ return false;
+ }
Log.Info("Sending keysym (" + (down ? "down" : "up") + "): " + keysym);
RFB.messages.keyEvent(this._sock, keysym, down ? 1 : 0);
}
} else {
return this._fail("Authentication failure");
}
- return false;
case 2:
return this._fail("Too many authentication attempts");
default:
if (this._sock.rQwait("server initialization", 24)) { return false; }
/* Screen size */
- this._fb_width = this._sock.rQshift16();
- this._fb_height = this._sock.rQshift16();
- this._destBuff = new Uint8Array(this._fb_width * this._fb_height * 4);
+ var width = this._sock.rQshift16();
+ var height = this._sock.rQshift16();
/* PIXEL_FORMAT */
var bpp = this._sock.rQshift8();
// NB(directxman12): these are down here so that we don't run them multiple times
// if we backtrack
- Log.Info("Screen: " + this._fb_width + "x" + this._fb_height +
+ Log.Info("Screen: " + width + "x" + height +
", bpp: " + bpp + ", depth: " + depth +
", big_endian: " + big_endian +
", true_color: " + true_color +
// we're past the point where we could backtrack, so it's safe to call this
this._onDesktopName(this, this._fb_name);
- this._display.resize(this._fb_width, this._fb_height);
- this._onFBResize(this, this._fb_width, this._fb_height);
+ this._resize(width, height);
if (!this._view_only) { this._keyboard.grab(); }
if (!this._view_only) { this._mouse.grab(); }
RFB.messages.enableContinuousUpdates(this._sock, true, 0, 0,
this._fb_width, this._fb_height);
+ },
+
+ _resize: function(width, height) {
+ this._fb_width = width;
+ this._fb_height = height;
+
+ this._destBuff = new Uint8Array(this._fb_width * this._fb_height * 4);
+
+ this._display.resize(this._fb_width, this._fb_height);
+ this._onFBResize(this, this._fb_width, this._fb_height);
+
+ this._timing.fbu_rt_start = (new Date()).getTime();
+ this._updateContinuousUpdates();
}
};
return true;
},
- getTightCLength: function (arr) {
- var header = 1, data = 0;
- data += arr[0] & 0x7f;
- if (arr[0] & 0x80) {
- header++;
- data += (arr[1] & 0x7f) << 7;
- if (arr[1] & 0x80) {
- header++;
- data += arr[2] << 14;
- }
- }
- return [header, data];
- },
-
- display_tight: function (isTightPNG) {
+ TIGHT: function () {
this._FBU.bytes = 1; // compression-control byte
if (this._sock.rQwait("TIGHT compression-control", this._FBU.bytes)) { return false; }
"Illegal tight compression received, " +
"ctl: " + ctl);
- if (isTightPNG && (cmode === "filter" || cmode === "copy")) {
- return this._fail("Unexpected server message",
- "filter/copy received in tightPNG mode");
- }
-
switch (cmode) {
// fill use depth because TPIXELs drop the padding byte
case "fill": // TPIXEL
return true;
},
- TIGHT: function () { return this._encHandlers.display_tight(false); },
- TIGHT_PNG: function () { return this._encHandlers.display_tight(true); },
-
last_rect: function () {
this._FBU.rects = 0;
return true;
},
- handle_FB_resize: function () {
- this._fb_width = this._FBU.width;
- this._fb_height = this._FBU.height;
- this._destBuff = new Uint8Array(this._fb_width * this._fb_height * 4);
- this._display.resize(this._fb_width, this._fb_height);
- this._onFBResize(this, this._fb_width, this._fb_height);
- this._timing.fbu_rt_start = (new Date()).getTime();
- this._updateContinuousUpdates();
-
- this._FBU.bytes = 0;
- this._FBU.rects -= 1;
- return true;
- },
-
ExtendedDesktopSize: function () {
this._FBU.bytes = 1;
if (this._sock.rQwait("ExtendedDesktopSize", this._FBU.bytes)) { return false; }
}
this._notification("Server did not accept the resize request: "
+ msg, 'normal');
- return true;
+ } else {
+ this._resize(this._FBU.width, this._FBU.height);
}
- this._encHandlers.handle_FB_resize();
+ this._FBU.bytes = 0;
+ this._FBU.rects -= 1;
return true;
},
DesktopSize: function () {
- this._encHandlers.handle_FB_resize();
+ this._resize(this._FBU.width, this._FBU.height);
+ this._FBU.bytes = 0;
+ this._FBU.rects -= 1;
return true;
},
QEMUExtendedKeyEvent: function () {
this._FBU.rects--;
- var keyboardEvent = document.createEvent("keyboardEvent");
- if (keyboardEvent.code !== undefined) {
- this._qemuExtKeyEventSupported = true;
+ // Old Safari doesn't support creating keyboard events
+ try {
+ var keyboardEvent = document.createEvent("keyboardEvent");
+ if (keyboardEvent.code !== undefined) {
+ this._qemuExtKeyEventSupported = true;
+ }
+ } catch (err) {
}
},
-
- JPEG_quality_lo: function () {
- Log.Error("Server sent jpeg_quality pseudo-encoding");
- },
-
- compress_lo: function () {
- Log.Error("Server sent compress level pseudo-encoding");
- }
};