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 639341 - altTab: use keybinding actions instead of clutter keysym comparison
altTab: use keybinding actions instead of clutter keysym comparison
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Dan Winship
gnome-shell-maint
: 596231 (view as bug list)
Depends on: 639532
Blocks:
 
 
Reported: 2011-01-12 18:51 UTC by Rui Matos
Modified: 2011-02-17 13:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add a way to switch among windows of the same application (2.20 KB, patch)
2011-01-12 18:51 UTC, Rui Matos
none Details | Review
Add a way to switch among windows of the same application (3.84 KB, patch)
2011-01-14 17:03 UTC, Rui Matos
none Details | Review
altTab: use switch_group and switch_windows keybinding actions (5.21 KB, patch)
2011-01-14 18:38 UTC, Rui Matos
none Details | Review
altTab: use switch_group and switch_windows keybinding actions (6.27 KB, patch)
2011-01-16 01:45 UTC, Rui Matos
none Details | Review
altTab: use switch_group and switch_windows keybinding actions (6.00 KB, patch)
2011-01-17 16:38 UTC, Rui Matos
none Details | Review
altTab: use cycle_group and switch_windows keybinding actions (5.99 KB, patch)
2011-01-25 18:58 UTC, Rui Matos
needs-work Details | Review
altTab: enable the cycle_group keybinding action (2.59 KB, patch)
2011-01-29 22:36 UTC, Rui Matos
none Details | Review
altTab: enable the cycle_group keybinding action (2.59 KB, patch)
2011-01-29 22:38 UTC, Rui Matos
needs-work Details | Review
altTab: use keybinding actions instead of clutter keysym comparison (3.15 KB, patch)
2011-01-29 22:41 UTC, Rui Matos
reviewed Details | Review
altTab: enable the switch_group keybinding action (2.59 KB, patch)
2011-02-02 19:45 UTC, Rui Matos
none Details | Review
altTab: use keybinding actions instead of clutter keysym comparison (3.25 KB, patch)
2011-02-02 19:46 UTC, Rui Matos
reviewed Details | Review
altTab: enable the switch_group keybinding action (2.59 KB, patch)
2011-02-02 19:46 UTC, Rui Matos
committed Details | Review
all-keybindings.h: change <Alt>Above_Tab from cycle_group to switch_group (1.49 KB, patch)
2011-02-02 19:57 UTC, Rui Matos
accepted-commit_now Details | Review
all-keybindings.h: change <Alt>Above_Tab from cycle_group to switch_group (1.49 KB, patch)
2011-02-10 17:29 UTC, Rui Matos
committed Details | Review
altTab: use keybinding actions instead of clutter keysym comparison (4.12 KB, patch)
2011-02-10 17:35 UTC, Rui Matos
committed Details | Review

Description Rui Matos 2011-01-12 18:51:08 UTC
This allows the keybinding /apps/metacity/global_keybindings/switch_group to
call the application switcher in "change application window mode" without the
user having to press Alt+Tab initially.
Comment 1 Rui Matos 2011-01-12 18:51:11 UTC
Created attachment 178167 [details] [review]
Add a way to switch among windows of the same application
Comment 2 Dan Winship 2011-01-12 20:07:26 UTC
of course, if you don't have a US keyboard, you'll have to use a different key once you get into the switcher...
Comment 3 Rui Matos 2011-01-13 18:12:50 UTC
(In reply to comment #2)
> of course, if you don't have a US keyboard, you'll have to use a different key
> once you get into the switcher...

This means that the whole AltTabPopup._keyPressEvent() function must be rewritten to not rely on clutter's key-press-event and instead do several Main.wm.setKeybindingHandler() and create the respective handlers ?
Comment 4 Dan Winship 2011-01-13 19:14:44 UTC
no, setKeybindingHandler() only affects what happens when there is no keyboard grab.

The fix is that rather than doing:

    if (keysym == Clutter.grave)
        this._select(this._currentApp, this._nextWindow());

it needs to do

    let keyCode = event.get_key_code();
    let modifierState = Shell.get_event_state(event);
    let display = global.screen.get_display();
    let action = display.get_keybinding_action(keyCode, modifierState);

    if (action == Meta.KeyBinding.Action.CYCLE_WINDOWS)
        this._select(this._currentApp, this._nextWindow());

etc
Comment 5 Rui Matos 2011-01-14 17:03:57 UTC
Created attachment 178334 [details] [review]
Add a way to switch among windows of the same application
Comment 6 Rui Matos 2011-01-14 17:11:24 UTC
(In reply to comment #5)

This patch should work better and be more elegant as you say. I've left open the question of handling SWITCH_WINDOWS/SWITCH_WINDOWS_BACKWARD instead of keysym == Clutter.Tab. Should I do that too? If yes, then what about Clutter.Escape, Clutter.Left, and so on?
Comment 7 Dan Winship 2011-01-14 17:47:36 UTC
the Clutter.Tab part should be switched to use keybinding_action. The rest (arrows, esc) is not configurable so there'd be no action to switch them to
Comment 8 Rui Matos 2011-01-14 18:38:24 UTC
Created attachment 178340 [details] [review]
altTab: use switch_group and switch_windows keybinding actions

Use metacity's keybinding actions switch_group and swicth_windows to "change
window" and "change application" respectively.
Comment 9 Rui Matos 2011-01-14 18:46:27 UTC
To test this you need:

$ gconftool-2 -s /apps/metacity/global_keybindings/switch_windows_backward -t string "<Shift><Alt>Tab"
$ gconftool-2 -s /apps/metacity/global_keybindings/switch_group -t string
"<Alt>Above_Tab"
$ gconftool-2 -s /apps/metacity/global_keybindings/switch_group_backward -t
string "<Shift><Alt>Above_Tab"
Comment 10 Rui Matos 2011-01-16 01:45:26 UTC
Created attachment 178418 [details] [review]
altTab: use switch_group and switch_windows keybinding actions

Use metacity's keybinding actions switch_group and switch_windows for "change
application window" and "change application" respectively.
Comment 11 Rui Matos 2011-01-16 01:52:28 UTC
Ok, now I think we're following metacity's behavior more closely by handling the shift key being pressed to reverse the meaning of the action. This way only the switch_group gconf key must be set to get the whole experience.
Comment 12 Rui Matos 2011-01-17 16:38:39 UTC
Created attachment 178526 [details] [review]
altTab: use switch_group and switch_windows keybinding actions

Use metacity's keybinding actions switch_group and switch_windows for "change
application window" and "change application" respectively.
Comment 13 Rui Matos 2011-01-17 16:43:31 UTC
I prefer this last version for 2 reasons:

1. It simplifies the code.

2. I personally find it useful to jump quickly to another application with a Tab press while a window thumbnail is selected instead of using the Up arrow or having to Tab through the whole thumbnail list until the last one to then select the following app.

Comments?
Comment 14 Rui Matos 2011-01-25 18:58:58 UTC
Created attachment 179311 [details] [review]
altTab: use cycle_group and switch_windows keybinding actions

Use metacity's keybinding actions cycle_group and switch_windows for "change
application window" and "change application" respectively.
Comment 15 Dan Winship 2011-01-27 19:06:47 UTC
Comment on attachment 179311 [details] [review]
altTab: use cycle_group and switch_windows keybinding actions

So, the current behavior of Tab being sometimes switch-app and sometimes switch-window is by design, and if you want to change it, you need to talk to the designers and get an OK on that. Otherwise, revert it back so that it works the way it did before. (You should still check for Meta.KeyBindingAction.SWITCH_WINDOWS rather than Clutter.Tab, just have it mean different things in the two different cases.)

>+                this._select (0, this._appIcons[0].cachedWindows.length - 1);

there should be no space between function name and "("

>+        } else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS) {
>+            this._select(shift ? this._previousApp() : this._nextApp());
>+        } else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD) {
>+            this._select(shift ? this._nextApp() : this._previousApp());

this is redundant. Either get_keybinding_action() takes shift into account for you (so you don't need to check it yourself) or it doesn't (so you don't need to handle SWITCH_WINDOWS_BACKWARD).
Comment 16 Rui Matos 2011-01-27 19:30:00 UTC
(In reply to comment #15)
> (From update of attachment 179311 [details] [review])
> So, the current behavior of Tab being sometimes switch-app and sometimes
> switch-window is by design, and if you want to change it, you need to talk to
> the designers and get an OK on that.

OK, I'm adding the ui-review keyword.

> Otherwise, revert it back so that it works
> the way it did before. (You should still check for
> Meta.KeyBindingAction.SWITCH_WINDOWS rather than Clutter.Tab, just have it mean
> different things in the two different cases.)

I'm not checking for Clutter.Tab anywhere in this latest patch. Am I missing something?

> 
> >+                this._select (0, this._appIcons[0].cachedWindows.length - 1);
> 
> there should be no space between function name and "("

Sure, will fix.

> 
> >+        } else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS) {
> >+            this._select(shift ? this._previousApp() : this._nextApp());
> >+        } else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD) {
> >+            this._select(shift ? this._nextApp() : this._previousApp());
> 
> this is redundant. Either get_keybinding_action() takes shift into account for
> you (so you don't need to check it yourself) or it doesn't (so you don't need
> to handle SWITCH_WINDOWS_BACKWARD).

Well, this is how metacity does it too. Check mutter's src/core/keybindings.c:process_tab_grab()

I agree it sucks because we already have both a switch_windows and a switch_windows_reversed. But if we are to use those then the gconf default for switch_windows_reversed has to be changed from disabled to <Shift><Alt>Tab. Analogously for cycle_group[_reversed].
Comment 17 Rui Matos 2011-01-28 12:29:06 UTC
Regarding the design question, my opinion is that the current behavior of Tab iterating through apps or windows depending on the context isn't much predictable and thus prone to misuses and frustration. So, now that we have a nice way to know about the key above tab, I think it works better if we do only one thing on each key since it's more predictable.
Comment 18 Rui Matos 2011-01-29 22:36:50 UTC
Created attachment 179614 [details] [review]
altTab: enable the cycle_group keybinding action

Allows the user to bring up the Alt+Tab popup with the current application's
window thumbnails selected.
Comment 19 Rui Matos 2011-01-29 22:38:28 UTC
Created attachment 179615 [details] [review]
altTab: enable the cycle_group keybinding action

Allows the user to bring up the Alt+Tab popup with the current application's
window thumbnails selected.
Comment 20 Rui Matos 2011-01-29 22:41:44 UTC
Created attachment 179616 [details] [review]
altTab: use keybinding actions instead of clutter keysym comparison

Use keybinding actions instead of clutter keysym comparisons to select
next/prev application and next/prev window.
Comment 21 Rui Matos 2011-01-29 22:57:24 UTC
Sorry for the bug spam. I'm still learning to use git-bz.

Attachment 179616 [details] should actually be first and doesn't change behavior. Although, to handle the shift case, I think something like:

diff --git a/src/include/all-keybindings.h b/src/include/all-keybindings.h
index 643a123..16db7ac 100644
--- a/src/include/all-keybindings.h
+++ b/src/include/all-keybindings.h
@@ -156,7 +156,7 @@ keybind (switch_windows,            handle_switch,        META_TAB_LIST_NORMAL,
          BINDING_REVERSES,       "<Alt>Tab",
         _("Move between windows, using a popup window"))
 keybind (switch_windows_backward,  handle_switch,        META_TAB_LIST_NORMAL,
-         REVERSES_AND_REVERSED,  NULL,
+         REVERSES_AND_REVERSED,  "<Shift><Alt>Tab",
         _("Move backward between windows, using a popup window"))
 keybind (switch_panels,             handle_switch,        META_TAB_LIST_DOCKS,
          BINDING_REVERSES,       "<Control><Alt>Tab",
@@ -170,7 +170,7 @@ keybind (cycle_group,               handle_cycle,         META_TAB_LIST_GROUP,
         BINDING_REVERSES,        "<Alt>Above_Tab",
         _("Move between windows of an application immediately"))
 keybind (cycle_group_backward,     handle_cycle,         META_TAB_LIST_GROUP,
-        REVERSES_AND_REVERSED,   NULL,
+        REVERSES_AND_REVERSED,   "<Shift><Alt>Above_Tab",
         _("Move backward between windows of an application immediately"))
 keybind (cycle_windows,             handle_cycle,         META_TAB_LIST_NORMAL,
         BINDING_REVERSES,        "<Alt>Escape",

should be committed to mutter. Else, something like I had in the previous patch must be added on top of this to implement the BINDING_REVERSES semantics like metacity does.

The second patch (attachment 179615 [details] [review]) just adds the possibility of triggering the window switcher without having to press Alt+Tab first.

The behavior changing part I'll leave out for now until we have design input and I can then open a new bug for it.
Comment 22 Owen Taylor 2011-01-30 21:29:04 UTC
(assigning to Dan for continued review of the keybinding handling portions)
Comment 23 Dan Winship 2011-01-31 16:17:13 UTC
Comment on attachment 179615 [details] [review]
altTab: enable the cycle_group keybinding action

Hm... this is odd. It's using the cycle_group keybinding, but the behavior is that of switch_group. ("cycle" = switch immediately, "switch" = select via pop-up window).

Assuming we're going to keep this UI, we should probably move the binding in metacity/mutter to switch_group, and then update this patch to use that.

Beyond that, the only problem I see is that if the app only has a single window, then Alt-Above_Tab should probably be a no-op, just like Alt-Tab is if you only have a single application open.
Comment 24 Dan Winship 2011-01-31 16:18:17 UTC
Comment on attachment 179616 [details] [review]
altTab: use keybinding actions instead of clutter keysym comparison

this is good, subject to the same cycle-vs-switch issue as the other bug
Comment 25 Rui Matos 2011-01-31 16:27:10 UTC
(In reply to comment #23)
> (From update of attachment 179615 [details] [review])
> Hm... this is odd. It's using the cycle_group keybinding, but the behavior is
> that of switch_group. ("cycle" = switch immediately, "switch" = select via
> pop-up window).

Right, on first patches I submitted to this bug I was actually using the switch_* keybindings, but then I changed it to cycle_* since that's what Owen chose as default for Alt+Above_Tab in the mutter patch:

http://git.gnome.org/browse/mutter/commit/?id=4ea00e102b6afe25e2b84f9def2f44da1b4953c6

I don't really care either way.

What about the BINDING_REVERSES semantics?

And, btw, currently, in a jhbuild environment where you already have a system metacity installed the user must configure the keybindings in gconf for them to work. How should that be handled? Oh, and I'm assuming that mutter's all-keybindings.h defaults are actually used if metacity's gconf keys aren't installed, right?
Comment 26 Dan Winship 2011-02-02 15:36:07 UTC
(In reply to comment #25)
> Right, on first patches I submitted to this bug I was actually using the
> switch_* keybindings, but then I changed it to cycle_* since that's what Owen
> chose as default for Alt+Above_Tab in the mutter patch:

Right. He assumed we were going to do the UI OS X style, where Alt+Above_Tab switched windows instantly, which corresponds to cycle_group in metacity. But what you implemented uses the pop-up switcher, which would be switch_group. So, if we're keeping this UI, we should change metacity/mutter to put the binding on switch_group.

Owen, want to try this patch out and see if you like the behavior?

> What about the BINDING_REVERSES semantics?

It's a mutter bug, but not in the place you pointed out. meta_display_get_keybinding_action() ought to be noticing the BINDING_REVERSES flag (or rather, the flag that that flag gets turned into later, IIRC), and returning the correct reversed keybinding when Shift is down. (That's the way it works in other places in mutter.)

> And, btw, currently, in a jhbuild environment where you already have a system
> metacity installed the user must configure the keybindings in gconf for them to
> work. How should that be handled?

Not sure. I'd suggested adding metacity to gnome-shell's jhbuild before.
Comment 27 Owen Taylor 2011-02-02 16:19:56 UTC
Trying this out, the good thing about it is that it handles windows on other workspaces well (also minimized/hidden windows)

The bad thing is that if you have an application with a bunch of very similar looking windows - like a bunch of terminals, the small previews arent' a very good way to tell them apart - and if they were raised as a group and all visible to you it's a bit silly that you are staring at tiny little thumbnails to try and figure out which is which instead of just waiting until the window you want to focus - that you can just look at - is focused.

I guess my inclination is that we should go with this change (and the accompanying mutter/metacity changes to the key bindings) so that we have something that is consistent and complete - so we don't have to solve:

 - Windows on other workspaces
 - Maybe hidden windows
 - Getting rid of the weird indicator rectangle that Mutter is drawing currently on cycle_group

Some other way, though I'm not really sold on this being the best possible user interface.
Comment 28 Rui Matos 2011-02-02 19:45:16 UTC
Created attachment 179917 [details] [review]
altTab: enable the switch_group keybinding action

Allows the user to bring up the Alt+Tab popup with the current application's
window thumbnails selected.
Comment 29 Rui Matos 2011-02-02 19:46:36 UTC
Created attachment 179918 [details] [review]
altTab: use keybinding actions instead of clutter keysym comparison

Use keybinding actions instead of clutter keysym comparisons to select
next/prev application and next/prev window.
Comment 30 Rui Matos 2011-02-02 19:46:40 UTC
Created attachment 179919 [details] [review]
altTab: enable the switch_group keybinding action

Allows the user to bring up the Alt+Tab popup with the current application's
window thumbnails selected.
Comment 31 Rui Matos 2011-02-02 19:57:25 UTC
Created attachment 179920 [details] [review]
all-keybindings.h: change <Alt>Above_Tab from cycle_group to switch_group
Comment 32 Dan Winship 2011-02-10 16:19:25 UTC
Comment on attachment 179918 [details] [review]
altTab: use keybinding actions instead of clutter keysym comparison

>+        let shift = event_state & Clutter.ModifierType.SHIFT_MASK;

call it "backwards" instead of "shift"; it will make things clearer below

>-        if (keysym == Clutter.grave)
>+        if (action == Meta.KeyBindingAction.SWITCH_GROUP && !shift)
>             this._select(this._currentApp, this._nextWindow());
>-        else if (keysym == Clutter.asciitilde)
>+        else if (action == Meta.KeyBindingAction.SWITCH_GROUP && shift)
>             this._select(this._currentApp, this._previousWindow());

I think it would be clearer to squash these. Eg,

    if (action == Meta.KeyBindingAction.SWITCH_GROUP)
        this._select(this._currentApp, backwards ? this._previousWindow() : this._nextWindow());

>+            if (action == Meta.KeyBindingAction.SWITCH_WINDOWS && !shift) {
>                 if (this._currentWindow == this._appIcons[this._currentApp].cachedWindows.length - 1)

and in this case, "if (action == Meta.KeyBindingAction.SWITCH_WINDOWS)" first, and then "if (backwards)" inside it.
Comment 33 Dan Winship 2011-02-10 16:20:18 UTC
Comment on attachment 179919 [details] [review]
altTab: enable the switch_group keybinding action

this is good to commit once the other stuff is in. (Do you have git bits or do you need us to commit it?)
Comment 34 Dan Winship 2011-02-10 16:20:58 UTC
Comment on attachment 179920 [details] [review]
all-keybindings.h: change <Alt>Above_Tab from cycle_group to switch_group

Owen, what do we do here wrt metacity? Do we need to discuss this change with them, or just commit it?
Comment 35 Owen Taylor 2011-02-10 17:11:59 UTC
Just commit it, but make sure to put cycle-group back to the old alt-f6 or whaver it was keybinding (haven't looked at the patch to see if it does that)
Comment 36 Rui Matos 2011-02-10 17:29:56 UTC
Created attachment 180607 [details] [review]
all-keybindings.h: change <Alt>Above_Tab from cycle_group to switch_group
Comment 37 Rui Matos 2011-02-10 17:35:10 UTC
Created attachment 180608 [details] [review]
altTab: use keybinding actions instead of clutter keysym comparison

Use keybinding actions instead of clutter keysym comparisons to select
next/prev application and next/prev window.
Comment 38 Dan Winship 2011-02-15 19:04:08 UTC
Attachment 179919 [details] pushed as a047132 - altTab: enable the switch_group keybinding action
Attachment 180608 [details] pushed as 1bc8052 - altTab: use keybinding actions instead of clutter keysym comparison
Comment 39 drago01 2011-02-17 13:17:05 UTC
*** Bug 596231 has been marked as a duplicate of this bug. ***