After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730628 - gnome-shell could disable IME on password dialog
gnome-shell could disable IME on password dialog
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: system-status
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2014-05-23 10:24 UTC by Takao Fujiwara
Modified: 2015-01-12 16:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for keyboard.js (3.86 KB, patch)
2014-05-23 10:27 UTC, Takao Fujiwara
none Details | Review
Patch for keyboard.js (3.95 KB, patch)
2014-10-31 05:54 UTC, Takao Fujiwara
needs-work Details | Review
Patch for ibusManager.js (6.32 KB, patch)
2014-11-20 02:30 UTC, Takao Fujiwara
needs-work Details | Review
Patch for ibusManager.js (6.90 KB, patch)
2014-11-27 08:25 UTC, Takao Fujiwara
committed Details | Review

Description Takao Fujiwara 2014-05-23 10:24:18 UTC
ibus 1.5.7 can send the gtk+ input purpose to panel.
https://github.com/ibus/ibus/commit/6ca5ddb302c98e52c78326ed0dfaaf90481d4d8c

IME preedit text should be disabled on password mode for the security reason.
Someone wishes gnome-shell panel disables IME so that each IME developer does not have to implement it.
Comment 1 Takao Fujiwara 2014-05-23 10:27:35 UTC
Created attachment 277045 [details] [review]
Patch for keyboard.js

Attached the patch.
Comment 2 Takao Fujiwara 2014-10-31 05:54:15 UTC
Created attachment 289712 [details] [review]
Patch for keyboard.js

Updated the patch for HEAD.
Currently I have no idea to bring back the ibus engine by manual.
Comment 3 Rui Matos 2014-11-04 15:06:28 UTC
Review of attachment 289712 [details] [review]:

Please include the file you're modifying in the commit subject, e.g. ibusManager: ... or status/keyboard: ...

I think a more elegant way to do this is to add a flag like InputSourceManager._disableIBus or so and then set or unset it when we get the set-content-type signal according to the input purpose and just call InputSourceManager.reload().

Then, when building the runtime list of input sources in _inputSourcesChanged() we can skip the IBus sources when that flag says so.
Comment 4 Takao Fujiwara 2014-11-20 02:30:13 UTC
Created attachment 291048 [details] [review]
Patch for ibusManager.js

Revised the patch.
This patch can disable IMEs on password dialogs.
Super+space shows XKB only but right click on panel shows all engines.
Comment 5 Rui Matos 2014-11-24 18:11:05 UTC
Review of attachment 291048 [details] [review]:

The subject would be more accurate written as "... Disable IBus input sources on password entries"

Note that for this to work correctly we'll need an ibus fix. See

https://codereview.appspot.com/176260043/

::: js/misc/ibusManager.js
@@ +126,3 @@
             this._candidatePopup.setPanelService(this._panelService);
             this._panelService.connect('update-property', Lang.bind(this, this._updateProperty));
+            this._panelService.connect('set-content-type', Lang.bind(this, this._setContentType));

We should only connect this signal if the ibus version is new enough to include the fix I mentioned above.

::: js/ui/status/keyboard.js
@@ +157,2 @@
         this._currentSource = null;
+        this._backupSourceForPassword = null;

Let's just call this _backupSource

@@ +401,3 @@
+                this._mruSources[0].activate();
+            }
+        }

This can more succinctly be written like:

        if (!this._disableIBus && this._backupSource) {
            for (let i = 0; i < this._mruSources.length; i++) {
                if (this._mruSources[i].type == this._backupSource.type &&
                    this._mruSources[i].id == this._backupSource.id) {                                                              
                    let currentSource = this._mruSources.splice(i, 1);
	            this._mruSources = currentSource.concat(this._mruSources);
                    break;
                }
            }
            this._backupSource = null;
	}

and leave the activate() call as it is.

@@ +460,3 @@
+    _ibusSetContentType: function(im, purpose, hints) {
+        if (purpose == IBus.InputPurpose.PASSWORD ||
+            purpose == IBus.InputPurpose.PIN ) {

Why PIN ?

@@ +470,3 @@
+            }
+            if (!hasXkbSources)
+                return;

All of this hasXkbSources check can be as simple as:

	    if (Object.keys(this._inputSources).length == Object.keys(this._ibusSources).length)
                return;

@@ +481,3 @@
+            this._disableIBus = false;
+        }
+        this._mruSources = [];

Clearing _mruSources doesn't seem to needed. Did you think of any special reason to do it?
Comment 6 Takao Fujiwara 2014-11-27 08:25:15 UTC
Created attachment 291617 [details] [review]
Patch for ibusManager.js

Updated the patch.
Comment 7 Takao Fujiwara 2014-11-27 08:37:00 UTC
(In reply to comment #5)
> Review of attachment 291048 [details] [review]:
> @@ +460,3 @@
> +    _ibusSetContentType: function(im, purpose, hints) {
> +        if (purpose == IBus.InputPurpose.PASSWORD ||
> +            purpose == IBus.InputPurpose.PIN ) {
> 
> Why PIN ?

I thought PIN is a secure key. OK, I removed it.

> @@ +470,3 @@
> +            }
> +            if (!hasXkbSources)
> +                return;
> 
> All of this hasXkbSources check can be as simple as:
> 
>         if (Object.keys(this._inputSources).length ==
> Object.keys(this._ibusSources).length)
>                 return;

Great. Thanks.

> @@ +481,3 @@
> +            this._disableIBus = false;
> +        }
> +        this._mruSources = [];
> 
> Clearing _mruSources doesn't seem to needed. Did you think of any special
> reason to do it?

I added some comments in the source file.
If this._mruSources is not cleared, IM sources will be appended to XKB sources after the lock screen is unlocked.

E.g. the order is IM1, XKB1, IM2, XKB2, IM3 before lock the screen and it will be IM1, XKB1, XKB2, IM2, IM3 after unlock the screen.
Comment 8 Rui Matos 2015-01-07 17:27:36 UTC
Review of attachment 291617 [details] [review]:

With the comment below addressed this is a-c-n. Thanks

::: js/misc/ibusManager.js
@@ +126,3 @@
+                this._panelService.connect('set-content-type', Lang.bind(this, this._setContentType));
+            } catch (e) {
+                log('Disable set-content-type signal: ' + e);

There's no need to log this IMO, most of the functionality is still working anyway so let's remain silent here.

OTOH, I'd like to see a comment here and also in the commit message explaining why we don't do this for older ibus versions.