diff --git a/app/ui.js b/app/ui.js index 03969ba..83609d2 100644 --- a/app/ui.js +++ b/app/ui.js @@ -731,7 +731,11 @@ const UI = { var handle = document.getElementById("noVNC_control_bar_handle"); var bounds = handle.getBoundingClientRect(); - setCapture(handle); + // Touch events have implicit capture + if (e.type === "mousedown") { + setCapture(handle); + } + UI.controlbarGrabbed = true; UI.controlbarDrag = false; diff --git a/core/input/devices.js b/core/input/devices.js index c5cd68f..08c8a63 100644 --- a/core/input/devices.js +++ b/core/input/devices.js @@ -10,7 +10,7 @@ import * as Log from '../util/logging.js'; import { isTouchDevice } from '../util/browsers.js' -import { setCapture, releaseCapture, stopEvent, getPointerEvent } from '../util/events.js'; +import { setCapture, stopEvent, getPointerEvent } from '../util/events.js'; import { set_defaults, make_properties } from '../util/properties.js'; import * as KeyboardUtil from "./util.js"; import KeyTable from "./keysym.js"; @@ -299,14 +299,6 @@ const Mouse = function (defaults) { Mouse.prototype = { // private methods - _captureMouse: function () { - // capturing the mouse ensures we get the mouseup event - setCapture(this._target); - }, - - _releaseMouse: function () { - releaseCapture(); - }, _resetDoubleClickTimer: function () { this._doubleClickTimer = null; @@ -367,13 +359,16 @@ Mouse.prototype = { }, _handleMouseDown: function (e) { - this._captureMouse(); + // Touch events have implicit capture + if (e.type === "mousedown") { + setCapture(this._target); + } + this._handleMouseButton(e, 1); }, _handleMouseUp: function (e) { this._handleMouseButton(e, 0); - this._releaseMouse(); }, _handleMouseWheel: function (e) { diff --git a/core/util/events.js b/core/util/events.js index d5e6de9..09f5c8a 100644 --- a/core/util/events.js +++ b/core/util/events.js @@ -44,7 +44,7 @@ const _captureProxy = function (e) { } // Implicitly release the capture on button release - if ((e.type === "mouseup") || (e.type === "touchend")) { + if (e.type === "mouseup") { releaseCapture(); } }; @@ -65,24 +65,12 @@ export function setCapture (elem) { // IE releases capture on 'click' events which might not trigger elem.addEventListener('mouseup', releaseCapture); - elem.addEventListener('touchend', releaseCapture); } else { // Release any existing capture in case this method is // called multiple times without coordination releaseCapture(); - // Safari on iOS 9 has a broken constructor for TouchEvent. - // We are fine in this case however, since Safari seems to - // have some sort of implicit setCapture magic anyway. - if (window.TouchEvent !== undefined) { - try { - new TouchEvent("touchstart"); - } catch (TypeError) { - return; - } - } - var captureElem = document.getElementById("noVNC_mouse_capture_elem"); if (captureElem === null) { @@ -103,9 +91,6 @@ export function setCapture (elem) { captureElem.addEventListener('mousemove', _captureProxy); captureElem.addEventListener('mouseup', _captureProxy); - - captureElem.addEventListener('touchmove', _captureProxy); - captureElem.addEventListener('touchend', _captureProxy); } _captureElem = elem; @@ -121,9 +106,6 @@ export function setCapture (elem) { // happens to leave the viewport window.addEventListener('mousemove', _captureProxy); window.addEventListener('mouseup', _captureProxy); - - window.addEventListener('touchmove', _captureProxy); - window.addEventListener('touchend', _captureProxy); } }; @@ -154,8 +136,5 @@ export function releaseCapture () { window.removeEventListener('mousemove', _captureProxy); window.removeEventListener('mouseup', _captureProxy); - - window.removeEventListener('touchmove', _captureProxy); - window.removeEventListener('touchend', _captureProxy); } };