Commit Graph

280 Commits

Author SHA1 Message Date
Samuel Mannehed 10d1ecc118 Remove return value from event handlers
It's not used in modern event handlers.
2017-02-16 13:59:34 +01:00
Samuel Mannehed a0e3ec0ae6 Stop using window.event
It's an old propriatary IE thing that isn't necessary.
2017-02-16 13:59:34 +01:00
Samuel Mannehed af1b2ae1e5 Remove Util.getEventPosition()
It mostly dealt with scrolling which we don't use. It also made mistakes
in some cases. Remove it and compute the coordinates directly in the
calling code.
2017-02-16 13:59:34 +01:00
Samuel Mannehed b69dda9b19 Clean up some mouse workarounds
Adds comments that clarifies why they are needed. Also narrows the
handler for contextmenu a bit.
2017-02-16 13:59:34 +01:00
Samuel Mannehed 1658466579 Improve setCapture polyfill
Fix some corner cases.

Fixes issue #773
2017-02-16 13:59:22 +01:00
Pierre Ossman 0ee5ca6ebe Fix tests after changing auth negotiation
PhantomJS has a very basic implementation of Uint8Array, so we
need to help it out a bit.
2017-02-13 15:00:32 +01:00
Pierre Ossman 95533c579e Better selection of auth type
If no authentication is required then we should pick the None
option to avoid bothering the user.
2017-02-13 13:58:10 +01:00
Pierre Ossman 6ffdfd3aa7 Improve check for when to ignore mouse events
The browser tells us which element was under the cursor, so we don't
have to calculate it ourselves.
2017-02-09 16:02:58 +01:00
Pierre Ossman 86d15a4929 Use setCapture() polyfill everywhere
This makes sure we get consistent behaviour across all browsers.
2017-02-09 15:51:22 +01:00
Pierre Ossman d314d2c226 Merge branch 'util-console' of https://github.com/tghw/noVNC 2017-02-07 16:37:58 +01:00
Pierre Ossman d2467189f5 Don't delay WebSocket flushing
The native WebSocket is in a much better position to do queue
management than us. We also failed to check the return value and
set up a timer, causing stalls.

