mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Second press of "Show Keyboard" should show the guac OSK if the native OSK is already in use.
This commit is contained in:
@@ -178,22 +178,54 @@ var GuacamoleUI = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When GuacamoleUI.oskMode == OSK_MODE_NATIVE, "Show Keyboard" tries
|
||||||
|
* to use the native OSK instead of the Guacamole OSK.
|
||||||
|
*/
|
||||||
|
GuacamoleUI.OSK_MODE_NATIVE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When GuacamoleUI.oskMode == OSK_MODE_GUAC, "Show Keyboard" uses the
|
||||||
|
* Guacamole OSK, regardless of whether a native OSK is available.
|
||||||
|
*/
|
||||||
|
GuacamoleUI.OSK_MODE_GUAC = 2;
|
||||||
|
|
||||||
// Assume no native OSK by default
|
// Assume no native OSK by default
|
||||||
GuacamoleUI.nativeOSK = false;
|
GuacamoleUI.oskMode = GuacamoleUI.OSK_MODE_GUAC;
|
||||||
|
|
||||||
// Show/Hide keyboard
|
// Show/Hide keyboard
|
||||||
var keyboardResizeInterval = null;
|
var keyboardResizeInterval = null;
|
||||||
GuacamoleUI.buttons.showKeyboard.onclick = function() {
|
GuacamoleUI.buttons.showKeyboard.onclick = function() {
|
||||||
|
|
||||||
// If we think the platform has a native OSK, use the event target to
|
// If Guac OSK shown, hide it.
|
||||||
// cause it to display.
|
var displayed = GuacamoleUI.containers.keyboard.style.display;
|
||||||
if (GuacamoleUI.nativeOSK) {
|
if (displayed == "block") {
|
||||||
GuacamoleUI.eventTarget.focus();
|
GuacamoleUI.containers.keyboard.style.display = "none";
|
||||||
return;
|
GuacamoleUI.buttons.showKeyboard.textContent = "Show Keyboard";
|
||||||
|
|
||||||
|
window.onresize = null;
|
||||||
|
window.clearInterval(keyboardResizeInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
var displayed = GuacamoleUI.containers.keyboard.style.display;
|
// If not shown ... action depends on OSK mode.
|
||||||
if (displayed != "block") {
|
else {
|
||||||
|
|
||||||
|
// If we think the platform has a native OSK, use the event target to
|
||||||
|
// cause it to display.
|
||||||
|
if (GuacamoleUI.oskMode == GuacamoleUI.OSK_MODE_NATIVE) {
|
||||||
|
|
||||||
|
// ...but use the Guac OSK if clicked again
|
||||||
|
GuacamoleUI.oskMode = GuacamoleUI.OSK_MODE_GUAC;
|
||||||
|
|
||||||
|
// Try to show native OSK by focusing eventTarget.
|
||||||
|
GuacamoleUI.eventTarget.focus();
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure event target is NOT focused if we are using the Guac OSK.
|
||||||
|
GuacamoleUI.eventTarget.blur();
|
||||||
|
|
||||||
GuacamoleUI.containers.keyboard.style.display = "block";
|
GuacamoleUI.containers.keyboard.style.display = "block";
|
||||||
GuacamoleUI.buttons.showKeyboard.textContent = "Hide Keyboard";
|
GuacamoleUI.buttons.showKeyboard.textContent = "Hide Keyboard";
|
||||||
|
|
||||||
@@ -203,13 +235,7 @@ var GuacamoleUI = {
|
|||||||
|
|
||||||
updateKeyboardSize();
|
updateKeyboardSize();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
GuacamoleUI.containers.keyboard.style.display = "none";
|
|
||||||
GuacamoleUI.buttons.showKeyboard.textContent = "Show Keyboard";
|
|
||||||
|
|
||||||
window.onresize = null;
|
|
||||||
window.clearInterval(keyboardResizeInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -250,7 +276,7 @@ var GuacamoleUI = {
|
|||||||
detectMenuOpenTimeout = window.setTimeout(function() {
|
detectMenuOpenTimeout = window.setTimeout(function() {
|
||||||
|
|
||||||
// If menu opened via mouse, do not show native OSK
|
// If menu opened via mouse, do not show native OSK
|
||||||
GuacamoleUI.nativeOSK = false;
|
GuacamoleUI.oskMode = GuacamoleUI.OSK_MODE_GUAC;
|
||||||
|
|
||||||
GuacamoleUI.showMenu();
|
GuacamoleUI.showMenu();
|
||||||
detectMenuOpenTimeout = null;
|
detectMenuOpenTimeout = null;
|
||||||
@@ -299,7 +325,7 @@ var GuacamoleUI = {
|
|||||||
menuShowLongPressTimeout = null;
|
menuShowLongPressTimeout = null;
|
||||||
|
|
||||||
// Assume native OSK if menu shown via long-press
|
// Assume native OSK if menu shown via long-press
|
||||||
GuacamoleUI.nativeOSK = true;
|
GuacamoleUI.oskMode = GuacamoleUI.OSK_MODE_NATIVE;
|
||||||
GuacamoleUI.showMenu();
|
GuacamoleUI.showMenu();
|
||||||
|
|
||||||
}, 800);
|
}, 800);
|
||||||
@@ -320,7 +346,7 @@ var GuacamoleUI = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Detect long-press at bottom of screen
|
// Detect long-press at bottom of screen
|
||||||
document.body.addEventListener('touchstart', GuacamoleUI.startLongPressDetect, true);
|
GuacamoleUI.display.addEventListener('touchstart', GuacamoleUI.startLongPressDetect, true);
|
||||||
|
|
||||||
// Reconnect button
|
// Reconnect button
|
||||||
GuacamoleUI.buttons.reconnect.onclick = function() {
|
GuacamoleUI.buttons.reconnect.onclick = function() {
|
||||||
@@ -415,7 +441,7 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
|
|
||||||
// If we're using native OSK, ensure event target is reset
|
// If we're using native OSK, ensure event target is reset
|
||||||
// on each key event.
|
// on each key event.
|
||||||
if (GuacamoleUI.nativeOSK)
|
if (GuacamoleUI.oskMode == GuacamoleUI.OSK_MODE_NATIVE)
|
||||||
GuacamoleUI.resetEventTarget();
|
GuacamoleUI.resetEventTarget();
|
||||||
|
|
||||||
guac.sendKeyEvent(1, keysym);
|
guac.sendKeyEvent(1, keysym);
|
||||||
|
Reference in New Issue
Block a user