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
e2e7c224
Commit
e2e7c224
authored
Jun 15, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move DOM event handling from vnc.js to canvas.js.
parent
96a6eaad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
112 deletions
+82
-112
canvas.js
include/canvas.js
+72
-38
vnc.js
include/vnc.js
+10
-74
No files found.
include/canvas.js
View file @
e2e7c224
...
@@ -23,6 +23,10 @@ ctx : null,
...
@@ -23,6 +23,10 @@ ctx : null,
prevStyle
:
""
,
prevStyle
:
""
,
keyPress
:
null
,
mouseButton
:
null
,
mouseMove
:
null
,
getX
:
function
()
{
getX
:
function
()
{
var
c
=
$
(
Canvas
.
id
);
var
c
=
$
(
Canvas
.
id
);
...
@@ -34,46 +38,79 @@ getY: function() {
...
@@ -34,46 +38,79 @@ getY: function() {
return
c
.
getPosition
().
y
-
document
.
getScroll
().
y
;
return
c
.
getPosition
().
y
-
document
.
getScroll
().
y
;
},
},
mouseDown
:
function
(
e
)
{
onMouseButton
:
function
(
e
,
down
)
{
var
evt
=
e
.
event
||
window
.
event
;
var
evt
,
x
,
y
,
bmask
;
evt
=
e
.
event
||
window
.
event
;
x
=
(
evt
.
clientX
-
Canvas
.
getX
());
y
=
(
evt
.
clientY
-
Canvas
.
getY
());
bmask
=
1
<<
evt
.
button
;
//console.log('mouse ' + evt.which + '/' + evt.button + ' down:' + x + "," + y);
if
(
Canvas
.
mouseButton
)
{
Canvas
.
mouseButton
(
x
,
y
,
down
,
bmask
);
}
e
.
stop
();
e
.
stop
();
console
.
log
(
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' down:'
+
return
false
;
(
evt
.
clientX
-
Canvas
.
getX
())
+
","
+
(
evt
.
clientY
-
Canvas
.
getY
()));
},
},
mouseUp
:
function
(
e
)
{
onMouseDown
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
Canvas
.
onMouseButton
(
e
,
1
);
e
.
stop
();
console
.
log
(
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' up:'
+
(
evt
.
clientX
-
Canvas
.
getX
())
+
","
+
(
evt
.
clientY
-
Canvas
.
getY
()));
},
},
mouseMove
:
function
(
e
)
{
onMouseUp
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
Canvas
.
onMouseButton
(
e
,
0
);
console
.
log
(
'mouse '
+
evt
.
which
+
'/'
+
evt
.
button
+
' up:'
+
(
evt
.
clientX
-
Canvas
.
getX
())
+
","
+
(
evt
.
clientY
-
Canvas
.
getY
()));
},
},
mouseWheel
:
function
(
e
)
{
onMouseWheel
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
var
evt
,
x
,
y
,
bmask
;
evt
=
e
.
event
||
window
.
event
;
//e = e ? e : window.event;
//e = e ? e : window.event;
x
=
(
evt
.
clientX
-
Canvas
.
getX
());
y
=
(
evt
.
clientY
-
Canvas
.
getY
());
var
wheelData
=
evt
.
detail
?
evt
.
detail
*
-
1
:
evt
.
wheelDelta
/
40
;
var
wheelData
=
evt
.
detail
?
evt
.
detail
*
-
1
:
evt
.
wheelDelta
/
40
;
console
.
log
(
'mouse scroll by '
+
wheelData
+
':'
+
if
(
wheelData
>
0
)
{
(
evt
.
clientX
-
Canvas
.
getX
())
+
","
+
(
evt
.
clientY
-
Canvas
.
getY
()));
bmask
=
1
<<
3
;
}
else
{
bmask
=
1
<<
4
;
}
//console.log('mouse scroll by ' + wheelData + ':' + x + "," + y);
if
(
Canvas
.
mouseButton
)
{
Canvas
.
mouseButton
(
x
,
y
,
1
,
bmask
);
Canvas
.
mouseButton
(
x
,
y
,
0
,
bmask
);
}
e
.
stop
();
return
false
;
},
},
keyDown
:
function
(
e
)
{
onMouseMove
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
x
=
(
evt
.
clientX
-
Canvas
.
getX
());
y
=
(
evt
.
clientY
-
Canvas
.
getY
());
//console.log('mouse ' + evt.which + '/' + evt.button + ' up:' + x + "," + y);
if
(
Canvas
.
keyPress
)
{
Canvas
.
mouseMove
(
x
,
y
);
}
},
onKeyDown
:
function
(
e
)
{
//console.log("keydown: " + e.key + "(" + e.code + ")");
if
(
Canvas
.
keyPress
)
{
Canvas
.
keyPress
(
Canvas
.
getKeysym
(
e
),
1
);
}
e
.
stop
();
e
.
stop
();
console
.
log
(
"keydown: "
+
e
.
key
+
"("
+
e
.
code
+
")"
)
;
return
false
;
},
},
keyUp
:
function
(
e
)
{
onKeyUp
:
function
(
e
)
{
//console.log("keyup: " + e.key + "(" + e.code + ")");
if
(
Canvas
.
keyPress
)
{
Canvas
.
keyPress
(
Canvas
.
getKeysym
(
e
),
0
);
}
e
.
stop
();
e
.
stop
();
console
.
log
(
"keyup: "
+
e
.
key
+
"("
+
e
.
code
+
")"
)
;
return
false
;
},
},
ctx
Disable
:
function
(
e
)
{
onMouse
Disable
:
function
(
e
)
{
var
evt
=
e
.
event
||
window
.
event
;
var
evt
=
e
.
event
||
window
.
event
;
/* Stop propagation if inside canvas area */
/* Stop propagation if inside canvas area */
if
((
evt
.
clientX
>=
Canvas
.
getX
())
&&
if
((
evt
.
clientX
>=
Canvas
.
getX
())
&&
...
@@ -86,30 +123,27 @@ ctxDisable: function (e) {
...
@@ -86,30 +123,27 @@ ctxDisable: function (e) {
},
},
init
:
function
(
id
,
width
,
height
,
true_color
,
key
Down
,
keyUp
,
init
:
function
(
id
,
width
,
height
,
true_color
,
key
Press
,
mouse
Down
,
mouseUp
,
mouseMove
,
mouseWheel
)
{
mouse
Button
,
mouseMove
)
{
//console.log(">> Canvas.init");
//console.log(">> Canvas.init");
Canvas
.
id
=
id
;
Canvas
.
id
=
id
;
if
(
!
keyDown
)
{
keyDown
=
Canvas
.
keyDown
;
}
Canvas
.
keyPress
=
keyPress
||
null
;
if
(
!
keyUp
)
{
keyUp
=
Canvas
.
keyUp
;
}
Canvas
.
mouseButton
=
mouseButton
||
null
;
if
(
!
mouseDown
)
{
mouseDown
=
Canvas
.
mouseDown
;
}
Canvas
.
mouseMove
=
mouseMove
||
null
;
if
(
!
mouseUp
)
{
mouseUp
=
Canvas
.
mouseUp
;
}
if
(
!
mouseMove
)
{
mouseMove
=
Canvas
.
mouseMove
;
}
if
(
!
mouseWheel
)
{
mouseWheel
=
Canvas
.
mouseWheel
;
}
var
c
=
$
(
Canvas
.
id
);
var
c
=
$
(
Canvas
.
id
);
document
.
addEvent
(
'keydown'
,
k
eyDown
);
document
.
addEvent
(
'keydown'
,
Canvas
.
onK
eyDown
);
document
.
addEvent
(
'keyup'
,
k
eyUp
);
document
.
addEvent
(
'keyup'
,
Canvas
.
onK
eyUp
);
c
.
addEvent
(
'mousedown'
,
m
ouseDown
);
c
.
addEvent
(
'mousedown'
,
Canvas
.
onM
ouseDown
);
c
.
addEvent
(
'mouseup'
,
m
ouseUp
);
c
.
addEvent
(
'mouseup'
,
Canvas
.
onM
ouseUp
);
c
.
addEvent
(
'mouse
move'
,
mouseMove
);
c
.
addEvent
(
'mouse
wheel'
,
Canvas
.
onMouseWheel
);
c
.
addEvent
(
'mouse
wheel'
,
mouseWheel
);
c
.
addEvent
(
'mouse
move'
,
Canvas
.
onMouseMove
);
/* Work around right and middle click browser behaviors */
/* Work around right and middle click browser behaviors */
document
.
addEvent
(
'click'
,
Canvas
.
ctx
Disable
);
document
.
addEvent
(
'click'
,
Canvas
.
onMouse
Disable
);
document
.
body
.
addEvent
(
'contextmenu'
,
Canvas
.
ctx
Disable
);
document
.
body
.
addEvent
(
'contextmenu'
,
Canvas
.
onMouse
Disable
);
Canvas
.
resize
(
width
,
height
);
Canvas
.
resize
(
width
,
height
);
Canvas
.
c_wx
=
c
.
getSize
().
x
;
Canvas
.
c_wx
=
c
.
getSize
().
x
;
...
...
include/vnc.js
View file @
e2e7c224
...
@@ -453,8 +453,7 @@ init_msg: function () {
...
@@ -453,8 +453,7 @@ init_msg: function () {
RFB
.
fb_name
=
RQ
.
shiftStr
(
name_length
);
RFB
.
fb_name
=
RQ
.
shiftStr
(
name_length
);
Canvas
.
init
(
RFB
.
canvasID
,
RFB
.
fb_width
,
RFB
.
fb_height
,
RFB
.
true_color
,
Canvas
.
init
(
RFB
.
canvasID
,
RFB
.
fb_width
,
RFB
.
fb_height
,
RFB
.
true_color
,
RFB
.
keyDown
,
RFB
.
keyUp
,
RFB
.
mouseDown
,
RFB
.
mouseUp
,
RFB
.
keyPress
,
RFB
.
mouseButton
,
RFB
.
mouseMove
);
RFB
.
mouseMove
,
RFB
.
mouseWheel
);
if
(
RFB
.
true_color
)
{
if
(
RFB
.
true_color
)
{
RFB
.
fb_Bpp
=
4
;
RFB
.
fb_Bpp
=
4
;
...
@@ -955,12 +954,6 @@ display_tight_png: function() {
...
@@ -955,12 +954,6 @@ display_tight_png: function() {
FBU
.
imgs
.
push
([
img
,
FBU
.
x
,
FBU
.
y
]);
FBU
.
imgs
.
push
([
img
,
FBU
.
x
,
FBU
.
y
]);
img
.
src
=
"data:image/"
+
cmode
+
img
.
src
=
"data:image/"
+
cmode
+
RFB
.
extract_data_uri
(
RQ
.
shiftBytes
(
clength
[
1
]));
RFB
.
extract_data_uri
(
RQ
.
shiftBytes
(
clength
[
1
]));
/*
img.onload = (function () {
var x = FBU.x, y = FBU.y, me = img;
return function () { Canvas.ctx.drawImage(me, x, y); };
})();
*/
img
=
null
;
img
=
null
;
break
;
break
;
}
}
...
@@ -1303,88 +1296,31 @@ checkEvents: function () {
...
@@ -1303,88 +1296,31 @@ checkEvents: function () {
RFB
.
checkEvents
.
delay
(
RFB
.
check_rate
);
RFB
.
checkEvents
.
delay
(
RFB
.
check_rate
);
},
},
key
X
:
function
(
e
,
down
)
{
key
Press
:
function
(
keysym
,
down
)
{
var
arr
;
var
arr
;
if
(
RFB
.
clipboardFocus
)
{
if
(
RFB
.
clipboardFocus
)
{
return
true
;
return
true
;
}
}
e
.
stop
();
arr
=
RFB
.
keyEvent
(
keysym
,
down
);
arr
=
RFB
.
keyEvent
(
Canvas
.
getKeysym
(
e
),
down
);
arr
=
arr
.
concat
(
RFB
.
fbUpdateRequest
(
1
));
arr
=
arr
.
concat
(
RFB
.
fbUpdateRequest
(
1
));
RFB
.
send_array
(
arr
);
RFB
.
send_array
(
arr
);
},
},
keyDown
:
function
(
e
)
{
mouseButton
:
function
(
x
,
y
,
down
,
bmask
)
{
//console.log(">> keyDown: " + Canvas.getKeysym(e));
if
(
down
)
{
RFB
.
keyX
(
e
,
1
);
RFB
.
mouse_buttonMask
|=
bmask
;
},
}
else
{
RFB
.
mouse_buttonMask
^=
bmask
;
keyUp
:
function
(
e
)
{
}
//console.log(">> keyUp: " + Canvas.getKeysym(e));
RFB
.
keyX
(
e
,
0
);
},
mouseDown
:
function
(
e
)
{
var
evt
,
x
,
y
;
evt
=
e
.
event
||
window
.
event
;
x
=
(
evt
.
clientX
-
Canvas
.
getX
());
y
=
(
evt
.
clientY
-
Canvas
.
getY
());
//console.log(">> mouseDown " + evt.which + "/" + evt.button +
// " " + x + "," + y);
RFB
.
mouse_buttonMask
|=
1
<<
evt
.
button
;
RFB
.
mouse_arr
=
RFB
.
mouse_arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
RFB
.
flushClient
();
return
false
;
},
mouseUp
:
function
(
e
)
{
var
evt
,
x
,
y
;
evt
=
e
.
event
||
window
.
event
;
x
=
(
evt
.
clientX
-
Canvas
.
getX
());
y
=
(
evt
.
clientY
-
Canvas
.
getY
());
//console.log(">> mouseUp " + evt.which + "/" + evt.button +
// " " + x + "," + y);
RFB
.
mouse_buttonMask
^=
1
<<
evt
.
button
;
RFB
.
mouse_arr
=
RFB
.
mouse_arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
RFB
.
mouse_arr
=
RFB
.
mouse_arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
RFB
.
flushClient
();
RFB
.
flushClient
();
return
false
;
},
},
mouseMove
:
function
(
e
)
{
mouseMove
:
function
(
x
,
y
)
{
var
evt
,
x
,
y
;
evt
=
e
.
event
||
window
.
event
;
x
=
(
evt
.
clientX
-
Canvas
.
getX
());
y
=
(
evt
.
clientY
-
Canvas
.
getY
());
//console.log('>> mouseMove ' + x + "," + y);
//console.log('>> mouseMove ' + x + "," + y);
RFB
.
mouse_arr
=
RFB
.
mouse_arr
.
concat
(
RFB
.
pointerEvent
(
x
,
y
)
);
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
.
getX
());
y
=
(
evt
.
clientY
-
Canvas
.
getY
());
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
();
return
false
;
},
clipboardCopyTo
:
function
(
text
)
{
clipboardCopyTo
:
function
(
text
)
{
console
.
log
(
">> clipboardCopyTo stub"
);
console
.
log
(
">> clipboardCopyTo stub"
);
// Stub
// Stub
...
...
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