Commit Graph

73 Commits (dbe29307588e0c23e19c3f02d9390e406aa422cc)

Author SHA1 Message Date
Niko Lehto dbe2930758 Handle errors from zlib/pako 4 years ago
Niko Lehto b690ae4c2d Move error handling to Inflate class
Every call wants this check so this should be done inside the class.
4 years ago
Niko Lehto 5e4544d5fc Add missing copyright header for Inflator.js 4 years ago
Niko Lehto 0b19961b06 Remove unused inflate argument
The value true was an invalid flush argument so it was in practice
unused.
4 years ago
Niko Lehto 286694869b Add util for unsigned and signed int. conversion
Will be used in later commit in extended clipboard handling.
4 years ago
Niko Lehto fdeefcfab4 Add deflator helper class for deflating data
Wraps pako's deflate for easier usage.
4 years ago
Samuel Mannehed c1160d1468 Fix color channels for VMware alpha cursors
The red and blue channels were incorrectly swapped.
4 years ago
Juanjo Diaz 1c38b6f120 Remove generated HTML by Cursor when it detaches 4 years ago
Samuel Mannehed 2f43cead79 Add comment for browser and platform detection 4 years ago
Samuel Mannehed e7a5aa271e Add short description at the top of browser.js 4 years ago
Samuel Mannehed ad206180d2 Properly detect scrollbar gutter
As a rule, instead of hard-coding a behavior on specific platforms we
should do dynamic detection.

This commit moves away from always hiding scrollbars on Android and iOS
and instead detects the rendered width of scrollbars in the browser.
4 years ago
Pierre Ossman 89dd199317 Allow cursor to be updated while connecting
We haven't got a server provided cursor at this point, but we might
have done something local, e.g. enabled the dot cursor.
4 years ago
Pierre Ossman 8be70e5ae0 Handle slow loading of images
Internet Explorer seems to flag images as loaded prematurely, which
can result in rendering bugs. We can detect this by looking at the
dimensions though.
4 years ago
Samuel Mannehed ce94d92e18 Build in the behavior to ignore decodeUTF8 errors
Makes the code clearer and more explicit in intent.
4 years ago
Chris \"Koying\" Browet c0276776e9 Add support for Unix Tight auth 4 years ago
VanyM 10f4aa9e7b Add try catch in every place that uses decodeUTF8 4 years ago
Samuel Mannehed b2dc76ee18 Add encodeUTF8 function to core/util/strings.js 4 years ago
Pierre Ossman 12cdad066e Make Cursor.detach() safe to call when not attached
Avoids having checks in higher layers.
4 years ago
Alex Tanskanen 15c74e7dc9 Fix missing caps lock events on iOS
Caps Lock on iOS only trigged key release or key press events.
When it's clicked it would only send keydown, and next time
it would only send keyup and so on. It should send both a key press
and a key release.

Also added the unit tests for macOS since those were missing.

Co-Authored-By: Alex Tanskanen <aleta@cendio.se>
4 years ago
Alex Tanskanen b5f1a00282 Add "macOS shuffle" to iOS as well
Since iOS functions like macOS with regards to Alt behaving like AltGr,
we need the same workaround on iOS as well.
4 years ago
Pierre Ossman 740a8217ab Handle missing Shift events on Windows
This is a bug in the OS that leaks through to the browsers. We need
to fake a Shift release here to avoid Shift getting stuck in the remote
session.
4 years ago
Pierre Ossman 796de9653f Send NumLock on macOS, even though the key is Clear
There is no obvious choice what works best here, but this is what
TigerVNC has been doing for years without complaints. Let's follow
them until we get reports that this doesn't work well.
4 years ago
Pierre Ossman 6916c83b48 Fix typo for MailSend key 4 years ago
Pierre Ossman d10d7167f6 Update to latest UI Events key specification 4 years ago
Pierre Ossman a8dc933701 Fix AltGr for a few more keys in IE and Edge
Some keys apparently send 'Unidentified' rather than an unshifted value.
Make sure those are also handled. Examples are \ and | on a Swedish
keyboard.
4 years ago
Pierre Ossman 62fca18cb9 Revert iOS keyup workaround
It seems Apple has fixed their buggy keyup events, so remove the
workaround and allow keys to be kept pressed again.

This is a revert of 9e99ce126ca8f6f350fa015c0e58d35103c62f7e.
4 years ago
Pierre Ossman dc3ddc8efc Handle broken numpad delete key in Chrome 4 years ago
Pierre Ossman e497b53d09 Explain why Clear maps to KP_Begin 4 years ago
Pierre Ossman 7dc51fa7a5 Try to handle Meta key properly
The standards have unfortunatly caused some confusion between the Windows
key and the original Meta key. Try to handle the common case sanely at least.
4 years ago
Samuel Mannehed 6067290169 Rename document.capturedElem to captureElement
To better fit most naming.
4 years ago
Samuel Mannehed 996895268e Hide the emulated cursor when target is null
Makes it easier to understand what happens when a real element isn't
passed as a target to updateVisibility(). Also makes the code more
robust to future changes.

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
4 years ago
Samuel Mannehed fb14c2dec9 Fix disappearing cursor after click
In the cursor emulation when deciding if the cursor should be hidden -
Instead of checking what's under the cursor, we check the element that
has capture.

This introduced another bug in the cursor emulation. The cursor did not
always disappear properly when using our cursor emulation together with
our setCapture polyfill. More specifically, we saw a problem when a
capture ended on an element without cursor emulation.

We solved this by introducing another visibility check on a timer in
the cursor emulation. However this led to yet another problem where
this timer conflicted with the timer in the setCapture polyfill.

We removed the timeout in the setCapture polyfill and created a
variable to make sure that all the events remaining in the queue can be
completed.

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
4 years ago
Samuel Mannehed 83d5e5bffd Check next elem at mouseleave in cursor emulation
It's not obvious that we want to hide the cursor when we get a leave,
it depends on the element that we're leaving to. This makes the code
more robust.

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
4 years ago
Samuel Mannehed 19dfb7901c Rename variables in setCapture proxy
The names of many variables were too similar. To make the code easier
to follow we renamed:

* _captureElem to _capturedElem
* _captureElemChanged() to _capturedElemChanged()
* captureElem to proxyElem
* elem to target

Co-authored-by: Alex Tanskanen <aleta@cendio.se>
Co-authored-by: Niko Lehto <nikle@cendio.se>
4 years ago
Samuel Mannehed 0dcb896920 Update copyright to 2019 for modified files 4 years ago
Samuel Mannehed d88aefba4e Code comments for how the receieve queue works 4 years ago
Samuel Mannehed b0c54f6b24 Clarify why we ENABLE_COPYWITHIN is false 4 years ago
Samuel Mannehed 6342a117ff Clarify comments for broken alt in FF on Windows 4 years ago
Niko Lehto 766fc43855 Add support for VMware cursor encoding
Supports both classic cursor type and alpha cursor type. In classic
mode the server can send 'inverted' pixels for the cursor, our code
does not support this but handles these pixels as opaque black.

Co-authored-by: Samuel Mannehed <samuel@cendio.se>
4 years ago
Niko Lehto 19f0803636 Fix url cursor detection on Edge
_supportCursorURIs was set to true even when Edge didn't support
URIs because the fallback value "default" was used.
4 years ago
Niko Lehto 8c43287afb Add support for DesktopName extension
This extension allows session name to be changed during runtime.
4 years ago
Pierre Ossman c211f31113 Remove pointless Display.clear()
It served no meaningful purpose and it had bugs. So let's remove it
rather than try to fix it.
4 years ago
Pierre Ossman 4cc536636a Remove unused Display.logo attribute 4 years ago
Pierre Ossman 734bdd3746 Deprecate showDotCursor option for RFB constructor
It is not relevant for the connection stage so it should not have
been a constructor argument to begin with. Ship with a warning for
a release before we remove it.
4 years ago
Pierre Ossman 8218a0cb2a Make sure showDotCursor can be modified before connecting
The cursor object is only attached to our canvas whilst connecting,
so we need to make sure we don't try to update anything when were
not connected or we'll get a crash.
4 years ago
Jesper Alf Dam b0896c8859 When compacting the receive buffer don't copy unused buffer space
When compacting the receive buffer, we should only copy the bytes
between _rQi and _rQlen (the index of the first unread byte, and the
next write position).

Previously, we copied everything for _rQi up untill the end of the
buffer.
4 years ago
Jesper Alf Dam 09de4b8349 Don't compact the receive buffer unless we've actually run out of space
Previously, we would compact the buffer (moving unread data to the
start of the buffer) as follows:

- after processing a message, if there are zero unread bytes, just reset
  the indices for first and last unread byte to zero
- else, if at least 1/8th of the buffer is used, copy remaining data to the beginning of the buffer

The second option is never actually necessary, as before inserting new data
into the array, we already check if there's enough free space, and
compact the buffer first if necessary. So we've been doing a lot of
copies that weren't actually needed. Let's not do that any more.
4 years ago
Jesper Alf Dam d4747a8c80 Avoid recursion in Alt check on Firefox
The Firefox workaround which checks for missing Alt key events may
synthesise new KeyboardEvents. On these events, checkAlt should not be
recursively triggered. Otherwise, we get "too much recursion" errors
whenever the Alt key is pressed.
4 years ago
Samuel Mannehed 8b859f4598 Remove the default value of wsProtocols
Using the 'binary' protocol by default is very non-standard.
4 years ago
Shira Maximov 8c5b5f17eb Add support in websocket sub-protocols 4 years ago