Skip to content

Commit d7791eb

Browse files
Make the screen background cutomizable
1 parent 823daa8 commit d7791eb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

core/rfb.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import TightPNGDecoder from "./decoders/tightpng.js";
3131

3232
// How many seconds to wait for a disconnect to finish
3333
const DISCONNECT_TIMEOUT = 3;
34+
const DEFAULT_BACKGROUND = 'rgb(40, 40, 40)';
3435

3536
export default class RFB extends EventTargetMixin {
3637
constructor(target, url, options) {
@@ -128,7 +129,7 @@ export default class RFB extends EventTargetMixin {
128129
this._screen.style.width = '100%';
129130
this._screen.style.height = '100%';
130131
this._screen.style.overflow = 'auto';
131-
this._screen.style.backgroundColor = 'rgb(40, 40, 40)';
132+
this._screen.style.background = DEFAULT_BACKGROUND;
132133
this._canvas = document.createElement('canvas');
133134
this._canvas.style.margin = 'auto';
134135
// Some browsers add an outline on focus
@@ -302,6 +303,9 @@ export default class RFB extends EventTargetMixin {
302303
this._refreshCursor();
303304
}
304305

306+
get background() { return this._screen.style.background; }
307+
set background(cssValue) { this._screen.style.background = cssValue; }
308+
305309
// ===== PUBLIC METHODS =====
306310

307311
disconnect() {

docs/API.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ protocol stream.
5858
instead of a zero-sized or fully-transparent cursor if the server
5959
sets such invisible cursor. Disabled by default.
6060

61+
`background`
62+
- Is a valid CSS [background](https://developer.mozilla.org/en-US/docs/Web/CSS/background)
63+
style value indicating which background style should be applied
64+
to the element containing the remote session screen. The default value is `rgb(40, 40, 40)`
65+
(solid gray color).
66+
6167
`capabilities` *Read only*
6268
- Is an `Object` indicating which optional extensions are available
6369
on the server. Some methods may only be called if the corresponding

0 commit comments

Comments
 (0)