(ev)
| 1238 | } |
| 1239 | |
| 1240 | _handleMouse(ev) { |
| 1241 | /* |
| 1242 | * We don't check connection status or viewOnly here as the |
| 1243 | * mouse events might be used to control the viewport |
| 1244 | */ |
| 1245 | |
| 1246 | if (ev.type === 'click') { |
| 1247 | /* |
| 1248 | * Note: This is only needed for the 'click' event as it fails |
| 1249 | * to fire properly for the target element so we have |
| 1250 | * to listen on the document element instead. |
| 1251 | */ |
| 1252 | if (ev.target !== this._canvas) { |
| 1253 | return; |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | // FIXME: if we're in view-only and not dragging, |
| 1258 | // should we stop events? |
| 1259 | ev.stopPropagation(); |
| 1260 | ev.preventDefault(); |
| 1261 | |
| 1262 | if ((ev.type === 'click') || (ev.type === 'contextmenu')) { |
| 1263 | return; |
| 1264 | } |
| 1265 | |
| 1266 | let pos = clientToElement(ev.clientX, ev.clientY, |
| 1267 | this._canvas); |
| 1268 | |
| 1269 | let bmask = RFB._convertButtonMask(ev.buttons); |
| 1270 | |
| 1271 | let down = ev.type == 'mousedown'; |
| 1272 | switch (ev.type) { |
| 1273 | case 'mousedown': |
| 1274 | case 'mouseup': |
| 1275 | if (this.dragViewport) { |
| 1276 | if (down && !this._viewportDragging) { |
| 1277 | this._viewportDragging = true; |
| 1278 | this._viewportDragPos = {'x': pos.x, 'y': pos.y}; |
| 1279 | this._viewportHasMoved = false; |
| 1280 | |
| 1281 | this._flushMouseMoveTimer(pos.x, pos.y); |
| 1282 | |
| 1283 | // Skip sending mouse events, instead save the current |
| 1284 | // mouse mask so we can send it later. |
| 1285 | this._mouseButtonMask = bmask; |
| 1286 | break; |
| 1287 | } else { |
| 1288 | this._viewportDragging = false; |
| 1289 | |
| 1290 | // If we actually performed a drag then we are done |
| 1291 | // here and should not send any mouse events |
| 1292 | if (this._viewportHasMoved) { |
| 1293 | this._mouseButtonMask = bmask; |
| 1294 | break; |
| 1295 | } |
| 1296 | // Otherwise we treat this as a mouse click event. |
| 1297 | // Send the previously saved button mask, followed |
nothing calls this directly
no test coverage detected