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
d064769c
Commit
d064769c
authored
Apr 13, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial mouse support. Down and Up only.
parent
9f4af5a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
23 deletions
+85
-23
canvas.js
canvas.js
+2
-2
vnc.js
vnc.js
+83
-21
No files found.
canvas.js
View file @
d064769c
...
...
@@ -7,14 +7,14 @@ c_wy : 0,
ctx
:
null
,
mouseDown
:
function
(
e
)
{
evt
=
e
.
event
||
window
.
event
;
var
evt
=
e
.
event
||
window
.
event
;
e
.
stop
();
console
.
log
(
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' down:'
+
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
));
},
mouseUp
:
function
(
e
)
{
evt
=
e
.
event
||
window
.
event
;
var
evt
=
e
.
event
||
window
.
event
;
e
.
stop
();
console
.
log
(
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' up:'
+
(
evt
.
clientX
-
Canvas
.
c_x
)
+
","
+
(
evt
.
clientY
-
Canvas
.
c_y
));
...
...
vnc.js
View file @
d064769c
...
...
@@ -41,7 +41,7 @@ Array.prototype.shiftBytes = function (len) {
/*
* Pending frame buffer update data
*/
var
FBU
=
{
FBU
=
{
rects
:
0
,
subrects
:
0
,
tiles
:
0
,
...
...
@@ -53,7 +53,15 @@ var FBU = {
encoding
:
0
,
subencoding
:
-
1
,
background
:
null
,
arr
:
null
};
arr
:
[]};
/*
* Mouse state data
*/
Mouse
=
{
buttonmask
:
0
,
arr
:
[]
};
/*
...
...
@@ -67,7 +75,7 @@ ws : null, // Web Socket object
version
:
"RFB 003.003
\n
"
,
state
:
'ProtocolVersion'
,
shared
:
1
,
p
oll
_rate
:
1413
,
p
ush
_rate
:
1413
,
host
:
''
,
port
:
5900
,
...
...
@@ -193,16 +201,17 @@ init_msg: function (data) {
console
.
log
(
"Name: "
+
RFB
.
fb_name
);
$
(
'status'
).
innerHTML
=
"Connected to: "
+
RFB
.
fb_name
;
Canvas
.
init
(
'vnc'
,
RFB
.
fb_width
,
RFB
.
fb_height
,
RFB
.
keyDown
,
RFB
.
keyUp
);
Canvas
.
init
(
'vnc'
,
RFB
.
fb_width
,
RFB
.
fb_height
,
RFB
.
keyDown
,
RFB
.
keyUp
,
RFB
.
mouseDown
,
RFB
.
mouseUp
);
var
init
=
[];
init
=
init
.
concat
(
RFB
.
pixelFormat
());
init
=
init
.
concat
(
RFB
.
encodings
());
init
=
init
.
concat
(
RFB
.
fbUpdateRequest
(
0
,
0
,
0
,
RFB
.
fb_width
,
RFB
.
fb_height
));
init
=
init
.
concat
(
RFB
.
fbUpdateRequest
(
0
));
RFB
.
send_array
(
init
);
/* Start polling */
RFB
.
p
oller
.
delay
(
RFB
.
poll
_rate
);
/* Start p
ushing/p
olling */
RFB
.
p
usher
.
delay
(
RFB
.
push
_rate
);
RFB
.
state
=
'normal'
;
break
;
...
...
@@ -313,7 +322,7 @@ display_hextile: function() {
}
}
//
console.log(" tile:" + cur_tile + "/" + (FBU.total_tiles - 1) + ", subencoding:" + subencoding + ", subrects:" + subrects + ", tile:" + tile_x + "," + tile_y + " [" + x + "," + y + "], arr.length:" + FBU.arr.length + ", bytes:" + FBU.bytes);
console
.
log
(
" tile:"
+
cur_tile
+
"/"
+
(
FBU
.
total_tiles
-
1
)
+
", subencoding:"
+
subencoding
+
", subrects:"
+
subrects
+
", tile:"
+
tile_x
+
","
+
tile_y
+
" ["
+
x
+
","
+
y
+
"], arr.length:"
+
FBU
.
arr
.
length
+
", bytes:"
+
FBU
.
bytes
);
//console.log(" arr[0..30]: " + FBU.arr.slice(0,30));
if
(
FBU
.
arr
.
length
<
FBU
.
bytes
)
{
//console.log(" waiting for " + (FBU.bytes - FBU.arr.length) + "bytes");
...
...
@@ -371,7 +380,7 @@ display_hextile: function() {
FBU
.
rects
--
;
}
//console.log("<< display_hextile"
);
console
.
log
(
"<< display_hextile, rects:"
+
FBU
.
rects
);
},
...
...
@@ -390,7 +399,6 @@ normal_msg: function (data) {
FBU
.
rects
=
data
.
shift16
();
console
.
log
(
"FramebufferUpdate, "
+
FBU
.
rects
+
" rects"
);
FBU
.
bytes
=
0
;
FBU
.
arr
=
[];
}
else
{
//console.log("FramebufferUpdate continuation");
}
...
...
@@ -399,7 +407,7 @@ normal_msg: function (data) {
FBU
.
arr
=
FBU
.
arr
.
concat
(
data
);
}
while
(
FBU
.
arr
.
length
>
0
)
{
while
(
(
FBU
.
rects
>
0
)
&&
(
FBU
.
arr
.
length
>
0
)
)
{
if
(
FBU
.
bytes
==
0
)
{
FBU
.
x
=
FBU
.
arr
.
shift16
();
FBU
.
y
=
FBU
.
arr
.
shift16
();
...
...
@@ -520,7 +528,11 @@ encodings: function () {
},
fbUpdateRequest
:
function
(
incremental
,
x
,
y
,
xw
,
yw
)
{
//console.log(">> fbUpdateRequest");
console
.
log
(
">> fbUpdateRequest"
);
if
(
!
x
)
x
=
0
;
if
(
!
y
)
y
=
0
;
if
(
!
xw
)
xw
=
RFB
.
fb_width
;
if
(
!
yw
)
yw
=
RFB
.
fb_height
;
var
arr
;
arr
=
[
3
];
// msg-type
arr
.
push8
(
incremental
);
...
...
@@ -540,12 +552,19 @@ keyEvent: function (keysym, down) {
arr
.
push16
(
0
);
arr
.
push32
(
keysym
);
//console.log("keyEvent array: " + arr);
arr
=
arr
.
concat
(
RFB
.
fbUpdateRequest
(
1
,
0
,
0
,
RFB
.
fb_width
,
RFB
.
fb_height
));
RFB
.
send_array
(
arr
);
//console.log("<< keyEvent");
return
arr
;
},
pointerEvent
:
function
()
{
pointerEvent
:
function
(
x
,
y
)
{
console
.
log
(
">> pointerEvent, x,y: "
+
x
+
","
+
y
+
" , mask: "
+
Mouse
.
buttonMask
);
var
arr
;
arr
=
[
5
];
// msg-type
arr
.
push8
(
Mouse
.
buttonMask
);
arr
.
push16
(
x
);
arr
.
push16
(
y
);
console
.
log
(
"<< pointerEvent"
);
return
arr
;
},
clientCutText
:
function
()
{
...
...
@@ -563,7 +582,7 @@ send_string: function (str) {
},
send_array
:
function
(
arr
)
{
//
console.log(">> send_array: " + arr);
console
.
log
(
">> send_array: "
+
arr
);
//console.log(">> send_array: " + Base64.encode_array(arr));
RFB
.
ws
.
send
(
Base64
.
encode_array
(
arr
));
},
...
...
@@ -586,25 +605,68 @@ passwdTwiddle: function (passwd) {
return
arr
;
},
poller
:
function
()
{
flushClient
:
function
()
{
var
arr
=
[];
if
(
Mouse
.
arr
.
length
>
0
)
{
RFB
.
send_array
(
Mouse
.
arr
.
concat
(
RFB
.
fbUpdateRequest
(
1
)));
Mouse
.
arr
=
[];
}
else
{
RFB
.
send_array
(
RFB
.
fbUpdateRequest
(
1
));
}
},
pusher
:
function
()
{
if
(
RFB
.
state
==
'normal'
)
{
RFB
.
send_array
(
RFB
.
fbUpdateRequest
(
1
,
0
,
0
,
RFB
.
fb_width
,
RFB
.
fb_height
)
);
RFB
.
p
oller
.
delay
(
RFB
.
poll
_rate
);
RFB
.
flushClient
(
);
RFB
.
p
usher
.
delay
(
RFB
.
push
_rate
);
}
},
keyDown
:
function
(
e
)
{
//console.log(">> keyDown: " + e.key + "(" + e.code + ")");
e
.
stop
();
RFB
.
keyEvent
(
Canvas
.
getKeysym
(
e
),
1
);
var
arr
=
RFB
.
keyEvent
(
Canvas
.
getKeysym
(
e
),
1
);
arr
=
arr
.
concat
(
RFB
.
fbUpdateRequest
(
1
));
RFB
.
send_array
(
arr
);
},
keyUp
:
function
(
e
)
{
//console.log(">> keyUp: " + e.key + "(" + e.code + ")");
e
.
stop
();
RFB
.
keyEvent
(
Canvas
.
getKeysym
(
e
),
0
);
var
arr
=
RFB
.
keyEvent
(
Canvas
.
getKeysym
(
e
),
0
);
arr
=
arr
.
concat
(
RFB
.
fbUpdateRequest
(
1
));
RFB
.
send_array
(
arr
);
},
mouseDown
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
var
x
,
y
;
x
=
(
evt
.
clientX
-
Canvas
.
c_x
);
y
=
(
evt
.
clientY
-
Canvas
.
c_y
);
console
.
log
(
'>> mouseDown '
+
evt
.
which
+
'/'
+
evt
.
button
+
" "
+
x
+
","
+
y
);
Mouse
.
buttonMask
|=
1
<<
evt
.
button
;
Mouse
.
arr
=
Mouse
.
arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
RFB
.
flushClient
();
},
mouseUp
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
var
x
,
y
;
x
=
(
evt
.
clientX
-
Canvas
.
c_x
);
y
=
(
evt
.
clientY
-
Canvas
.
c_y
);
console
.
log
(
'>> mouseUp '
+
evt
.
which
+
'/'
+
evt
.
button
+
" "
+
x
+
","
+
y
);
Mouse
.
buttonMask
^=
1
<<
evt
.
button
;
Mouse
.
arr
=
Mouse
.
arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
RFB
.
flushClient
();
},
mouseMove
:
function
(
e
)
{
// TODO: accumulate in global array
},
/*
* Setup routines
...
...
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