Add support for DesktopName extension
This extension allows session name to be changed during runtime.
This commit is contained in:
committed by
Lauri Kasanen
parent
c16cc6e2b9
commit
8c43287afb
@@ -542,6 +542,13 @@ export default class RFB extends EventTargetMixin {
|
||||
this.focus();
|
||||
}
|
||||
|
||||
_setDesktopName(name) {
|
||||
this._fb_name = name;
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
"desktopname",
|
||||
{ detail: { name: this._fb_name } }));
|
||||
}
|
||||
|
||||
_windowResize(event) {
|
||||
// If the window resized then our screen element might have
|
||||
// as well. Update the viewport dimensions.
|
||||
@@ -1256,7 +1263,7 @@ export default class RFB extends EventTargetMixin {
|
||||
/* Connection name/title */
|
||||
const name_length = this._sock.rQshift32();
|
||||
if (this._sock.rQwait('server init name', name_length, 24)) { return false; }
|
||||
this._fb_name = decodeUTF8(this._sock.rQshiftStr(name_length));
|
||||
let name = decodeUTF8(this._sock.rQshiftStr(name_length));
|
||||
|
||||
if (this._rfb_tightvnc) {
|
||||
if (this._sock.rQwait('TightVNC extended server init header', 8, 24 + name_length)) { return false; }
|
||||
@@ -1296,10 +1303,7 @@ export default class RFB extends EventTargetMixin {
|
||||
", blue_shift: " + blue_shift);
|
||||
|
||||
// we're past the point where we could backtrack, so it's safe to call this
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
"desktopname",
|
||||
{ detail: { name: this._fb_name } }));
|
||||
|
||||
this._setDesktopName(name);
|
||||
this._resize(width, height);
|
||||
|
||||
if (!this._viewOnly) { this._keyboard.grab(); }
|
||||
@@ -1383,6 +1387,7 @@ export default class RFB extends EventTargetMixin {
|
||||
encs.push(encodings.pseudoEncodingXvp);
|
||||
encs.push(encodings.pseudoEncodingFence);
|
||||
encs.push(encodings.pseudoEncodingContinuousUpdates);
|
||||
encs.push(encodings.pseudoEncodingDesktopName);
|
||||
if (this._hasWebp())
|
||||
encs.push(encodings.pseudoEncodingWEBP);
|
||||
|
||||
@@ -1694,6 +1699,9 @@ export default class RFB extends EventTargetMixin {
|
||||
}
|
||||
return true;
|
||||
|
||||
case encodings.pseudoEncodingDesktopName:
|
||||
return this._handleDesktopName();
|
||||
|
||||
case encodings.pseudoEncodingDesktopSize:
|
||||
this._resize(this._FBU.width, this._FBU.height);
|
||||
return true;
|
||||
@@ -1743,6 +1751,25 @@ export default class RFB extends EventTargetMixin {
|
||||
return true;
|
||||
}
|
||||
|
||||
_handleDesktopName() {
|
||||
if (this._sock.rQwait("DesktopName", 4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let length = this._sock.rQshift32();
|
||||
|
||||
if (this._sock.rQwait("DesktopName", length, 4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let name = this._sock.rQshiftStr(length);
|
||||
name = decodeUTF8(name);
|
||||
|
||||
this._setDesktopName(name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_handleExtendedDesktopSize() {
|
||||
if (this._sock.rQwait("ExtendedDesktopSize", 4)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user