blur logic

This commit is contained in:
Devaev Maxim 2018-11-27 17:32:36 +03:00
parent 8c3f604e4a
commit 2cea16a978
3 changed files with 23 additions and 3 deletions

View File

@ -38,8 +38,8 @@ function Hid() {
); );
} }
window.onpagehide = __releaseAll; window.addEventListener("pagehide", __releaseAll);
window.onblur = __releaseAll; window.addEventListener("blur", __releaseAll);
__chars_to_codes = __buildCharsToCodes(); __chars_to_codes = __buildCharsToCodes();

View File

@ -21,6 +21,10 @@ function Keyboard() {
$("stream-window").onfocus = __updateLeds; $("stream-window").onfocus = __updateLeds;
$("stream-window").onblur = __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) { Array.prototype.forEach.call($$("key"), function(el_key) {
tools.setOnDown(el_key, () => __clickHandler(el_key, true)); tools.setOnDown(el_key, () => __clickHandler(el_key, true));
tools.setOnUp(el_key, () => __clickHandler(el_key, false)); tools.setOnUp(el_key, () => __clickHandler(el_key, false));
@ -63,7 +67,18 @@ function Keyboard() {
}; };
var __updateLeds = function() { 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").className = "led-green";
$("hid-keyboard-led").title = "Keyboard captured"; $("hid-keyboard-led").title = "Keyboard captured";
} else { } else {

View File

@ -39,6 +39,11 @@ function Ui() {
window.onmouseup = __globalMouseButtonHandler; window.onmouseup = __globalMouseButtonHandler;
window.ontouchend = __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("resize", () => __organizeWindowsOnResize(false));
window.addEventListener("orientationchange", () => __organizeWindowsOnResize(true)); window.addEventListener("orientationchange", () => __organizeWindowsOnResize(true));
}; };