diff options
author | Samuel Mannehed <samuel@cendio.se> | 2017-02-16 13:25:34 +0100 |
---|---|---|
committer | Samuel Mannehed <samuel@cendio.se> | 2017-02-16 14:00:36 +0100 |
commit | 8cbf1dd9d220950ea5163a3c2da2ebca0c7bc450 (patch) | |
tree | 5a0080e9a5205d59bbac6a2003905349f9c0e4a8 | |
parent | 10d1ecc118a617f5d6e3011ae17afc90a9dfa486 (diff) | |
download | novnc-8cbf1dd9d220950ea5163a3c2da2ebca0c7bc450.tar.gz |
Set correct cursor style for setCapture()
-rw-r--r-- | core/util.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/util.js b/core/util.js index 27fc179..03e6925 100644 --- a/core/util.js +++ b/core/util.js @@ -507,6 +507,13 @@ Util._captureProxy = function (e) { } }; +// Follow cursor style of target element +Util._captureElemChanged = function() { + var captureElem = document.getElementById("noVNC_mouse_capture_elem"); + captureElem.style.cursor = window.getComputedStyle(Util._captureElem).cursor; +}; +Util._captureObserver = new MutationObserver(Util._captureElemChanged); + Util.setCapture = function (elem) { if (elem.setCapture) { @@ -558,6 +565,11 @@ Util.setCapture = function (elem) { } Util._captureElem = elem; + + // Track cursor and get initial cursor + Util._captureObserver.observe(elem, {attributes:true}); + Util._captureElemChanged(); + captureElem.style.display = null; // We listen to events on window in order to keep tracking if it @@ -586,6 +598,8 @@ Util.releaseCapture = function () { // FIXME: What happens if setCapture is called before this fires? window.setTimeout(function() { Util._captureElem = null; }); + Util._captureObserver.disconnect(); + var captureElem = document.getElementById("noVNC_mouse_capture_elem"); captureElem.style.display = "none"; |