Commit Graph

13 Commits

Author SHA1 Message Date
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