mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-326: Fix handling of focus (do not try to enforce, but inform when focus is gained/lost).
This commit is contained in:
@@ -1772,26 +1772,44 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
|
|
||||||
GuacUI.Client.ime_none_radio.onclick =
|
GuacUI.Client.ime_none_radio.onclick =
|
||||||
GuacUI.Client.ime_none_radio.onchange = function() {
|
GuacUI.Client.ime_none_radio.onchange = function() {
|
||||||
GuacUI.Client.ime_expected = false;
|
|
||||||
GuacUI.Client.target.blur();
|
if (GuacUI.Client.ime_enabled) {
|
||||||
|
GuacUI.Client.ime_expected = false;
|
||||||
|
__ime_notify_changed(false);
|
||||||
|
GuacUI.Client.target.blur();
|
||||||
|
}
|
||||||
|
|
||||||
GuacUI.Client.OnScreenKeyboard.hide();
|
GuacUI.Client.OnScreenKeyboard.hide();
|
||||||
GuacUI.Client.showMenu(false);
|
GuacUI.Client.showMenu(false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GuacUI.Client.ime_text_radio.onclick =
|
GuacUI.Client.ime_text_radio.onclick =
|
||||||
GuacUI.Client.ime_text_radio.onchange = function() {
|
GuacUI.Client.ime_text_radio.onchange = function() {
|
||||||
GuacUI.Client.ime_expected = true;
|
|
||||||
GuacUI.Client.target.focus();
|
if (!GuacUI.Client.ime_enabled) {
|
||||||
|
GuacUI.Client.ime_expected = true;
|
||||||
|
__ime_notify_changed(true);
|
||||||
|
GuacUI.Client.target.focus();
|
||||||
|
}
|
||||||
|
|
||||||
GuacUI.Client.OnScreenKeyboard.hide();
|
GuacUI.Client.OnScreenKeyboard.hide();
|
||||||
GuacUI.Client.showMenu(false);
|
GuacUI.Client.showMenu(false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GuacUI.Client.ime_osk_radio.onclick =
|
GuacUI.Client.ime_osk_radio.onclick =
|
||||||
GuacUI.Client.ime_osk_radio.onchange = function() {
|
GuacUI.Client.ime_osk_radio.onchange = function() {
|
||||||
GuacUI.Client.ime_expected = false;
|
|
||||||
GuacUI.Client.target.blur();
|
if (GuacUI.Client.ime_enabled) {
|
||||||
|
GuacUI.Client.ime_expected = false;
|
||||||
|
__ime_notify_changed(false);
|
||||||
|
GuacUI.Client.target.blur();
|
||||||
|
}
|
||||||
|
|
||||||
GuacUI.Client.OnScreenKeyboard.show();
|
GuacUI.Client.OnScreenKeyboard.show();
|
||||||
GuacUI.Client.showMenu(false);
|
GuacUI.Client.showMenu(false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1840,8 +1858,32 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ime_notify_enabled = null;
|
||||||
var ime_notify_timeout = null;
|
var ime_notify_timeout = null;
|
||||||
|
|
||||||
|
function __ime_notify_changed(new_state) {
|
||||||
|
|
||||||
|
if (ime_notify_enabled === null)
|
||||||
|
ime_notify_enabled = new_state;
|
||||||
|
|
||||||
|
window.clearTimeout(ime_notify_timeout);
|
||||||
|
ime_notify_timeout = window.setTimeout(function() {
|
||||||
|
|
||||||
|
// Only notify if state changed successfully
|
||||||
|
if (ime_notify_enabled === GuacUI.Client.ime_enabled) {
|
||||||
|
if (GuacUI.Client.ime_enabled)
|
||||||
|
GuacUI.Client.showNotification("Text input mode ON");
|
||||||
|
else
|
||||||
|
GuacUI.Client.showNotification("Text input mode OFF");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset for next change
|
||||||
|
ime_notify_enabled = null;
|
||||||
|
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
GuacUI.Client.target.onfocus = function() {
|
GuacUI.Client.target.onfocus = function() {
|
||||||
|
|
||||||
// Acknowledge and synchronize state change
|
// Acknowledge and synchronize state change
|
||||||
@@ -1849,19 +1891,12 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
GuacUI.Client.ime_text_radio.checked = true;
|
GuacUI.Client.ime_text_radio.checked = true;
|
||||||
GuacUI.Client.ime_enabled = true;
|
GuacUI.Client.ime_enabled = true;
|
||||||
|
|
||||||
// If unexpected, try to reset state back
|
|
||||||
if (!GuacUI.Client.ime_expected)
|
|
||||||
GuacUI.Client.target.blur();
|
|
||||||
|
|
||||||
// Reset content
|
// Reset content
|
||||||
GuacUI.Client.target.value = new Array(257).join("\u200B");
|
GuacUI.Client.target.value = new Array(257).join("\u200B");
|
||||||
GuacUI.Client.target.setSelectionRange(128, 128);
|
GuacUI.Client.target.setSelectionRange(128, 128);
|
||||||
|
|
||||||
// Notify of change if settled within 50ms
|
// Notify of change after it settles
|
||||||
window.clearTimeout(ime_notify_timeout);
|
__ime_notify_changed(true);
|
||||||
ime_notify_timeout = window.setTimeout(function() {
|
|
||||||
GuacUI.Client.showNotification("Text input mode ON");
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1872,15 +1907,8 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
GuacUI.Client.ime_none_radio.checked = true;
|
GuacUI.Client.ime_none_radio.checked = true;
|
||||||
GuacUI.Client.ime_enabled = false;
|
GuacUI.Client.ime_enabled = false;
|
||||||
|
|
||||||
// If unexpected, try to reset state back
|
// Notify of change after it settles
|
||||||
if (GuacUI.Client.ime_expected)
|
__ime_notify_changed(false);
|
||||||
GuacUI.Client.target.focus();
|
|
||||||
|
|
||||||
// Notify of change if settled within 50ms
|
|
||||||
window.clearTimeout(ime_notify_timeout);
|
|
||||||
ime_notify_timeout = window.setTimeout(function() {
|
|
||||||
GuacUI.Client.showNotification("Text input mode OFF");
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user