Commit Graph

325 Commits

Author SHA1 Message Date
Alex Tanskanen a6304f91d0 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>
2019-11-07 16:44:26 +01:00
Alex Tanskanen 175b843b66 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.
2019-11-04 14:22:46 +01:00
Pierre Ossman ccb511a527 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.
2019-11-04 10:17:45 +01:00
Pierre Ossman 3388c92c7f 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.
2019-11-01 13:13:35 +01:00
Pierre Ossman 1096555414 Fix typo for MailSend key 2019-11-01 10:49:19 +01:00
Pierre Ossman ebee9cddbf Update to latest UI Events key specification 2019-11-01 10:25:23 +01:00
Pierre Ossman 5736ea0bd5 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.
2019-11-01 09:59:02 +01:00
Pierre Ossman 8c51e9a8a2 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 9e99ce126c.
2019-10-31 15:36:40 +01:00
Pierre Ossman 9d956e9198 Handle broken numpad delete key in Chrome 2019-10-31 14:51:36 +01:00
Pierre Ossman dd4341fe67 Explain why Clear maps to KP_Begin 2019-10-31 14:12:58 +01:00
Pierre Ossman 758399050d 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.
2019-10-31 14:12:58 +01:00
Samuel Mannehed 0c4b3e802f Rename document.capturedElem to captureElement
To better fit most naming.
2019-10-23 15:59:43 +02:00
Samuel Mannehed c3a7524c9e 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>
2019-10-21 13:51:42 +02:00
Samuel Mannehed 7a96fc3785 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>
2019-10-21 13:51:42 +02:00
Samuel Mannehed 938690375b 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>
2019-10-21 13:10:13 +02:00
Samuel Mannehed fcd99d04fb 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>
2019-10-21 13:10:09 +02:00
Samuel Mannehed 412d93060d Update copyright to 2019 for modified files 2019-09-30 15:35:33 +02:00
Samuel Mannehed e8614e20ef Code comments for how the receieve queue works 2019-09-25 21:04:46 +02:00
Samuel Mannehed c90d53565a Clarify why we ENABLE_COPYWITHIN is false 2019-09-25 21:03:37 +02:00
Samuel Mannehed 3aeaea50af
Merge pull request #1298 from CendioNiko/edgeCursorURI
Fix url cursor detection on Edge
2019-09-25 14:46:58 +02:00
Samuel Mannehed 3055307d3d
Merge pull request #1299 from CendioNiko/vmwarecursor
Add support for VMware cursor encoding
2019-09-25 14:45:29 +02:00
Samuel Mannehed 8dc47f3c06
Merge pull request #1289 from CendioNiko/master
Desktop name improvements
2019-09-25 14:43:55 +02:00
Samuel Mannehed c51a77c2eb
Merge pull request #1281 from jalfd/optimize-receive-buffer
Optimize receive buffer
2019-09-25 13:26:02 +02:00
Samuel Mannehed d39e0d1244 Clarify comments for broken alt in FF on Windows 2019-09-24 16:00:05 +02:00
Samuel Mannehed ebb58c34da
Merge pull request #1280 from jalfd/alt-key-recursion
Avoid recursion in Alt check on Firefox
2019-09-24 15:56:13 +02:00
Niko Lehto 296ba51f49 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>
2019-09-24 10:26:30 +02:00
Niko Lehto a1afb2a215 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.
2019-09-23 13:50:17 +02:00
Niko Lehto ce66b46986 Add support for DesktopName extension
This extension allows session name to be changed during runtime.
2019-09-04 14:23:37 +02:00
Pierre Ossman e5255fc246 Remove pointless Display.clear()
It served no meaningful purpose and it had bugs. So let's remove it
rather than try to fix it.
2019-08-23 15:05:58 +02:00
Pierre Ossman 3855a7bee4 Remove unused Display.logo attribute 2019-08-23 15:04:23 +02:00
Pierre Ossman 6aed0b4dd2 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.
2019-08-23 14:00:20 +02:00
Pierre Ossman 1f2bb52850 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.
2019-08-23 13:57:30 +02:00
Jesper Alf Dam 08567b08ac 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.
2019-08-16 19:34:09 +02:00
Jesper Alf Dam 7d755d10dc 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.
2019-08-16 19:34:09 +02:00
Jesper Alf Dam e9f489a629 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.
2019-08-16 16:20:41 +02:00
Samuel Mannehed c912230309 Remove the default value of wsProtocols
Using the 'binary' protocol by default is very non-standard.
2019-07-23 16:03:49 +02:00
Shira Maximov 25b3d49d32 Add support in websocket sub-protocols 2019-07-23 13:44:18 +03:00
Pierre Ossman 755d6eae99 Remove server pixel format warnings
These are harmless and really only for debugging. So remove them
as they tend to trick people in to thinking something is wrong.
We already print the entire server pixel format earlier anyway in
case we need the details.
2019-05-24 13:06:26 +02:00
Samuel Mannehed a136b4b078 Allow autoscale() with zero height or width
Commit 6e7e6f9 stopped the function from running if width or height was
zero, this commit reverts that change. This commit also makes the
resulting canvas 0x0 if autoscale is called with zero. By adding this
special case we can avoid division by zero in the calculations.
2019-04-02 16:51:18 +02:00
Samuel Mannehed 6e7e6f9c9e Add check for bad values for Display.autoscale() 2019-03-08 16:30:43 +01:00
Juanjo Diaz 41ddb35458 Replace unnecessary function supportsCursorURIs by a constant variable 2019-02-27 10:14:50 +02:00
Juanjo Diaz 44f4c5545f Move support check from display to browser 2019-02-27 10:13:50 +02:00
Juanjo Diaz 0505214cd9 Convert DES into a class 2019-02-26 23:53:43 +02:00
Juanjo Diaz 9d2c9d1a75 Use default argument for base64 2019-02-26 23:52:47 +02:00
Juanjo Diaz 667f3cc20e Remove unnecessary context from eventtarget 2019-02-26 23:51:45 +02:00
Juanjo Diaz fe5974a740 Remove unnecessary constructor parameter from Cursor 2019-02-26 23:51:33 +02:00
Juanjo Diaz 9255e0fb47 Remove intermediate variable from mouse 2019-02-16 23:31:58 +02:00
Pierre Ossman b00a608af7 Remove error handling in clientCutText()
It is not necessary as Websock.flush() is guaranteed to succeed and
give us some space. It also remove the call to _fail(), which was
invalid at this place as clientCutText() is not a method on RFB.
2019-02-15 13:14:36 +01:00
Pierre Ossman 47c66517ae Throw correct Error object
We've already defined the name Error as a logging function, so we
need to be more explicit when we want to refer to the exception
class.
2019-02-15 13:01:28 +01:00
Pierre Ossman c02b18f06f Clean up RFB._rfb_auth_schema assignment 2019-02-15 10:25:50 +01:00