Commit Graph

484 Commits

Author SHA1 Message Date
Solly Ross 8b46c0deb0 Update UI to allow for different scaling modes
This commit updates the UI to allow for different
scaling modes.  The "resize" option was changed to
be a dropdown with the following options: "None" (nothing),
"Remote Resizing" (SetDesktopSize).
2015-02-27 17:13:51 -05:00
Solly Ross 7e54fb93dd Make Util.getPosition be relative to page
Commit 5108c4635c caused a regression
in the case where scrolling is used -- getPosition return position
relative to the viewport, while getEventPosition expected a position
relative to the page.

As per
https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect,
the fix for this is simply to add the `pageXOffset` and `pageYOffset` to
the output of `getBoundingClientRect()`.

Fixes #459.
2015-02-27 13:37:13 -05:00
Solly Ross e543525faa Fix disconnect/reconnect issues
Commit 155d78b399 prevented reconnections
from working properly.  This fixes that by creating a new RFB object
after disconnecting or failing.

Furthermore, this ensures that a new connection cannot be opened util
we've actually disconnected (either by timer or by receiving a `close`
event).

Closes #452
2015-02-25 11:01:18 -05:00
Solly 5108c4635c Merge pull request #432 from nbibler/getPositionUpdate
Replace custom getPosition algorithms with getBoundingClientRect.
2015-02-17 15:59:27 -05:00
samhed f8b399d7df Support automatic resize [Part 3/4]: ui.js
* Added a resize request (setDesktopSize) triggered when connecting and by
  changes to the browser window's size.
* Hid the view-drag-hand when the display area is the same or smaller than the
  remote session size.
* Added a setting for the automatic resize feature.
* Updated vnc.html and vnc_auto.html to reflect the changes to the UI.
2015-02-10 17:05:58 +01:00
samhed b0ec6509f1 Support automatic resize [Part 2/4]: rfb.js
* Support sending the setDesktopSize encoding (client -> server)
* Support recieving the ExtendedDesktopSize encoding (server <- client)
2015-02-06 17:06:48 +01:00
samhed 636be753b2 Support automatic resize [Part 1/4]: display.js
* Split viewportChange into two functions, one for changing size and the other for changing position.
* Modified viewport code to be capable of changing to a bigger size in the context of a
  client-initiated resize.
* Made clearer distinctions between when viewport-clipping or not.
* Added public function for telling when viewport-clipping.
* Updated tests that were using viewportChange.
2015-02-06 16:54:14 +01:00
samhed 5b7598ac6b Use our own event registration function for keyboardinputReset. 2015-02-06 15:53:10 +01:00
Solly a437079307 Merge pull request #427 from jswanner/register-listeners
Unregister event listeners from websock.
2015-02-04 11:09:37 -05:00
samhed e9f55ea0f8 Fixes issue #435 - added missing comma in keysym.js 2015-02-03 13:04:16 +01:00
Nathaniel Bibler 455f8f3fd0 Replace custom getPosition algorithms with getBoundingClientRect. 2015-01-26 11:46:44 -05:00
samhed b804b3e458 Fixes #428 - hides the local cursor when using the server-side cursor. 2015-01-15 16:27:18 +01:00
Jacob Swanner 155d78b399 Unregister event listeners from websock.
Prevents possible memory and event notification leaks when tearing down
connection and reestablishing a new one.
2015-01-08 15:25:55 -05:00
samhed 282834caf1 Fixes #309, make use of keysym.js
Bonus 3 bug fixes:
 * Meta is 0xFFE7 not 0xFE07
 * Super_L is 0xFFEB not 0xFFEC
 * Super_R is 0xFFEC not 0xFFED
