Joel Martin [Wed, 3 Aug 2011 23:18:41 +0000 (18:18 -0500)]
Add a viewport example/test.
Tested with an iPad 2.
This example shows a 400x200 viewport of an 800x400 display.
It tries to be intelligent about how much it redraws. It copies what
it can, and then when the user releases the mouse, it redraws the
"dirty" areas that were newly revealed.
Joel Martin [Sun, 24 Jul 2011 02:24:59 +0000 (21:24 -0500)]
Touch events and mouse button selectors.
First crack at supporting touch screen for devices like Android and
iOS tablets. Part of https://github.com/kanaka/noVNC/issues/48.
This change detects touch screen support and uses the touchstart,
touchmove, touchend events in place of the normal mouse events.
In order to support middle and right mouse clicks, if the device is
a touch device, then three toggle buttons are added to the UI
representing the left, middle and right mouse buttons. These select
which mouse button will be sent when the screen is touched. All the
buttons can be toggled off, in which case then the touch events only
move the mouse cursor rather than sending a mouse down and mouse up
for touchstart and touchend events respectively. This allows fairly
full control with the mouse on touch screens.
Joel Martin [Thu, 14 Jul 2011 20:57:01 +0000 (15:57 -0500)]
Version 0.1, debian packaging, license text.
noVNC version 0.1
Add debian packaging directory loosely based on
http://trac.zentyal.org/browser/trunk/extra/novnc/debian
Show web root directory on startup (pulled from websockify f1c8223).
Lintian fixups:
- Some license text clarifications.
- remove executable permission on utils/launch.sh and
include/web-socket-js/web_socket.js
- Add executable permission to utils/launch.sh
WebSocketServer.socket() is a static method takes a host and port and
an optional connect parameter. If connect is not set then it returns
a socket listening on host and port. If connect is set then
a connection will be made host and port and the socket returned. This
has IPv6 support like the addrinfo method it replaces.
Also, prefer IPv4 resolutions if they are in the list. This can be
overriden to prefer IPv6 resolutions for the same host using the
optional prefer_ipv6 parameter.
Joel Martin [Wed, 6 Jul 2011 21:32:42 +0000 (16:32 -0500)]
Fix ordering of tightPNG fills.
This addresses issue #65:
https://github.com/kanaka/noVNC/issues/65
When tightPNG encoded rects were received, any fill types were
immediately drawn to the canvas while images (PNG, JPEGs) were queued
for loading. This can cause screen corruption when things are changing
rapidly due to the misordering of fills vs images.
Also, remove the onload setting in each image on the queue and instead
decrease the tight image queue scanning interval (to 40ms or 25
scans per second).
The reocrd parameter will turn on recording of all messages sent
to and from the client. The record parameter is a file prefix. The
full file-name will be the prefix with an extension '.HANDLER_ID'
based on the handler ID.
Joel Martin [Wed, 11 May 2011 22:31:53 +0000 (17:31 -0500)]
Refactor configuration attributes.
- Add conf_defaults which accepts an array of configuration
attributes.
- Split out user configuration defaults from the actual configuration
object.
- Add mode field and enforce read-only, write-once, read-write modes.
Joel Martin [Wed, 11 May 2011 20:55:44 +0000 (15:55 -0500)]
API changes/cleanup.
API changes:
- include/canvas.js renamed to include/display.js
- Display.rescale() method removed from API. Use Display.set_scale() instead.
- Make logo configuration attribute of Display and display it when
clear() is called if it is set.
API deprecations:
- use RFB onUpdateState instead of updateState.
- use RFB onClipboard instead of clipboardReceive.
See https://github.com/kanaka/noVNC/wiki/ModuleAPI for detailed noVNC
modules and API description.
Expand and normalize the event/callback interfaces. Standize on
"onEventName" form for callbacks.
Other:
- Add array type support to Util.conf_default()
- Removed a bunch of routines from the Display API that were just used
internally and not actually by noVNC: flush, setFillColor,
imageDataGet, imageDataCreate, rgbxImageData, rgbxImageFill,
cmapImageData, cmapImageFill.
- More keyboard/mouse logging when debug turned on.
- Some JSLinting
Joel Martin [Tue, 12 Apr 2011 14:06:11 +0000 (09:06 -0500)]
input.js: adjust special key handling for non-US keys.
Issue #21 - non-US keyboard layouts.
Only identify some keys as special during the keyDown event so that
when using non-US keyboards the values don't overlap with the values
for normal keys.
Some keys have to still be identified in both keyDown and keyPress
since they generate both: backspace and enter for Firefox and Opera,
tab for Opera.
Joel Martin [Tue, 5 Apr 2011 19:26:54 +0000 (14:26 -0500)]
Refactor keyboard event handling.
This is part of addressing issue #21 - non-US keyboard layouts.
There are several challenges when dealing with keyboard events:
- The meaning and use of keyCode, charCode and which depends on
both the browser and the event type (keyDown/Up vs keyPress).
- We cannot automatically determine the keyboard layout
- The keyDown and keyUp events have a keyCode value that has not
been translated by modifier keys.
- The keyPress event has a translated (for layout and modifiers)
character code but the attribute containing it differs. keyCode
contains the translated value in WebKit (Chrome/Safari), Opera
11 and IE9. charCode contains the value in WebKit and Firefox.
The which attribute contains the value on WebKit, Firefox and
Opera 11.
- The keyDown/Up keyCode value indicates (sort of) the physical
key was pressed but only for standard US layout. On a US
keyboard, the '-' and '_' characters are on the same key and
generate a keyCode value of 189. But on an AZERTY keyboard even
though they are different physical keys they both still
generate a keyCode of 189!
- To prevent a key event from propagating to the browser and
causing unwanted default actions (such as closing a tab,
opening a menu, shifting focus, etc) we must suppress this
event in both keyDown and keyPress because not all key strokes
generate on a keyPress event. Also, in WebKit and IE9
suppressing the keyDown prevents a keyPress but other browsers
still generated a keyPress even if keyDown is suppressed.
For safe key events, we wait until the keyPress event before
reporting a key down event. For unsafe key events, we report a key
down event when the keyDown event fires and we suppress any further
actions (including keyPress).
In order to report a key up event that matches what we reported
for the key down event, we keep a list of keys that are currently
down. When the keyDown event happens, we add the key event to the
list. If it is a safe key event, then we update the which attribute
in the most recent item on the list when we received a keyPress
event (keyPress should immediately follow keyDown). When we
received a keyUp event we search for the event on the list with
a matching keyCode and we report the character code using the value
in the 'which' attribute that was stored with that key.
For character codes above 255 we use a character code to keysym lookup
table. This is generated using the util/u2x11 script contributed by
Colin Dean (xvpsource.org).
Joel Martin [Sun, 3 Apr 2011 22:30:45 +0000 (17:30 -0500)]
API change: Mouse/kbd handling to include/input.js
API change: for intergrators that explicitly include the Javascript
files (that do not use include/vnc.js)js, include/input.js is a new
file that must also be included.
The mouse and keyboard handling could be useful on its own so split it
out into a Keyboard and Mouse class in include/input.js.
This refactoring is preparation to deal with issue #21 - non-US
keyboard layouts.
Joel Martin [Tue, 22 Mar 2011 19:24:55 +0000 (14:24 -0500)]
Higher connectTimeout default with web-socket-js.
Current timeout is 2 seconds for connect timeout. Use 5 seconds if
web-socket-js (Flash WebSockets emulator) is being used. On Windows XP
with Flash 10.2.152.26, connecting seems to take quite a bit longer
than it probably should. This should make it work more consistently.
Joel Martin [Mon, 31 Jan 2011 04:58:22 +0000 (22:58 -0600)]
IE9 fixes. Works but slow. API change.
API change: changed include path variable from VNC_uri_prefix to
URI_INCLUDE since websock.js uses the variable and websock.js is no
longer just for noVNC (i.e. websockify is really the canonical
location for websock.js).
Changes to get web-socket-js to work. Right now it's a hack to get
around: https://github.com/gimite/web-socket-js/issues#issue/41. The
hack is to disable caching of the flash objects by appending
"?" + Math.random() to the end of the flash object path (but only when
using IE).
Joel Martin [Mon, 24 Jan 2011 01:36:11 +0000 (19:36 -0600)]
Opera 11 WebSockets and Opera '-' key mapping fix.
Opera 11 native WebSockets (if enabled) seems to have bad behavior for
the bufferedAmount so add change from websockify project to allow max
bufferedAmount (before send queue is delay) to be configured.
Also, Opera 11 and 10.60 behave like Mozilla regarding the '-' key so
translate it correctly.
Joel Martin [Mon, 24 Jan 2011 01:21:04 +0000 (19:21 -0600)]
websock.send returns true/false.
If all send data was flushed from the send queue then return true,
otherwise false. This doesn't mean the data won't be sent, just that
it wasn't sent this time and is queued.
Joel Martin [Mon, 24 Jan 2011 01:17:59 +0000 (19:17 -0600)]
Tolerate some bufferedAmount.
Only delay sending data if bufferedAmount is greater than 1000.
This seems to match the intention of the spec better. bufferedAmount
does not mean that we can't send, it's just an indication that the
network is becoming saturated. But Opera 11 native WebSockets seems to
have a bug that bufferedAmount isn't set back to zero correctly so
we'll be a bit more tolerant.
Joel Martin [Tue, 18 Jan 2011 18:16:50 +0000 (12:16 -0600)]
include/canvas.js: add numpad support to getKeysym.
Check keyLocation and translate numpad keys into numbers. keyLocation
is not widely supported yet, but it should start percolating into
browsers eventually:
http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent
Joel Martin [Thu, 13 Jan 2011 02:31:04 +0000 (20:31 -0600)]
Remove files that are now in websockify.
https://github.com/kanaka/websockify is now the canonical location of
websockify (formerly wsproxy). A copy of the python version is kept
here for backwards compatibility and ease-of-use. The other versions
and related test scripts are in websockify.
Getting the wswrapper.c LD_PRELOAD model working has turned out to
involve too many dark corners of the glibc/POSIX file descriptor
space. I realized that 95% of what I want can be accomplished by
adding a "wrap command" mode to wsproxy.
The code is still there for now, but consider it experimental at
best. Minor fix to dup2 and add dup and dup3 logging.
wsproxy Wrap Command:
In wsproxy wrap command mode, a command line is specified instead
of a target address and port. wsproxy then uses a much simpler
LD_PRELOAD library, rebind.so, to move intercept any bind() system
calls made by the program. If the bind() call is for the wsproxy
listen port number then the real bind() system call is issued for
an alternate (free high) port on loopback/localhost. wsproxy then
forwards from the listen address/port to the moved port.
The --wrap-mode argument takes three options that determine the
behavior of wsproxy when the wrapped command returns an exit code
(exit or daemonizing): ignore, exit, respawn.
For example, this runs vncserver on turns port 5901 into
a WebSockets port (rebind.so must be built first):
The vncserver command backgrounds itself so the wrap mode is set
to "ignore" so that wsproxy keeps running even after it receives
an exit code from vncserver.
wstelnet:
To demonstrate the wrap command mode, I added WebSockets telnet
client.
For example, this runs telnetd (krb5-telnetd) on turns port 2023
into a WebSockets port (using "respawn" mode since telnetd exits
after each connection closes):
Then the utils/wstelnet.html page can be used to connect to the
telnetd server on port 2023. The telnet client includes VT100.js
(from http://code.google.com/p/sshconsole) which handles the
terminal emulation and rendering.
rebind:
The rebind LD_PRELOAD library is used by wsproxy in wrap command
mode to intercept bind() system calls and move the port to
a different port on loopback/localhost. The rebind.so library can
be built by running make in the utils directory.
The rebind library can be used separately from wsproxy by setting
the REBIND_OLD_PORT and REBIND_NEW_PORT environment variables
prior to executing a command. For example:
Joel Martin [Sun, 9 Jan 2011 03:46:36 +0000 (21:46 -0600)]
wswrapper: add dup2, fix select w/ NULL timeout.
- add dup2 functionality. This requires adding a ref cnt to the
_WS_connections structure so that we only free the structure once
all dup'd referenced are closed. Also, refactor malloc and free of
connection structure into _WS_alloc and _WS_free.
- allow select to accept a NULL timeout value which means sleep
forever instead of segfaulting.
- fix some compile warnings related to ppoll definition.
- move some WebSockets related html test pages into utils and symlink
them from tests.
Joel Martin [Sat, 8 Jan 2011 21:29:01 +0000 (15:29 -0600)]
Refactor and cleanup websocket.py and deps.
Moved websocket.py code into a class WebSocketServer. WebSockets
server implementations will sub-class and define a handler() method
which is passed the client socket after. Global variable settings have been
changed to be parameters for WebSocketServer when created.
Subclass implementations still have to handle queueing and sending but
the parent class handles everything else (daemonizing, websocket
handshake, encode/decode, etc). It would be better if the parent class
could handle queueing and sending. This adds some buffering and
polling complexity to the parent class but it would be better to do so
at some point. However, the result is still much cleaner as can be
seen in wsecho.py.
Refactored wsproxy.py and wstest.py (formerly ws.py) to use the new
class. Added wsecho.py as a simple echo server.
- rename tests/ws.py to utils/wstest.py and add a symlink from
tests/wstest.py
- rename tests/ws.html to tests/wstest.html to match utils/wstest.py.
- add utils/wsecho.py
- add tests/wsecho.html which communicates with wsecho.py and simply
sends periodic messages and shows what is received.
Joel Martin [Fri, 7 Jan 2011 00:26:54 +0000 (18:26 -0600)]
wsproxy.py: add web serving capability.
- Added ability to respond to normal web requests. This is basically
integrating web.py functionality into wsproxy. This is only in the
python version and it is off by default when calling wsproxy. Turn
it on with --web DIR where DIR is the web root directory.
Next task is to clean up wsproxy.py. It's gotten unwieldy and it
really no longer needs to be parallel to the C version.