An RFB object represents a single connection so it doesn't make
sense to have one without it trying to connect right away. Matches
the behaviour of other APIs, e.g. WebSocket.
Use normal properties with JavaScript setters and getters instead of
our homegrown stuff.
This also changes the properties to follow normal naming conventions.
Sort things by category, and organise everything in the same place.
We don't support reuse of RFB objects so we can safely init everything
in the constructor.
The previous method of retaining focus didn't work reliably when
the RFB object tried to move the focus to the canvas. Add a setting
to control "focus on click" behaviour instead of letting them try
to fight it out.
Give the canvas proper focus handling. This avoids messy logic that
needs to disable and enable event handling when we want to interact
with other UI elements.
It also makes sure we can properly inhibit the browser from triggering
local actions on key presses.
This restores basic support for Intel AMT servers. They refuse clients
that request more than 16 bits per pixels, so implement a fallback
in just the "Raw" encoding.
Servers will assume that a scan code is present if this message type
is used, so fall back to the standard key event message if we don't
know the scan code.
The fields provided cannot tell us if it is the left or right
version of the key that's pressed, so they are inherently unreliable.
It is also not a huge problem in practice as we'll get in sync on
the next press or release of the modifier.
If down is false we can't just toggle the current internal state, even
though this is correct most of the time. There are cases where we don't
get the down event and thus won't have a correct internal state. For
example, when clicking in the session after using the clipboard
textarea.
If down is false, we always want to send a mouse event with the button
in 'up'-state.
This commit restructures many of the ES6 modules, splitting them
up to actual export multiple functions instead of a single object.
It also splits up Util into multiple sub-modules, to make it easier
to maintain.
Finally, localisation is renamed to localization.
This removes the special comment part of the ES6 module syntax,
opting to enable ES6 module syntax by default.
It also appends `.js` to all import paths to better support in-browser
loading.
We don't have to check for _display or context here since this is a
private function which is never called under such circumstances. This
solves problems caused by display.get_context() which was previously
removed in e549ae074f.
The old default was to ask for the maximum compression level. This
is against the recommendations in libvncserver/tight.c due to excessive
CPU load. It also causes Vino 3.8.1 (still shipped with Ubuntu 16.04
LTS) to prefer the blurry JPEG compression too much - e.g. red text on
the default background in MATE terminal becomes almost unreadable.
The new default is the recommended compression level for low-color
workloads, according to libvncserver source. Also, it is the maximum
compression level that doesn't trigger the Vino bug with red text in
most cases.
Fixes issue #737.
Do all rendering to a hidden canvas and then copy over the finished
frame to the visible canvas once everything is done. This simplifies
things and solves some bugs as we can retain a copy of the entire
frame buffer.
Supports server configurations that might prefer wss:// connections
on the default port, then proxies them through the web server to the
VNC server.
This proxy configuration is helpful on servers using self-signed
certificates. Accessing the https://host/vnc_auto.html page and
adding an exception for that host is sufficient to also satisfy the
wss://host/ request, unlike requests to wss://host:port/ which
may require an extra certificate exception.
RFB's _fail function logs the error, disconnects the session and sets
disconnect_reason. The disconnect_reason is upon disconnection sent to
the user interface. It is thus not suitable for including error details
that aren't user friendly. The idea is that you will look in the
browser console for a full log with details of the error.
RFB._fail() can be called at any time in any state, it is not certain
that we will get a close event on the socket since the socket might not
be open. This caused us to hit the disconnect timeout in such cases.
Fixes issue #678
For example, previously if the user typed in illegal characters in the
port field, no error would be displayed in the interface and the page
would stop at "connecting".
The callers don't need to concern themselves with how images are
rendered, so hide the details behind the API. This also avoids
exposing the render queue.
The states 'loaded', 'failed' and 'fatal' were all variations of the
'disconnected' state. Removing these states allows us to get rid of
many ugly workarounds and special cases. Error messages to the UI can
now instead be delivered via a new onDisconnected callback.
Names such as 'disconnect' and 'disconnected' are inconsistent in the
way that one describes an action and the other a state. The state that
was called 'normal' didn't fit in with the others because the other
names describe a connection state. The new names are: 'disconnecting',
'connecting' and 'connected'