2014-11-26 09:24:13 +01:00
samhed ed7f8c3886 Add ISO Level 3 Shift (AltGr) to keysym.js 2014-11-26 09:22:12 +01:00
Joe Huss df89129ff0 Fix for typo from a recent pull
There is a minor typo in the recent pull  Simple fix.
2014-11-23 07:22:39 -05:00
Ramon de Klein 40ac6f0ab6 Don't draw "blank" HEXTILE tiles with random data
Previously, if a HEXTILE tiles was received with a subencoding
of 0x00, it would draw a rectangle using data from the render
queue, which would result in random colored blocks when using
the HEXTILE encoding.  This is the result of a miscopy during
the refactoring.  It now has the correct functionality according
to the RFB protocol specification, which is to draw a rectangle
with the last set background color.

Closes #411
2014-11-17 20:01:28 -05:00
samhed bd6874e087 We should use the globally declared UI variable 2014-11-13 17:22:48 +01:00
samhed 795fca23dc Modify minimum width of clear to accomodate smaller screens 2014-11-11 16:29:06 +01:00
Solly Ross ec31f82eda Fix Cursor Issue When Using True Color
This fixes an issue where, when using true color, the changeCursor
function would not actually write the cursor to the target array.

Fixes #407
2014-10-29 19:18:34 -04:00
Julien Fontanet 58ca1978ea Fix subprotocols
Broken by b1dee94788
2014-10-01 16:30:39 +02:00
Solly Ross f9fd0313b8 Make Utils.js use Object.define to modify Array
Previously, we were modifying Array's prototype using
simple assignment.  This can mess with enumeration/iteration.
Thus, we now use Object.defineProperty with enumerable set to
false.

See #366
2014-09-22 22:30:19 -04:00
Solly Ross 0b0b0433b5 Fix Race Condition in Display#clear on IE10
There was a race condition in Display#clear on IE10
because we resize and then clear that causes the canvas
to not actually end up cleared.  Clearing the current
viewport first solves the issue.  It doesn't appear to
affect other platforms, so it's inside a engine check
(`Util.Engine.trident === 6`).  Once we stop supporting
IE10, we should just remove this, because it's not the best
to have Engine-specific code.
2014-09-22 21:37:04 -04:00
Solly Ross 53762c31fe Fixed Cursor URI Support Detection
There was a bug in cursor URI support detection due to the way
set_defaults now works -- the code was checking for `null`, whereas
when not set, options default to `undefined` unless otherwise
specified.  The code now checks for either `null` or `undefined`.
Tests have been added to ensure that this works properly.
2014-09-19 14:51:15 -04:00
Solly Ross cfc02e5e2b Fixed presence detection bug in utils.set_defaults
Previously, Utils.set_defaults was using `if(conf[keys[i]])`
to check for the presence of a configuration key.  This would
fail if `conf[keys[i]]` happened to be false.  Instead, we now
use `if(keys[i] in conf)`, which simply checks for the presence
of the key in the conf object.
2014-09-19 14:48:00 -04:00
Solly Ross d02a99f0c8 Fixed Typo Causing MouseUp to not Register
There was a typo in one of the instances of the _buttonMask field
(it was written as _buttonMaks), causing MouseUp to never be sent.
This has been rectified, and the unit tests for the mouse handler
have been changed to check for explicitly sending mouseup and
mousedown.

Fixes #393
2014-09-19 14:18:45 -04:00
Martin André 7caa9c20c2 Prevent noVNC loading error when invalid property is set on object
Util.set_defaults should accommodate with missing properties to prevent
'Uncaught TypeError: Cannot read property 'call' of undefined' error.
2014-09-17 16:50:05 +09:00
Solly Ross bbbf42bb5a Cleanup: UI code
File: ui.js
Tests Added: False

Changes:
- Fix JSHint errors
- add some curly braces to improve clarity
- move variable declarations to relevant locations instead of at the top
  of methods
2014-09-15 16:46:02 -04:00
Solly Ross b1dee94788 Cleanup: RFB Client
File: rfb.js (also websock.js)
Tests Added: True

Changes:
- De-Crockford-ified rfb.js
- Added methods to websock.js to skip bytes in the receive queue
2014-09-15 16:46:02 -04:00
Solly Ross 1e13775bd5 Cleanup: Display Helper
File: display.js
Tests Added: True (preliminary)

