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 691414 - status/keyboard: Add input source switching per window
status/keyboard: Add input source switching per window
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on: 691413
Blocks:
 
 
Reported: 2013-01-09 13:31 UTC by Rui Matos
Modified: 2013-01-14 10:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
status/keyboard: Add input source switching per window (3.56 KB, patch)
2013-01-09 13:31 UTC, Rui Matos
reviewed Details | Review
status/keyboard: Only change the current source setting if it changed (1.13 KB, patch)
2013-01-09 13:31 UTC, Rui Matos
none Details | Review
status/keyboard: Only change the current source setting if it changed (1.11 KB, patch)
2013-01-09 17:54 UTC, Rui Matos
committed Details | Review
status/keyboard: Add input source switching per window (4.83 KB, patch)
2013-01-12 17:42 UTC, Rui Matos
reviewed Details | Review
display: Expose meta_display_list_windows (2.96 KB, patch)
2013-01-12 17:45 UTC, Rui Matos
rejected Details | Review
status/keyboard: Add input source switching per window (4.79 KB, patch)
2013-01-12 19:03 UTC, Rui Matos
committed Details | Review

Description Rui Matos 2013-01-09 13:31:21 UTC
Patches attached.
Comment 1 Rui Matos 2013-01-09 13:31:24 UTC
Created attachment 233067 [details] [review]
status/keyboard: Add input source switching per window

If the setting is enabled, we record the last activated input source
for the currently focused window and switch to it when focusing back
that window.
Comment 2 Rui Matos 2013-01-09 13:31:29 UTC
Created attachment 233068 [details] [review]
status/keyboard: Only change the current source setting if it changed

This avoids all the work that goes on in various processes when
switching input sources if the activated source if the currently
configured one.
Comment 3 Jasper St. Pierre (not reading bugmail) 2013-01-09 14:27:57 UTC
Review of attachment 233068 [details] [review]:

Huh, I thought gsettings did this check for us.
Comment 4 Rui Matos 2013-01-09 14:29:49 UTC
(In reply to comment #3)
> Review of attachment 233068 [details] [review]:
> 
> Huh, I thought gsettings did this check for us.

Me too, but it doesn't.
Comment 5 Jasper St. Pierre (not reading bugmail) 2013-01-09 14:30:36 UTC
Review of attachment 233067 [details] [review]:

I'm afraid of this because it's state that we lose if we crash the Shell. Should we set an Xorg property on the window so we can get it back? _GNOME_PRIV_INPUT_SOURCE ?

::: js/ui/status/keyboard.js
@@ +743,3 @@
+    _sourcesPerWindowChanged: function() {
+        this._sourcesPerWindow = this._settings.get_boolean('per-window');
+        if (this._sourcesPerWindow && this._focusWindowNotifyId == 0) {

I wonder if we should lose the input sources stored on each window?
Comment 6 Rui Matos 2013-01-09 17:54:43 UTC
Created attachment 233094 [details] [review]
status/keyboard: Only change the current source setting if it changed

--

Not asking the GSettings object looks tidier though.
Comment 7 Rui Matos 2013-01-12 17:42:52 UTC
Created attachment 233311 [details] [review]
status/keyboard: Add input source switching per window

--
* Added the Overview as another "window".

(In reply to comment #5)
> Review of attachment 233067 [details] [review]:
>
> I'm afraid of this because it's state that we lose if we crash the Shell.
> Should we set an Xorg property on the window so we can get it back?
> _GNOME_PRIV_INPUT_SOURCE ?

I think that's too much trouble for something that's basically
transient state which the user can easily get back to.

> ::: js/ui/status/keyboard.js
> @@ +743,3 @@
> +    _sourcesPerWindowChanged: function() {
> +        this._sourcesPerWindow = this._settings.get_boolean('per-window');
> +        if (this._sourcesPerWindow && this._focusWindowNotifyId == 0) {
>
> I wonder if we should lose the input sources stored on each window?

Yeah, I think it's better to do that indeed. Done here now.
Comment 8 Rui Matos 2013-01-12 17:45:55 UTC
Created attachment 233312 [details] [review]
display: Expose meta_display_list_windows

This is useful to quickly get at all the MetaWindow instances.
--

The shell patch depends on this. Did I miss a way to get at all the
windows already existing somewhere else?
Comment 9 Jasper St. Pierre (not reading bugmail) 2013-01-12 17:59:27 UTC
global.get_window_actors().map(function(x) {
    return x.meta_window;
});

or similar is what we do already, which isn't really good. If you want to add MetaDisplay.list_windows(), I'm fine with it. At some point we should probably kill a lot of the code that uses get_window_actors to get a MetaWindow.
Comment 10 Jasper St. Pierre (not reading bugmail) 2013-01-12 18:01:42 UTC
Review of attachment 233312 [details] [review]:

OK. Bonus points if you quickly swap out the quickly greppable instances of get_window_actors() in the shell codebase.
Comment 11 Jasper St. Pierre (not reading bugmail) 2013-01-12 18:04:24 UTC
Review of attachment 233094 [details] [review]:

When could 'activate' get sent when it's already active?
Comment 12 Rui Matos 2013-01-12 18:11:02 UTC
(In reply to comment #11)
> Review of attachment 233094 [details] [review]:
> 
> When could 'activate' get sent when it's already active?

Clicking the corresponding panel menu entry or using the new AltTab-like switcher and choosing the same entry.
Comment 13 Jasper St. Pierre (not reading bugmail) 2013-01-12 18:16:21 UTC
Review of attachment 233311 [details] [review]:

::: js/ui/status/keyboard.js
@@ +722,3 @@
+    },
+
+    _setPerWindowInputSource: function() {

Can we share some of this with _changePerWindowSource?

@@ +735,3 @@
+            window._inputSources = this._inputSources;
+            window._currentSource = this._currentSource;
+            return;

I'd prefer this to be:

    if (window._inputSources == null) {
        // ...
    } else if (window._inputSources == this._inputSources) {
        // ...
    } else {
        // ...
    }

Makes the behavior much more obvious.

@@ +782,3 @@
+        let window;
+        if (Main.overview.visible)
+            window = Main.overview;

Should we do it for the message tray, too? Modal dialogs?

    let focusable;
    if (global.display.focus_window != null)
        focusable = global.display.focus_window;
    else
        focusable = global.stage.key_focus;

The hard thing is to drop sources when the setting changes. One easy idea is to add a counter that increments whenever the setting changes, so if we detect that the focusable's counter is out of date, we don't respect the value.
Comment 14 Rui Matos 2013-01-12 18:37:39 UTC
(In reply to comment #13)
> @@ +782,3 @@
> +        let window;
> +        if (Main.overview.visible)
> +            window = Main.overview;
> 
> Should we do it for the message tray, too? Modal dialogs?

We probably should but I haven't come up with a solution for that yet. See below.

>     let focusable;
>     if (global.display.focus_window != null)
>         focusable = global.display.focus_window;
>     else
>         focusable = global.stage.key_focus;

This doesn't really work for 2 reasons. global.display.focus_window is not null when the input focus is on the COW and global.stage.key_focus is actually either the panel menu entry that the user is activating or the AltTab-like switcher item. Do you have suggestions to overcome this?
Comment 15 Rui Matos 2013-01-12 19:01:07 UTC
Comment on attachment 233312 [details] [review]
display: Expose meta_display_list_windows

Other places that are using global.get_window_actors() are relying on the stack ordering on that list so they can't be just ported to meta_display_list_windows() so I'm just going to use global.get_window_actors() here too instead of introducing another method needlessly.
Comment 16 Rui Matos 2013-01-12 19:03:22 UTC
Created attachment 233319 [details] [review]
status/keyboard: Add input source switching per window

--
(In reply to comment #13)
> +    _setPerWindowInputSource: function() {
>
> Can we share some of this with _changePerWindowSource?

Like this?

> I'd prefer this to be:
>
>     if (window._inputSources == null) {
>         // ...
>     } else if (window._inputSources == this._inputSources) {
>         // ...
>     } else {
>         // ...
>     }
>
> Makes the behavior much more obvious.

Ok.
Comment 17 Jasper St. Pierre (not reading bugmail) 2013-01-12 21:23:55 UTC
Review of attachment 233319 [details] [review]:

OK.
Comment 18 Jasper St. Pierre (not reading bugmail) 2013-01-12 21:24:12 UTC
Review of attachment 233094 [details] [review]:

OK.
Comment 19 Rui Matos 2013-01-14 10:14:43 UTC
Attachment 233094 [details] pushed as ca44977 - status/keyboard: Only change the current source setting if it changed
Attachment 233319 [details] pushed as 16bb9c1 - status/keyboard: Add input source switching per window