xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2154: html-layout-change-back-v4.patch

File html-layout-change-back-v4.patch, 3.0 KB (added by Antoine Martin, 2 years ago)

updated patch

  • html5/js/Client.js

     
    627627
    628628XpraClient.prototype._check_browser_language = function(key_layout) {
    629629        /**
    630          * Use the "key_language" if we have it,
    631          * otherwise use the browser's language.
    632          * This function may ssend the new detected keyboard layout.
     630         * This function may send the new detected keyboard layout.
    633631         * (ignoring the keyboard_layout preference)
    634632         */
    635633        var now = Utilities.monotonicTime();
     
    637635                return;
    638636        }
    639637        var new_layout = null;
    640         if (key_layout && this.key_layout!=key_layout) {
    641                 this.clog("input language changed from", this.key_layout, "to", key_layout);
     638        if (key_layout) {
    642639                new_layout = key_layout;
    643                 this.key_layout = key_layout;
    644640        }
    645641        else {
     642                //we may have used a different layout for a specific key,
     643                //and now this new key doesn't need it anymore,
     644                //so we may want to switch back to the original layout:
    646645                var l = Utilities.getFirstBrowserLanguage();
    647646                if (l && this.browser_language != l) {
     647                        //if the browser language has changed,
     648                        //this takes precedence over the configuration
     649                        this.clog("browser language changed from", this.browser_language, "to", l);
     650                        this.browser_language = l;
    648651                        new_layout = Utilities.getKeyboardLayout();
    649                         this.clog("browser language changed from", this.browser_language, "to", l, ", sending new keyboard layout:", layout);
    650                         this.browser_language = l;
    651652                }
     653                else {
     654                        //this will honour the setting supplied by the user on the connect page
     655                        //or default to Utilities.getKeyboardLayout()
     656                        new_layout = this._get_keyboard_layout() || "us";
     657                }
    652658        }
    653         if (new_layout!=null) {
     659        if (new_layout!=null && this.key_layout!=new_layout) {
     660                this.key_layout = new_layout;
     661                this.clog("keyboard layout changed from", this.key_layout, "to", key_layout);
    654662                this.send(["layout-changed", new_layout, ""]);
    655663                //changing the language too quickly can cause problems server side,
    656                 //wait at least 2 seconds before checking again:
    657                 this.browser_language_change_embargo_time = now + 2000;
     664                //wait a bit before checking again:
     665                this.browser_language_change_embargo_time = now + 1000;
    658666        }
    659667        else {
    660668                //check again after 100ms minimum
     
    11251133        }
    11261134        this.desktop_width = this.container.clientWidth;
    11271135        this.desktop_height = this.container.clientHeight;
     1136        this.key_layout = this._get_keyboard_layout();
    11281137        this._update_capabilities({
    11291138                "auto_refresh_delay"            : 500,
    11301139                "randr_notify"                          : true,
     
    11971206                "windows"                                       : true,
    11981207                //partial support:
    11991208                "keyboard"                                      : true,
    1200                 "xkbmap_layout"                         : this._get_keyboard_layout(),
     1209                "xkbmap_layout"                         : this.key_layout,
    12011210                "xkbmap_keycodes"                       : this._get_keycodes(),
    12021211                "xkbmap_print"                          : "",
    12031212                "xkbmap_query"                          : "",
     
    12951304        ctx.do_window_mouse_move(e, window);
    12961305}
    12971306XpraClient.prototype.do_window_mouse_move = function(e, window) {
    1298         this._check_browser_language();
    12991307        if (this.server_readonly || this.mouse_grabbed || !this.connected) {
    13001308                return;
    13011309        }