Changes:
- De-crockford-ified the file

NOTE: the tests included for display.js cover basic functionality, but
are by no means nearly as comprehensive as the ones presented for
rfb.js.
2014-09-15 16:46:02 -04:00
Solly Ross 2cccf7530c Cleanup: WebSocket Helper
File: websock.js
Tests Added: True
Changes:
- Cleaned up JSHint errors
- Converted to normal JS constructor pattern with "private" fields and
  methods now simply being prepended by underscores
- Added a "bind" polyfill for use in PhantomJS 1.x in util.js
- Added FakeWebSocket to fill in for actual WebSocket objects when
  testing
- Made exception handler actually log exception name and message,
  to console, in addition to stack trace
2014-09-15 16:46:02 -04:00
Solly Ross ee7d4c61c6 Cleanup: Webutil code
File: webutil.js
Tests Added: False
Changes:
- Fixed JSHint Errors (global "use strict", spaces)
- added some newline characters when appropriate for readability
- moved variable declarations to the places they were actually used
  for readability
2014-09-15 16:46:02 -04:00
Solly Ross 31f169e86f Cleanup: Keyboard code
File: keyboard.js
Tests Added: False (already present)
Changes:
- Fixed JSHint Errors
- Moved functions outside loops
- Added proper include directives to tests
2014-09-15 16:46:02 -04:00
Solly Ross d6e281baf6 Cleanup: Input code
File: input.js
Tests Added: False (already present partially -- see below)
Changes:
- Fixed JSHint Errors
- Converted to normal non-Crockford constructors

NOTE: while there are tests for the actual key-detecting functionality,
      the tests do not cover the actual Keyboard and Mouse objects
      themselves.
2014-09-15 16:46:02 -04:00
Solly Ross d21cd6c164 Cleanup: Util code
File: util.js
Tests Added: True (partial -- for logging and array push methods)
Changes:
- Fixed JSHint Errors (indentation, semicolons, global "use strict")
- Made browser detection methods more readable
- added some newline characters when appropriate for readability
- throw Errors not strings!
- Removed conf_defaults, and added make_properties and set_defaults
  instead (see below)

The removal of conf_defaults and switch to make_properties and
set_defaults is to facilitate the switch over to normal Javascript
constructors instead of Crockford-style constructors.  Now, methods
are added to the objects prototype (and thus make properties is called
outside the constructor).
2014-09-15 16:46:02 -04:00
Solly Ross fb64ed2135 Cleanup: DES code
File: des.js
Tests Added: False
Changes:
- Fixed JSHint Errors
- Improved whitespace around operators
2014-09-15 16:46:02 -04:00
Solly Ross f8e9b9f1bf Cleanup and Test: base64.js
This is the first commit in a series of commits
which improve the readability of some of the code
and add tests.

File: base64.js
Tests Added: True
Changes:
- Improved indentation
- Fixed JSHint errors
- Moved loop variables to be declared in the loop for better readability
  (N.B. Javascript does not have block scoping, so the variables are
  still technically available outside the loop -- it just makes the code
  clearer to place them inside the loop, since they are only used there)
2014-09-15 16:46:02 -04:00
Solly Ross 95eb681bbb Support the "NOTUNNEL" tunnel type for TightVNC
Previously, tight auth was supported without any support for tunnels,
even the no-op tunnel.  No, the no-op tunnel type is supported.
2014-09-15 16:46:02 -04:00
samhed 960752ea53 fixes an error that was made in the merge with the last sync with websockify. 2014-08-19 13:49:55 +02:00
Giannis Kosmas d8c0953567 Better parsing of query string variables 2014-05-05 23:23:48 +03:00
Solly Ross c77938efc9 Fix for scroll offset in Util.getPosition()
Previously, Util.getPosition didn't deal with scrolling
particularly well.  This fixes that by calculating the
scroll offset when dealing with getting mouse positions.

Credit to @erikgull and @emmar for the initial version of
the fix.  Credit to Brian Huismanfor the initial code.

