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
7e24f50b
Commit
7e24f50b
authored
Jul 24, 2013
by
samhed
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/kanaka/noVNC
into framebufferupdate
parents
dfcedffc
f3ff971d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
input.js
include/input.js
+35
-1
No files found.
include/input.js
View file @
7e24f50b
/*
* noVNC: HTML5 VNC client
* Copyright (C) 2012 Joel Martin
* Copyright (C) 2013 Samuel Mannehed for Cendio AB
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
*/
...
...
@@ -489,6 +490,9 @@ var that = {}, // Public API methods
conf
=
{},
// Configuration attributes
mouseCaptured
=
false
;
var
doubleClickTimer
=
null
,
lastTouchPos
=
null
;
// Configuration attributes
Util
.
conf_defaults
(
conf
,
that
,
defaults
,
[
[
'target'
,
'ro'
,
'dom'
,
document
,
'DOM element that captures mouse input'
],
...
...
@@ -521,6 +525,10 @@ function releaseMouse() {
// Private functions
//
function
resetDoubleClickTimer
()
{
doubleClickTimer
=
null
;
}
function
onMouseButton
(
e
,
down
)
{
var
evt
,
pos
,
bmask
;
if
(
!
conf
.
focused
)
{
...
...
@@ -528,8 +536,34 @@ function onMouseButton(e, down) {
}
evt
=
(
e
?
e
:
window
.
event
);
pos
=
Util
.
getEventPosition
(
e
,
conf
.
target
,
conf
.
scale
);
if
(
e
.
touches
||
e
.
changedTouches
)
{
// Touch device
// When two touches occur within 500 ms of each other and are
// closer than 20 pixels together a double click is triggered.
if
(
down
==
1
)
{
if
(
doubleClickTimer
==
null
)
{
lastTouchPos
=
pos
;
}
else
{
clearTimeout
(
doubleClickTimer
);
// When the distance between the two touches is small enough
// force the position of the latter touch to the position of
// the first.
var
xs
=
lastTouchPos
.
x
-
pos
.
x
;
var
ys
=
lastTouchPos
.
y
-
pos
.
y
;
var
d
=
Math
.
sqrt
((
xs
*
xs
)
+
(
ys
*
ys
));
// The goal is to trigger on a certain physical width, the
// devicePixelRatio brings us a bit closer but is not optimal.
if
(
d
<
20
*
window
.
devicePixelRatio
)
{
pos
=
lastTouchPos
;
}
}
doubleClickTimer
=
setTimeout
(
resetDoubleClickTimer
,
500
);
}
bmask
=
conf
.
touchButton
;
// If bmask is set
}
else
if
(
evt
.
which
)
{
...
...
@@ -543,7 +577,7 @@ function onMouseButton(e, down) {
}
//Util.Debug("mouse " + pos.x + "," + pos.y + " down: " + down +
// " bmask: " + bmask + "(evt.button: " + evt.button + ")");
if
(
bmask
>
0
&&
conf
.
onMouseButton
)
{
if
(
conf
.
onMouseButton
)
{
Util
.
Debug
(
"onMouseButton "
+
(
down
?
"down"
:
"up"
)
+
", x: "
+
pos
.
x
+
", y: "
+
pos
.
y
+
", bmask: "
+
bmask
);
conf
.
onMouseButton
(
pos
.
x
,
pos
.
y
,
down
,
bmask
);
...
...
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