diff options
author | Devaev Maxim <[email protected]> | 2018-11-27 17:32:36 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-11-27 17:32:36 +0300 |
commit | 2cea16a978f475aa2b12d49d7ac2eccfd5c6892f (patch) | |
tree | 4d3d9e2fe648c93852695e9905a7c8854a592c6f /web | |
parent | 8c3f604e4a64fa6b81da30d6d3cba6c9dc0d9d71 (diff) |
blur logic
Diffstat (limited to 'web')
-rw-r--r-- | web/js/kvm/hid.js | 4 | ||||
-rw-r--r-- | web/js/kvm/keyboard.js | 17 | ||||
-rw-r--r-- | web/js/ui.js | 5 |
3 files changed, 23 insertions, 3 deletions
diff --git a/web/js/kvm/hid.js b/web/js/kvm/hid.js index 341527b1..e7877484 100644 --- a/web/js/kvm/hid.js +++ b/web/js/kvm/hid.js @@ -38,8 +38,8 @@ function Hid() { ); } - window.onpagehide = __releaseAll; - window.onblur = __releaseAll; + window.addEventListener("pagehide", __releaseAll); + window.addEventListener("blur", __releaseAll); __chars_to_codes = __buildCharsToCodes(); diff --git a/web/js/kvm/keyboard.js b/web/js/kvm/keyboard.js index 126749cb..273038fa 100644 --- a/web/js/kvm/keyboard.js +++ b/web/js/kvm/keyboard.js @@ -21,6 +21,10 @@ function Keyboard() { $("stream-window").onfocus = __updateLeds; $("stream-window").onblur = __updateLeds; + window.addEventListener("focus", __updateLeds); + window.addEventListener("pagehide", __updateLeds); + window.addEventListener("blur", __updateLeds); + Array.prototype.forEach.call($$("key"), function(el_key) { tools.setOnDown(el_key, () => __clickHandler(el_key, true)); tools.setOnUp(el_key, () => __clickHandler(el_key, false)); @@ -63,7 +67,18 @@ function Keyboard() { }; var __updateLeds = function() { - if (__ws && (document.activeElement === $("stream-window") || document.activeElement === $("keyboard-window"))) { + tools.info("Update leds"); + if ( + __ws + && ( + document.activeElement === $("stream-window") + || document.activeElement === $("keyboard-window") + ) + && ( + $("stream-window").classList.contains("window-active") + || $("keyboard-window").classList.contains("window-active") + ) + ) { $("hid-keyboard-led").className = "led-green"; $("hid-keyboard-led").title = "Keyboard captured"; } else { diff --git a/web/js/ui.js b/web/js/ui.js index b4c13536..e3877191 100644 --- a/web/js/ui.js +++ b/web/js/ui.js @@ -39,6 +39,11 @@ function Ui() { window.onmouseup = __globalMouseButtonHandler; window.ontouchend = __globalMouseButtonHandler; + window.addEventListener("focus", () => __activateLastWindow()); + window.addEventListener("pagehide", () => __deactivateAllWindows()); + window.addEventListener("pagehide", __closeAllMenues); + window.addEventListener("blur", () => __deactivateAllWindows()); + window.addEventListener("blur", __closeAllMenues); window.addEventListener("resize", () => __organizeWindowsOnResize(false)); window.addEventListener("orientationchange", () => __organizeWindowsOnResize(true)); }; |