Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML5 client. Keyboard layout on-fly change #66

Closed
totaam opened this issue Apr 2, 2017 · 4 comments
Closed

HTML5 client. Keyboard layout on-fly change #66

totaam opened this issue Apr 2, 2017 · 4 comments

Comments

@totaam
Copy link
Collaborator

totaam commented Apr 2, 2017

Issue migrated from trac ticket # 1484

component: html5 | priority: major | resolution: fixed

2017-04-02 17:58:29: Denis01 created the issue


Follow up from Xpra-org/xpra#1487:
Hello,
Somebody already told about this function but seems not declared ticket (at least I have not found, correct me if I am wrong).
So it would perfect if that function appears in the following versions.

@totaam
Copy link
Collaborator Author

totaam commented Apr 3, 2017

2017-04-03 19:28:42: Denis01 commented


Version html5-2.0.1-2.15507

system reacts on keyboard change (in tray or by hot-keys) but after the switch EN->RU cyrrilic symbols are not treated properly - nothing appears and remote application considers the symbols typied as key-combinations cnrt-F, cntr-C, etc
To restore it is needed to re-login with preferred language to use and not to change keyboard on-fly to avoid the problem appear

@totaam
Copy link
Collaborator Author

totaam commented Apr 4, 2017

"en" keys (latin keys really) are still mapped on a "ru" keyboard layout, which is why switching from "ru" to "en" works.
But many "ru" keys do not exist on an "en" keyboard layout, and so they cannot be mapped.

Sadly, there is no reliable way of detecting the current locale used for keyboard input. See "locale" in KeyboardEvent (only supported by IE)
And even the more convoluted layout detection code we have does not apply when the user changes the layout: if I call setxkbmap us on my client system, all the HTTP request headers and all the browser attributes still have my preferred locale first ("en_GB").
r15510 adds code to re-detect the keyboard layout whenever one of those properties changes, but it doesn't fire with chrome or Firefox. (not tested IE)

So I was starting to think that this could not be fixed without requiring user interaction and adding a language menu to the html5 toolbar. (planned in Xpra-org/xpra#1471)
But then it occurred to me that we can guess which keyboard layout is actually needed based on the keyname (ie: "Thai_thothan" requires a "Thai" or "th" keyboard layout), so r15511 does that.
With this change, the HTML5 client will request the server to switch to a new keyboard layout when it sees keys it knows belongs to a specific layout ("Greek", "Thai", "Cyrillic", "Hebrew", etc)


Notes:

  • there may be a slight delay as the change is aynchronous
  • we rate limit those changes to prevent server DOS
  • this will not switch back to the original layout when the user starts typing in "latin" again because we don't keep track of all the layouts we have used, only the current one
  • there's bound to be some corner cases, but this is likely to be as good as it is going to get given Javascript's API limitations

@totaam
Copy link
Collaborator Author

totaam commented Apr 5, 2017

2017-04-05 12:55:13: Denis01 commented


Hello,
had some fun with VPS provider on OS version :-) Now ready for tests

version 2.1-15507 64-bit
Linux CentOS Linux 7.3.1611
Chrome

it seems that everything works properly. En->Ru, Ru->En
Fantastic!
Closed

@totaam totaam closed this as completed Apr 5, 2017
@totaam
Copy link
Collaborator Author

totaam commented Jun 9, 2019

See also #65

@totaam totaam transferred this issue from Xpra-org/xpra Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant