]> git.proxmox.com Git - mirror_novnc.git/blame - docs/API-internal.md
Split out internal API
[mirror_novnc.git] / docs / API-internal.md
CommitLineData
6929a0a1
PO
1# 1. Internal Modules
2
3The noVNC client is composed of several internal modules that handle
4rendering, input, networking, etc. Each of the modules is designed to
5be cross-browser and independent from each other.
6
7Note however that the API of these modules is not guaranteed to be
8stable, and this documentation is not maintained as well as the
9official external API.
10
11
12## 1.1 Module List
13
14* __Mouse__ (core/input/mouse.js): Mouse input event handler with
15limited touch support.
16
17* __Keyboard__ (core/input/keyboard.js): Keyboard input event handler with
18non-US keyboard support. Translates keyDown and keyUp events to X11
19keysym values.
20
21* __Display__ (core/display.js): Efficient 2D rendering abstraction
22layered on the HTML5 canvas element.
23
24* __Websock__ (core/websock.js): Websock client from websockify
25with transparent binary data support.
26[Websock API](https://github.com/novnc/websockify/wiki/websock.js) wiki page.
27
28
29## 1.2 Configuration Attributes
30
31The Mouse, Keyboard and Display objects have a similar API for
32configuration options as the RFB object. See the official API
33documentation for details.
34
35
36## 1.3 Callbacks
37
38For the Mouse, Keyboard and Display objects the callback functions are
39assigned to configuration attributes, just as for the RFB object. The
40WebSock module has a method named 'on' that takes two parameters: the
41callback event name, and the callback function.
42
43## 2. Modules
44
45## 2.1 Mouse Module
46
47### 2.1.1 Configuration Attributes
48
49| name | type | mode | default | description
50| ----------- | ---- | ---- | -------- | ------------
51| target | DOM | WO | document | DOM element that captures mouse input
52| touchButton | int | RW | 1 | Button mask (1, 2, 4) for which click to send on touch devices. 0 means ignore clicks.
53
54### 2.1.2 Methods
55
56| name | parameters | description
57| ------ | ---------- | ------------
58| grab | () | Begin capturing mouse events
59| ungrab | () | Stop capturing mouse events
60
61### 2.1.2 Callbacks
62
63| name | parameters | description
64| ------------- | ------------------- | ------------
65| onMouseButton | (x, y, down, bmask) | Handler for mouse button click/release
66| onMouseMove | (x, y) | Handler for mouse movement
67
68
69## 2.2 Keyboard Module
70
71### 2.2.1 Configuration Attributes
72
73| name | type | mode | default | description
74| ------- | ---- | ---- | -------- | ------------
75| target | DOM | WO | document | DOM element that captures keyboard input
76
77### 2.2.2 Methods
78
79| name | parameters | description
80| ------ | ---------- | ------------
81| grab | () | Begin capturing keyboard events
82| ungrab | () | Stop capturing keyboard events
83
84### 2.2.3 Callbacks
85
86| name | parameters | description
87| ---------- | -------------------- | ------------
88| onKeyPress | (keysym, code, down) | Handler for key press/release
89
90
91## 2.3 Display Module
92
93### 2.3.1 Configuration Attributes
94
95| name | type | mode | default | description
96| ----------- | ----- | ---- | ------- | ------------
97| target | DOM | WO | | Canvas element for rendering
98| context | raw | RO | | Canvas 2D context for rendering
99| logo | raw | RW | | Logo to display when cleared: {"width": width, "height": height, "type": mime-type, "data": data}
100| scale | float | RW | 1.0 | Display area scale factor 0.0 - 1.0
101| viewport | bool | RW | false | Use viewport clipping
102| width | int | RO | | Display area width
103| height | int | RO | | Display area height
104| render_mode | str | RO | '' | Canvas rendering mode
105| prefer_js | str | RW | | Prefer JavaScript over canvas methods
106| cursor_uri | raw | RW | | Can we render cursor using data URI
107
108### 2.3.2 Methods
109
110| name | parameters | description
111| ------------------ | ------------------------------------------------------- | ------------
112| viewportChangePos | (deltaX, deltaY) | Move the viewport relative to the current location
113| viewportChangeSize | (width, height) | Change size of the viewport
114| absX | (x) | Return X relative to the remote display
115| absY | (y) | Return Y relative to the remote display
116| resize | (width, height) | Set width and height
117| flip | (from_queue) | Update the visible canvas with the contents of the rendering canvas
118| clear | () | Clear the display (show logo if set)
119| pending | () | Check if there are waiting items in the render queue
120| flush | () | Resume processing the render queue unless it's empty
121| fillRect | (x, y, width, height, color, from_queue) | Draw a filled in rectangle
122| copyImage | (old_x, old_y, new_x, new_y, width, height, from_queue) | Copy a rectangular area
123| imageRect | (x, y, mime, arr) | Draw a rectangle with an image
124| startTile | (x, y, width, height, color) | Begin updating a tile
125| subTile | (tile, x, y, w, h, color) | Update a sub-rectangle within the given tile
126| finishTile | () | Draw the current tile to the display
127| blitImage | (x, y, width, height, arr, offset, from_queue) | Blit pixels (of R,G,B,A) to the display
128| blitRgbImage | (x, y, width, height, arr, offset, from_queue) | Blit RGB encoded image to display
129| blitRgbxImage | (x, y, width, height, arr, offset, from_queue) | Blit RGBX encoded image to display
130| drawImage | (img, x, y) | Draw image and track damage
131| changeCursor | (pixels, mask, hotx, hoty, w, h) | Change cursor appearance
132| defaultCursor | () | Restore default cursor appearance
133| disableLocalCursor | () | Disable local (client-side) cursor
134| clippingDisplay | () | Check if the remote display is larger than the client display
135| autoscale | (containerWidth, containerHeight, downscaleOnly) | Scale the display
136
137### 2.3.3 Callbacks
138
139| name | parameters | description
140| ------- | ---------- | ------------
141| onFlush | () | A display flush has been requested and we are now ready to resume FBU processing