Commit Graph

33 Commits

Author SHA1 Message Date
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
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
Joel Martin 292f6a5da7 Merge pull request #269 from phildriscoll/master
Fix to onMouseDisable
2013-07-31 08:35:02 -07: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 c6ad20992d Improved comments 2013-07-11 12:37:01 +02:00
samhed cf19ad3798 * Changed the trigger distance between touches from 50 to 20.
* The trigger distance now takes devicePixelRatio into account.
2013-07-08 17:14:50 +02:00
samhed a4ec2f5c7d Limited the double click fix to touch devices. 2013-07-03 14:41:09 +02:00
Samuel Mannehed b2f1961a3a to make double clicking on touch devices easier a double click is now triggered when two mouse clicks occur within 500 milli seconds and closer than 50 pixels together 2013-06-25 17:55:45 +02:00
Phil Driscoll ca9a9964a0 Fix onMouseDisable so that clicks outside the canvas are propagated 2013-06-13 11:10:04 +01:00
jalf b1b342a97e Capture mouse events and filter irrelevant ones 2013-01-30 13:17:50 +01:00
jalf 0d0f754aad Listen for mouseup events from window as well as target element
Pressing an holding a mouse button and then moving the mouse out of the
canvas before releasing meant that onmouseup was never triggered.
2013-01-30 13:17:32 +01:00
Hirokazu Takahashi 37a3081f05 Ctrl+'-' won't work on a US keyboad with Firefox.
Firefox 17 generates 173 as the keycode for the minus key.
2012-12-23 18:32:28 +09:00
Joel Martin 60106f240a Revert "supprt ALTGR key event"
This reverts commit 079504a6d2.
2012-10-17 15:37:24 -05:00
Joel Martin c527482ebf Merge pull request #195 from moobyfr/keyboard-altgr
Keyboard altgr
2012-10-17 13:30:50 -07:00
Joel Martin 7a6c94b6b9 Merge pull request #191 from takaha/altgr
support ALTGR key event
2012-10-16 08:09:35 -07:00
Joel Martin 1d728ace69 Change noVNC license to from LGPLv3 to MPL 2.0
The MPL 2.0 license is a "file-level" copyleft license vs the
"project-level" nature of the L/GPL. The intention of noVNC has
always been that it should be easy to incorporate into existing
projects and sites whether free/open or proprietary/commercial. The MPL
2.0 is designed for this sort of combination project but still
requires that any distributed modifications to noVNC source files must
also be published under the same license.

In addition, the MPL 2.0 allows the code to be used in L/GPL projects
(the secondary license clause). This means that any projects that are
already incorporating noVNC should not be impacted by this change and
in fact it should clarify the licensing situation (the exact
application of the L/GPL to web applications and interpreted code is
somewhat ambiguous).

The HTML, CSS, image and font files continue to be under more
permissive licenses (see LICENSE.txt). The included websockify python
code remains under a LGPLv3 license although the include/websock.js
file from the websockify component is now under MPL 2.0 as well.

Permission was received from other noVNC authors to make this change to their
code license on the following dates:

    - Chris Gordon (UI): Jun 24, 2012
    - Antoine Mercadal (DOM,*util.js): Oct 10, 2012
    - William Lightning (UltraVNC repeater): Oct 10, 2012
    - Mike Tinglof (tight encoding): Oct 15, 2012
2012-10-15 13:35:00 -05:00
Blindauer Emmanuel c76b2a8101 Handle Super and Menu keys (Windows keys) 2012-10-06 10:31:47 +02:00
Hirokazu Takahashi 079504a6d2 supprt ALTGR key event 2012-09-25 15:55:06 +09:00
BLINDAUER EMMANUEL 50b81d4470 AltGR support (Firefox 15 currently) 2012-08-02 09:09:35 +02:00
Joel Martin 483157f87f Comment out duplicates in unicodeTable.
Unfortunately the values for those duplicate keys are not the same and
I'm not sure which ones are more correct. However, for now, I've
commented out the second occurrence.

This data is generated from /usr/include/X11/keysymdef.h using the
utils/u2x11 script.
2012-04-26 08:18:27 -05:00
Joel Martin 6671c7624d Release down/pressed keys when window loses focus.
May window managers have a keyboard shortcut that switch away from the
current desktop (e.g. desktop switcher). Unfortunately, when this
happens, the meta/control keys that are used with the shortcut will
send a down event to the browser, but the up event will never be sent
because the browser no longer has focus at the point when the up event
happens. This can cause weird stuck key issues for VNC clients (not
just noVNC). To get around this, we try and detect when the browser
loses focus and release any keys that are on the keyDownList.

As an aside, if you run into this situation (in noVNC or another VNC
client), you can unstick the state by pressing and releasing the Ctrl,
Shift, Alt, etc.

Addresses: https://github.com/kanaka/noVNC/pull/135
2012-03-14 11:10:06 -05:00
Chris Gordon 53fc7392bb Modifed UI. Move HTML from ui.js to vnc.html. 2011-09-08 08:26:30 -05:00
Joel Martin ad3f762409 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.
2011-07-23 21:24:59 -05:00
Joel Martin 5210330a6c 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.
2011-05-11 17:31:53 -05:00
Joel Martin d890e8640f 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.

    Callback Renames:
        - RFB updateState -> onUpdateState
        - RFB clipboardReceive -> onClipboard
        - Keyboard keyPress -> onKeyPress
        - Mouse mouseButton -> onMouseButton
        - Mouse mouseMove -> onMouseMove

    Callback Additions:
        - RFB onPasswordRequired
        - RFB onBell
        - RFB onFBUReceive
        - RFB onFBUComplete

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
2011-05-11 15:55:44 -05:00
Joel Martin 58b4c53661 Fix scale/rescale attribute/hooks.
Still buggy so not yet activated in the UI, but the hooks are at least
here.
2011-04-29 14:01:40 -05:00
Joel Martin eb6426b4bc input.js: remove redundant switch case statments.
Issue #21 - non-US key handling.
2011-04-15 08:48:04 -06:00
Joel Martin dc4131b14a input.js: uncomment special key handling for non-US keys.
Issue #21 - non-US keyboard layouts.

The code section for tab, backspace and enter was commented out for
testing but got checked in that way. Fix that.
2011-04-15 08:40:20 -06:00
Joel Martin b7c9657b83 include/input.js: change to LGPL-2 or later.
Requested by Alexander Larsson at Red Hat to allow incorporation of
solution into HTML5 gtk 3.0 backend.
2011-04-14 11:25:11 -06:00
Joel Martin fac149ddbe 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.
2011-04-12 09:06:11 -05:00
Joel Martin c96f900336 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).
2011-04-05 14:26:54 -05:00
Joel Martin d3796c149e 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.
2011-04-03 17:30:45 -05:00