Closes #295
Relevant to #258
2014-05-05 14:51:32 -04:00
samhed 082027dc87 Sync with websockify
Pull 90b519edf0c1857d
2014-04-14 14:45:15 +02:00
samhed 60a415ae1c Credit for this fix goes to Jesper Dam (https://github.com/Medical-Insight/noVNC/tree/fix-ie10-keyboard).
Fix keyboard handling for IE10 (issue #352)
* Keyboard events in IE10 do not provide any useful information on the properties 'which', 'char' or 'charCode'. Instead, it seems to store the char code in the keyCode property.
2014-04-14 13:26:52 +02:00
samhed 0bb6a8c50e Fixes issue 344 - problem with backspace on Android. 2014-04-04 17:45:04 +02:00
samhed df0ee70e36 Make sure that the default value of the hidden input field is a space. 2014-03-28 08:54:49 +01:00
Solly 7cad15425e Merge pull request #347 from dol/fix/better-ws-binarytype-detection
Improved websocket binary support detection
2014-03-26 10:58:11 -04:00
samhed 0fe30338a0 Add a prototype from MDN for indexOf to be used in browsers where it is not supported. 2014-03-26 15:22:45 +01:00
samhed b7996b048b Added a wrapper for the UTF-8 decoding. 2014-03-14 15:18:05 +01:00
samhed 6227a91c01 Decode from UTF-8 to allow unicode characters in the connection name 2014-03-14 13:44:10 +01:00
Jesper Dam 230784066c Better browser OS detection.
Apparently Firefox on Linux changed the value of navigator.appVersion,
causing our OS detection (used to determine how to interpret different
modifier keys) to fail.

Use navigator.platform instead, which should be more stable.

http://stackoverflow.com/a/19883965/33213
2014-03-12 11:19:57 +01:00
Jesper Dam c3f6052435 Better key identifiers
Previously we identified keys in keyboard events by the 'key' property
if it was set, and 'keyCode' otherwise.

This turns out to be problematic as Firefox no longer leaves 'key'
undefined (so we fall back to using 'keyCode'), but instead sets 'key'
to 'MozPrintableKey' for all printable keys.

This meant that when (printable) keys are released, we can't match it
against the corresponding keydown event, and instead just send a keyup
event for the last keydown received.

Now, if both 'key' and 'keyCode' are set, use the concatenation of both.
Otherwise prefer 'keyCode', as that is at least unique for every key.

This should let us release the right keys on keyup events.
2014-03-12 11:19:56 +01:00
Dominic Luechinger 97362c3980 Improved websocket binary support detection
A facke connection to 'wss://localhost:17523' (randomly chosen) to detect
the WebSocket binary support is not the best solution.
First of all, check of prototype has the property 'binaryType'. If not,
perform a dummy connection to 'wss://.' instead of 'wss://localhost:17523'.

This patch was inspired by the discussion and implementation of Modernizr:
https://github.com/Modernizr/Modernizr/issues/370
https://github.com/Modernizr/Modernizr/blob/master/feature-detects/websockets/binary.js
2014-03-11 14:29:58 +01:00
Julien Fontanet c7fc3c082f WebSocket protocols are now configurable. 2014-02-19 19:29:06 +01:00
Solly e791b87572 Merge pull request #242 from Medical-Insight/use-wss-for-binary-detect
Use wss when creating localhost connection to detect binary support (closes #242)
2014-02-17 18:09:16 -05:00
Malcolm Scott fb35d50f6a Implement XVP UI in HTML 2014-02-17 17:55:28 -05:00
Malcolm Scott a856a051da Implement XVP extension (shutdown/reboot/reset) 2014-02-17 17:55:28 -05:00
Malcolm Scott 03ab251587 Implement XVP auth 2014-02-17 17:55:28 -05:00
Solly df6b7d7341 Merge pull request #327 from devicenull/master
Add support for connecting to TightVNC servers
2014-02-10 17:21:29 -05:00
samhed 20074a49eb Removes the connection timeouts to enable slower clients, connections or servers. 2014-02-06 16:08:00 +01:00
Brian Rak d86cc2d911 Add support for TightVNC auth type 2014-01-30 19:20:41 -05:00
Jesper Dam f6a1d98a3a Fix issue #326: correct handling of shift key
When shortcut modifiers (modifier keys such as CTRL, which do not participate in
composing character input) are pressed, we try to suppress the keypress
event, as browsers do not reliably generate it. This means that
subsequent key events are decoded only based on the keydown event.

Due to a type error (comparing a string to a number), shift was
mistakenly treated as a shortcut modifier, preventing text input which
relied on shift, such as _ and %, from being generated.
2014-01-06 13:59:25 +01:00
jalf 466a09f0f3 Keyboard Handling [8/8]: Introduce substituteCodepoint() to replace code points which don't have a keysym with ones that do
For now, the only code points this is done for are {s, S, t, T} with comma below (used in Romanian),
 which are replaced by {s, S, t, T} Cedilla.
2013-12-05 12:31:50 -05:00
jalf bf47095944 Keyboard Handling [7/8]: Replace keysym table with optimized version
Regenerate the keysymdef table without -d.

This eliminates keysym names, which are only used for debugging, and shaves ~40kb off the file size
2013-12-05 12:31:50 -05:00
jalf 2ea40fdf9a Keyboard Handling [6/8]: Update everything to include the new keyboard handling scripts 2013-12-05 12:31:48 -05:00
jalf fa30469cda Keyboard Handling [5/8]: Update rfb.js to connect mouse events to keyboard handler
This allows the keyboard handler to check modifier key state much more frequently

Since some browsers never send keyup events for modifier keys, we have to
synchronize modifier state whenever we get a mouse or keyboard event
2013-12-05 12:25:31 -05:00
jalf 9ceef041c6 Keyboard Handling [4/8]: Update input.html to work with new keyboard handling
Plug new keyboard handling into input.js (which breaks everything else), and update input.html to work with this
2013-12-05 12:25:30 -05:00
jalf 4ef7566b10 Keyboard Handling [2/8]: Core implementation of new keyboard handling
Add keyboard.js, containing the actual keyboard event parsing code.
2013-12-05 12:25:15 -05:00
jalf ae52883b93 Keyboard Handling [1/8]: Parse keysymdef.h to produce Unicode -> keysym mappings table
Add a node.js-based tool (utils/parse.js) to read keysymdef.h and produce a JavaScript file
mapping Unicode code points to keysyms.

Also add the generated table (include/keysymdef.js).
2013-12-05 12:24:20 -05:00
Joel Martin 75d69b9f62 Fix to relfect new github.io page base URL. 2013-10-29 14:38:24 -05:00
Joel Martin f0d30a90f3 Merge pull request #317 from dosaboy/bugs/add_secure_property_to_token_cookie
Adds 'secure' property to 'token' cookie
2013-10-29 07:19:23 -07:00
Takashi Natsume ad941fadde Adds support for secure attribute on token cookie
This patch adds support for the secure attribute on token
cookies (sent by nova-novncproxy). If the https is used
to transfer the cookie, the secure attribute is set thus
restricting server requestes to secure conections only.
This should prevent man-in-the-middle attacks.
2013-10-29 10:41:51 +00:00
Joel Martin be09828537 Merge branch 'master' of github.com:kanaka/noVNC 2013-10-11 14:27:12 -05:00
samhed f4f72e9db9 Merge branch 'master' of https://github.com/kanaka/noVNC into ctrlalttabesc
Conflicts:
	include/ui.js
	vnc.html
2013-10-11 17:20:49 +02:00
Samuel 69127447ac Merge pull request #282 from samhed/framebufferupdate
Allow higher frame rates by using a new approach for framebufferUpdate requests
2013-10-10 02:45:08 -07:00
Samuel 270ae2f9f5 Merge pull request #304 from samhed/localcursor
Enables local cursor by default
2013-10-09 01:44:41 -07:00
Joel Martin 7c76fd32a1 Merge pull request #308 from samhed/autoconnect
Autoconnect option as URL query
2013-10-04 13:29:24 -07:00
samhed f8ddfc732d Autoconnect option as URL query 2013-10-04 17:59:03 +02:00
samhed 9b9e741b8c On touch devices the default should be to use a remote cursor. 2013-09-24 11:19:17 +02:00
samhed 97aefe5f83 Enables local cursor by default. 2013-09-23 11:48:16 +02:00
samhed 968431dd46 Catch input events to make the onscreen keyboard work in chrome on android. 2013-09-17 15:01:52 +02:00
samhed b4a979a07e Added a new file for the key symbols, using the well recognized names for the constants from X11:
* The list is found in /usr/include/X11/keysymdef.h
* I did only include the most common symbols for now..
2013-08-30 15:41:46 +02:00
samhed 04d6a8347f Added variables for the keysums to make the code easier to read. 2013-08-29 17:35:22 +02:00
samhed 76e262134e * Removed fbu-requests from the places I missed earlier.
* Added a few clarifying comments.
2013-08-29 13:38:12 +02:00
Anton Lundin c39df031d8 clearTimeout instead of clearInterval for timers
We create timeouts, not intervals. Then we need to clear them with
clearTimeout.
2013-08-02 09:58:15 +02:00
Joel Martin 292f6a5da7 Merge pull request #269 from phildriscoll/master
Fix to onMouseDisable
2013-07-31 08:35:02 -07:00
samhed bd88b94393 Switched from using a list to absolute positions to achieve more
consistant behavior across different browsers.
2013-07-25 15:34:16 +02:00
samhed 9d04096e58 Tweaked the media sizing rules to match the new buttons to the left. 2013-07-25 14:05:52 +02:00
samhed 53c01a2353 Added the extra keys Ctrl, Alt, Tab and Esc to the control bar. 2013-07-25 12:49:37 +02:00
samhed 7e24f50b66 Merge branch 'master' of https://github.com/kanaka/noVNC into framebufferupdate 2013-07-24 10:55:21 +02:00
Joel Martin f3ff971db9 Merge pull request #272 from samhed/doubleclick
Allow for double taps to trigger double clicks even if the second touch is a slight bit off
2013-07-23 08:45:47 -07:00
samhed fb4394b10b Fixed so that viewportDrag works even if no mouse button is selected. 2013-07-23 14:26:11 +02:00
samhed dfcedffc16 Make noVNC follow the RFB protocol and keep only one outstanding
framebufferUpdate request at a time.
2013-07-22 15:46:59 +02:00
samhed df4d6dde30 Merge branch 'master' of https://github.com/kanaka/noVNC into doubleclick 2013-07-19 09:47:47 +02:00
Joel Martin 0e3d505e54 Merge pull request #276 from samhed/screenrealestate
Improved use of screen real estate
2013-07-18 09:58:02 -07:00
samhed 406a8b4e96 Display the desktop name in the document title 2013-07-18 15:51:23 +02:00
samhed 0019d3b055 Added Copyright information to all modified files. 2013-07-17 16:44:13 +02:00
samhed 35b29c98ea * On low resolution devices the status text is now justified to the left
button group instead of centered.
* On low resolution devices the padding towards the edges of the screen of
  the left and right button groups are now removed.
* Since the status_bar was merged into the control-bar the actual status_bar
  element became redundant and was therefor removed.
* Improved the style of the control-bar when there is an error or a warning.
* Implemented a fix so that vnc_auto.html works as intended with the improved
  screen real estate patch.
2013-07-17 16:11:19 +02:00
samhed 6ca8a2c05c Moved the popup_status_panel to the front. 2013-07-12 14:41:57 +02:00
samhed 7ab02c7fc7 Changed the color and weight of the status text to white and bold. 2013-07-12 11:47:41 +02:00
samhed c6ad20992d Improved comments 2013-07-11 12:37:01 +02:00