This gets us in sync with websockify as of 40238b00.
2017-02-03 17:12:41 +01:00
Pierre Ossman 2e6a58fb15 Avoid changing scale unless necessary
It causes the browser to redo the layout needlessly otherwise,
having annoying effects like moving the scroll position.
2017-02-03 12:00:13 +01:00
Pierre Ossman a6e52f9a73 Merge display scale changes 2017-02-03 11:56:02 +01:00
Samuel Mannehed 3e08594c89 Fix rfb._cleanup() (#743)
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.
2017-01-09 12:49:10 +01:00
Alexander E. Patrakov a124c8eab2 Changed the default compression level to 2
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.
2016-12-29 18:22:31 +05:00
Lee-Feng 558544364c Fix no auth "this._updateState" bug
Fixes #735
2016-12-20 08:37:31 +01:00
Samuel Mannehed c01b2f0259 Merge pull request #699 from CendioOssman/double
Display double buffering
2016-12-13 12:42:22 +01:00
Pierre Ossman adf345fdc4 Clean up viewport handling
Make sure the viewport is properly updated when necessary, on respects
given restrictions.
2016-12-09 09:20:50 +01:00
Pierre Ossman 3f781f2aa3 Remove max dimension handling
The viewport handling is now a lot clearer, so simply limit the size
of the viewport in the caller rather than having this extra layer
of checks.
2016-12-09 09:20:50 +01:00
Pierre Ossman e549ae074f Prevent access to sensitive display variables
These should not be directly accessed. Instead use drawing operation
and Display.resize().
2016-12-09 09:20:50 +01:00
Pierre Ossman 84cd0e719e Double buffering damage tracking
Optimise the copy from the hidden canvas to the visible one a bit
by only copying the modified area.
2016-12-09 09:20:50 +01:00
Pierre Ossman 2ba767a7fe Use double buffering for the display
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.
2016-12-09 09:20:50 +01:00
Pierre Ossman 74e390512d Remove blitStringImage() in favour of imageRect()
The latter is more generic and can easily be modified for other
mechanisms in the future.
2016-12-09 09:20:50 +01:00
Kyle Russell 1a50f6809f rfb: Allow port to be optionally appended to URI
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.
2016-11-24 06:14:31 -06:00
Samuel Mannehed f5bf2d84ef Merge pull request #718 from ossman/po
Use gettext .po files, and translate everything
2016-11-22 21:02:13 +01:00
Pierre Ossman edffd9e2f8 Also translate HTML elements 2016-11-19 13:23:00 +01:00
Samuel Mannehed 9964ab0e8e Add a space in logging of RFB._fail() 2016-11-18 10:30:40 +01:00
Pierre Ossman 3cdc603aa4 Use gettext .po files for translations
This allows the same workflow as most other projects for translations.
2016-11-17 20:42:08 +01:00
Pierre Ossman 45729def6d Restore translations for some strings
We lost the translation calls for a couple of strings in one of
the clenaups.
2016-11-17 19:58:10 +01:00
Pierre Ossman f28e248d3f Use _() as shorthand for translations
Used commonly when gettext is used for translations. Avoids cluttering
the code.
2016-11-17 19:58:10 +01:00
Samuel Mannehed 67cd2072ab Allow specifying details when calling RFB._fail()
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.
2016-11-10 15:17:37 +01:00
Samuel Mannehed 9f909d9b46 Don't wait for websocket closes on failure
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
2016-11-10 15:17:37 +01:00
Samuel Mannehed b2e961d48d Ensure proper connection state transitions
Makes the state machine more rubust and clear.
2016-11-10 15:17:31 +01:00
Samuel Mannehed b45905ab86 Handle server-side disconnections
Don't handle socket-close events when connected as errors. You could
for example, in the VNC session run 'vncconfig -disconnect'.
2016-11-10 14:33:29 +01:00
Samuel Mannehed e48d1b254e Separate state actions from connection actions 2016-11-10 14:33:29 +01:00
Samuel Mannehed c4b274ebb8 Move disconnect actions to a separate funciton
Done in order to be consistent with connect() and to separate state
actions from connection actions.
2016-11-10 14:33:29 +01:00
Samuel Mannehed 376864d6d1 Handle errors while opening a Websocket
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".
2016-11-10 14:33:29 +01:00
Samuel Mannehed b2cf3b68b3 requestDesktopSize() should always return a value 2016-11-10 14:33:23 +01:00
Samuel Mannehed b85a13de69 Merge pull request #689 from ossman/keysym
Don't send Unicode as keysym
2016-11-10 09:36:43 +01:00
Giannis Kosmas b98b2f813d Added Greek translation 2016-10-28 21:22:25 +03:00
Samuel Mannehed 9e26112d1a Ensure translations variable is set before use 2016-10-28 18:40:56 +02:00
Samuel Mannehed a4fc1fa586 Add Swedish translation 2016-10-28 15:41:08 +02:00
Samuel Mannehed fdb02f8570 Always translate literals instead of variables
Makes it much easier to find what needs to be translated.
2016-10-28 15:41:08 +02:00
Samuel Mannehed da88c28714 Remove unnecessary whitespace 2016-10-28 15:41:08 +02:00
Samuel Mannehed a93cda3a36 Move app-specific location of language files
The core directory should only contain core API code that isn't
specific to an application.
2016-10-28 14:30:14 +02:00
Loek Janssen 5af39a878a Added localization to statusbar 2016-10-28 12:40:28 +02:00
Pierre Ossman d9ca5e5b6b Don't allow more than one pending update 2016-10-24 14:42:45 +02:00
Pierre Ossman bb6965f2e6 Wait for proper image load event
There is a specific event for when an image has finished loading,
so trigger on that rather than polling. The polling interval of
requestAnimationFrame() can also be very large.
2016-10-24 14:42:13 +02:00
Pierre Ossman 1578fa68ac Hide image handling in display object
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.
2016-10-24 14:42:13 +02:00
Pierre Ossman 9535539bb2 Process entire WebSocket message at once
setTimeout() causes too much delay to be useful. Also, we
already handle all rects in a message at once, so this shouldn't
be too much of a change.
2016-10-24 14:42:08 +02:00
Pierre Ossman ebb9086ae8 Support standard mouse wheel event
Mouse wheel event handling has now been standardised and has broad
support. Use this event rather than the older, non-standard ones.
At the same time fix up support for horisontal mouse wheel events.
2016-10-21 16:04:23 +02:00
Asad Saeed 7c1b2bac90 Add Meta Key mapping to xtscancodes.js
OSLeft/OSRight have been renamed to MetaLeft/MetaRight respectively.
This change will allow the Super/Windows key to be used under the qemu
rfb extension under Chrome and updated browsers.

https://github.com/w3c/uievents-code/issues/7
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
2016-10-20 01:13:32 +02:00
Samuel Mannehed ac33960368 Merge pull request #649 from kanaka/dontgrabinviewonly
Fix view only
2016-10-20 01:04:14 +02:00
zarmhast 4b20f2364c Fix for touchscreen devices that also have a mouse. 2016-10-20 00:44:25 +02:00
Pierre Ossman 115eedf69c Use Unicode keysym range as fallback
Not all Unicode codepoints have an equivalent named Keysym. But
there is a range in the Keysym namespace that can be used to map
any codepoint to.
2016-10-15 14:58:55 +02:00
Pierre Ossman 4dc8953658 Use correct terminology in RFB.sendKey()
The keyboard handling is complex enough without using the incorrect
terms for things.
2016-10-14 08:37:48 +02:00
samhed bea2b3fdfc New way of detecting touch
Moves detection to Util and fixes so that touch is properly detected on
MS Surface and touch emulation in Chrome.
2016-10-14 02:41:06 +02:00
Samuel Mannehed 7ae53db9cd Don't request a new desktop size in view_only 2016-10-14 01:46:55 +02:00
Samuel Mannehed 81bd2d6682 Don't grab keyboard or mouse in view-only mode
Fixes #644.
2016-10-14 01:46:14 +02:00
Samuel Mannehed 9310577bd8 Remove out-of-place comma 2016-10-01 01:34:31 +02:00
Samuel Mannehed 6c14514774 Split cleanup from closing the socket 2016-10-01 01:34:30 +02:00
Samuel Mannehed 3bb12056b1 Remove unnecessary substates of disconnected
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.
2016-10-01 01:34:25 +02:00
Samuel Mannehed c2a4d3ef86 Improve the connection state names
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'
2016-10-01 01:30:02 +02:00
Samuel Mannehed 52e9cc48b0 Clean up log output on state changes 2016-10-01 01:30:02 +02:00
Samuel Mannehed c00ee156b9 Separate out init state from page state
This makes the state machine simpler as we don't have to confuse
protocol states with visual states.
2016-10-01 01:30:02 +02:00
Samuel Mannehed 159c50c009 Clean up special state handling for 'failed' 2016-10-01 01:30:02 +02:00
Samuel Mannehed d5bbe50eb5 Properly filter list of auth schemes
We do _not_ support scheme 1 through 16, only 1, 2, and 16 (and 22).
2016-10-01 01:30:01 +02:00
Samuel Mannehed a7127fee73 Don't abuse state change function for messages
This doesn't even work anymore since we fixed it to ignore changes
to the current state. Add a separate callback for notifications
instead.
2016-10-01 01:29:44 +02:00
Samuel Mannehed 4cfd49c8c3 Don't change state to same state
The comment already stated as much, but the code was broken.
2016-10-01 00:02:56 +02:00
Samuel Mannehed 7d714b15f5 Remove special password state
We already have a callback mechanism for this, so let's use that.
Adds an optional parameter 'msg' to the callback.
Fixes vnc_auto.html (#646) which was broken after
4e0c36dda7
2016-10-01 00:02:47 +02:00
Samuel Mannehed 04b399e27d Allow moving the controlbar handle
This also adds emulation of Element.setCapture() as only Firefox
and Internet Explorer/Edge currently supports it.
2016-09-23 14:39:21 +02:00
Dmitry Sankevich 33e1462999 Fix TIGHT negotiation with zero sub-auth types
According to the RFB protocol, when in TIGHT auth negotation,
if the client receives a sub-auth count of zero, it should proceed
as if the `None` sub-auth type had already been selected (and not
send a message selecting that type).

Closes #564
2016-09-16 23:22:35 -04:00
Lars Ole Hurlen 49aa5b81c7 Detect RealVNC's RFB 5.0 Protocol Version
The RFB protocol specifies a max version of 3.8, but RealVNC likes to
increment their version when they add new features.  RealVNC 5.3 sends
"005.000" as the version string, since they've extended their
implementation upon RFB v3.8.  We can detect that, and just tell them we
only speak 3.8, instead of barfing on "005.000" as an invalid version.
2016-09-16 17:33:46 -04:00
Solly Ross bd5340c7ee Move input-related files into core/input
This commit moves all the input-related files from `core/`
to `core/input/`, and renames a couple as relevant
(input.js --> input/devices.js, keyboard.js --> input/util.js).
2016-09-16 15:49:52 -04:00
Solly Ross b4ef49ea36 Remove unecessary event-related code from Util
The event-related wrapper functions in Util existed mainly for
backwards-compat.  However, all currently supported browsers
support the standard functions, so these wrappers are no longer needed.
2016-09-16 15:49:52 -04:00
Solly Ross e4fef7be2d Util shouldn't modify window object
This commits prevents Util from modifying the window object.

- `window.requestAnimFrame` was removed (no polyfill is needed anymore)
- the potential redefinition of `console.log` and friends was removed
  (all supported browsers have `console.xyz` defined anyway)
2016-09-16 15:49:52 -04:00
Solly Ross 9eca6889be Switch to PhantomJS 2.x for testing
This commit switches over to use PhantomJS 2.x, bringing in a whole host
of improvements (including `Function#bind`, so we can remove the
`Function#bind` shim in core/util.js).
2016-09-16 15:49:52 -04:00
Solly Ross 3949a09534 Don't modify Array prototype
This commit removes our modification of the Array prototype.
It wasn't actually used much in the main code, anyway, and it's a
bad practice to modify built-in prototypes.
2016-09-16 15:49:52 -04:00
Solly Ross 72bdd06ea2 Clean up Util
This commit removes unused code from Util, and moves the script-loading
functionality to WebUtil.
2016-09-16 15:49:52 -04:00
Solly Ross ae510306b5 Enable noVNC to become Browserifiable
This commit restructures noVNC, splitting it into the core directory
and the app directory, with the former containing core noVNC parts,
and the latter containing parts specific to the application.
2016-09-16 15:49:51 -04:00