Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
noVNC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
noVNC
Commits
a575a383
Commit
a575a383
authored
May 25, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mouse wheel support and input test page.
parent
7f4f41b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
3 deletions
+133
-3
canvas.js
include/canvas.js
+12
-1
include
tests/include
+1
-0
input.html
tests/input.html
+95
-0
vnc.js
vnc.js
+25
-2
No files found.
include/canvas.js
View file @
a575a383
...
...
@@ -42,6 +42,14 @@ mouseMove: function (e) {
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
));
},
mouseWheel
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
//e = e ? e : window.event;
var
wheelData
=
evt
.
detail
?
evt
.
detail
*
-
1
:
evt
.
wheelDelta
/
40
;
console
.
log
(
'mouse scroll by '
+
wheelData
+
':'
+
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
));
},
keyDown
:
function
(
e
)
{
e
.
stop
();
...
...
@@ -67,7 +75,7 @@ ctxDisable: function (e) {
init
:
function
(
id
,
width
,
height
,
keyDown
,
keyUp
,
mouseDown
,
mouseUp
,
mouseMove
)
{
mouseDown
,
mouseUp
,
mouseMove
,
mouseWheel
)
{
console
.
log
(
">> Canvas.init"
);
Canvas
.
id
=
id
;
...
...
@@ -77,6 +85,7 @@ init: function (id, width, height, keyDown, keyUp,
if
(
!
mouseDown
)
{
mouseDown
=
Canvas
.
mouseDown
;
}
if
(
!
mouseUp
)
{
mouseUp
=
Canvas
.
mouseUp
;
}
if
(
!
mouseMove
)
{
mouseMove
=
Canvas
.
mouseMove
;
}
if
(
!
mouseWheel
)
{
mouseWheel
=
Canvas
.
mouseWheel
;
}
var
c
=
$
(
Canvas
.
id
);
document
.
addEvent
(
'keydown'
,
keyDown
);
...
...
@@ -84,6 +93,7 @@ init: function (id, width, height, keyDown, keyUp,
c
.
addEvent
(
'mousedown'
,
mouseDown
);
c
.
addEvent
(
'mouseup'
,
mouseUp
);
c
.
addEvent
(
'mousemove'
,
mouseMove
);
c
.
addEvent
(
'mousewheel'
,
mouseWheel
);
/* Work around right and middle click browser behaviors */
document
.
addEvent
(
'click'
,
Canvas
.
ctxDisable
);
...
...
@@ -122,6 +132,7 @@ stop: function () {
c
.
removeEvents
(
'mousedown'
);
c
.
removeEvents
(
'mouseup'
);
c
.
removeEvents
(
'mousemove'
);
c
.
removeEvents
(
'DOMMouseScroll'
);
/* Work around right and middle click browser behaviors */
document
.
removeEvents
(
'click'
);
...
...
tests/include
0 → 120000
View file @
a575a383
../include
\ No newline at end of file
tests/input.html
0 → 100644
View file @
a575a383
<html>
<head><title>
Input Test
</title></head>
<body>
<br><br>
Canvas:
<br>
<canvas
id=
"canvas"
width=
"640"
height=
"20"
style=
"border-style: dotted; border-width: 1px;"
>
Canvas not supported.
</canvas>
<br>
Results:
<br>
<textarea
id=
"messages"
style=
"font-size: 9;"
cols=
80
rows=
25
></textarea>
</body>
<!--
<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
-->
<script
src=
"include/mootools.js"
></script>
<script
src=
"include/util.js"
></script>
<script
src=
"include/canvas.js"
></script>
<script>
var
msg_cnt
=
0
;
var
width
=
800
,
height
=
600
;
var
iterations
;
function
message
(
str
)
{
console
.
log
(
str
);
cell
=
$
(
'messages'
);
cell
.
innerHTML
+=
msg_cnt
+
": "
+
str
+
"
\n
"
;
cell
.
scrollTop
=
cell
.
scrollHeight
;
}
function
mouseDown
(
e
)
{
var
msg
,
evt
=
e
.
event
||
window
.
event
;
e
.
stop
();
msg
=
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' down:'
+
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
);
console
.
log
(
msg
);
message
(
msg
);
}
function
mouseUp
(
e
)
{
var
msg
,
evt
=
e
.
event
||
window
.
event
;
e
.
stop
();
msg
=
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' up:'
+
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
);
console
.
log
(
msg
);
message
(
msg
);
}
function
mouseMove
(
e
)
{
var
msg
,
evt
=
e
.
event
||
window
.
event
;
console
.
log
(
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' up:'
+
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
));
}
function
mouseWheel
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
//e = e ? e : window.event;
var
wheelData
=
evt
.
detail
?
evt
.
detail
*
-
1
:
evt
.
wheelDelta
/
40
;
msg
=
'mouse scroll by '
+
wheelData
+
':'
+
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
);
console
.
log
(
msg
);
message
(
msg
);
}
function
keyDown
(
e
)
{
var
msg
;
e
.
stop
();
msg
=
"keydown: "
+
e
.
key
+
"("
+
e
.
code
+
")"
;
console
.
log
(
msg
);
message
(
msg
);
}
function
keyUp
(
e
)
{
var
msg
;
e
.
stop
();
msg
=
"keyup: "
+
e
.
key
+
"("
+
e
.
code
+
")"
;
console
.
log
(
msg
);
message
(
msg
);
}
window
.
onload
=
function
()
{
Canvas
.
init
(
'canvas'
,
width
,
height
,
keyDown
,
keyUp
,
mouseDown
,
mouseUp
,
mouseMove
,
mouseWheel
);
message
(
"Canvas initialized"
);
}
</script>
</html>
vnc.js
View file @
a575a383
...
...
@@ -289,8 +289,8 @@ init_msg: function () {
RFB
.
fb_name
=
RQ
.
shiftStr
(
name_length
);
Canvas
.
init
(
'VNC_canvas'
,
RFB
.
fb_width
,
RFB
.
fb_height
,
RFB
.
keyDown
,
RFB
.
keyUp
,
RFB
.
mouse
Down
,
RFB
.
mouseUp
,
RFB
.
mouseMove
);
RFB
.
keyDown
,
RFB
.
keyUp
,
RFB
.
mouseDown
,
RFB
.
mouseUp
,
RFB
.
mouse
Move
,
RFB
.
mouseWheel
);
response
=
RFB
.
pixelFormat
();
response
=
response
.
concat
(
RFB
.
encodings
());
...
...
@@ -984,6 +984,29 @@ mouseMove: function(e) {
RFB
.
mouse_arr
=
RFB
.
mouse_arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
},
mouseWheel
:
function
(
e
)
{
var
evt
,
wheelData
,
bmask
;
evt
=
e
.
event
||
window
.
event
;
//e = e ? e : window.event;
x
=
(
evt
.
clientX
-
Canvas
.
c_x
);
y
=
(
evt
.
clientY
-
Canvas
.
c_y
);
wheelData
=
evt
.
detail
?
evt
.
detail
*
-
1
:
evt
.
wheelDelta
/
40
;
//console.log('>> mouseWheel ' + wheelData +
// " " + x + "," + y);
if
(
wheelData
>
0
)
{
bmask
=
1
<<
3
;
}
else
{
bmask
=
1
<<
4
;
}
RFB
.
mouse_buttonMask
|=
bmask
;
RFB
.
mouse_arr
=
RFB
.
mouse_arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
RFB
.
mouse_buttonMask
^=
bmask
;
RFB
.
mouse_arr
=
RFB
.
mouse_arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
RFB
.
flushClient
();
},
clipboardCopyTo
:
function
(
text
)
{
console
.
log
(
">> clipboardCopyTo: "
+
text
.
substr
(
0
,
40
)
+
"..."
);
RFB
.
clipboard
.
value
=
text
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment