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 688913 - Proposal to move the alternate-tab extension into core
Proposal to move the alternate-tab extension into core
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
: 656651 (view as bug list)
Depends on: 689528
Blocks: 685744
 
 
Reported: 2012-11-23 06:22 UTC by Florian Müllner
Modified: 2014-04-26 19:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
schemas: Add new 'switch-applications' keybinding (2.61 KB, patch)
2012-11-23 06:22 UTC, Florian Müllner
reviewed Details | Review
Add 'switch-applications' keybinding (9.71 KB, patch)
2012-11-23 06:23 UTC, Florian Müllner
rejected Details | Review
altTab: Use 'switch-applications' for app switcher (3.22 KB, patch)
2012-11-23 06:24 UTC, Florian Müllner
accepted-commit_now Details | Review
altTab: Minor code cleanup (1.60 KB, patch)
2012-11-23 06:24 UTC, Florian Müllner
committed Details | Review
altTab: Use more generic names in AltTabPopup (19.44 KB, patch)
2012-11-23 06:24 UTC, Florian Müllner
reviewed Details | Review
altTab: Re-implement 'switch-windows' keybinding (15.36 KB, patch)
2012-11-23 06:24 UTC, Florian Müllner
needs-work Details | Review
display: Make workspace parameter to get_tab_list() optional (3.26 KB, patch)
2012-12-03 18:01 UTC, Florian Müllner
needs-work Details | Review
altTab: Use 'switch-applications' for app switcher (3.21 KB, patch)
2012-12-03 18:03 UTC, Florian Müllner
committed Details | Review
altTab: Rename AltTabPopup to AppSwitcherPopup (1.49 KB, patch)
2012-12-03 18:04 UTC, Florian Müllner
committed Details | Review
altTab: Re-implement 'switch-windows' keybinding (10.32 KB, patch)
2012-12-03 18:12 UTC, Florian Müllner
needs-work Details | Review
display: Make workspace parameter to get_tab_list() optional (5.08 KB, patch)
2012-12-03 22:26 UTC, Florian Müllner
none Details | Review
display: Make workspace parameter to get_tab_list() optional (4.41 KB, patch)
2012-12-03 22:37 UTC, Florian Müllner
none Details | Review
display: Clean up meta_display_get_tab_list() (3.57 KB, patch)
2012-12-03 23:11 UTC, Florian Müllner
committed Details | Review
display: Make workspace parameter to get_tab_list() optional (3.76 KB, patch)
2012-12-03 23:11 UTC, Florian Müllner
reviewed Details | Review
mockup (297.24 KB, image/png)
2012-12-03 23:38 UTC, Allan Day
  Details
Screenshot of updated switcher (471.58 KB, image/png)
2012-12-04 01:03 UTC, Florian Müllner
  Details
display: Make workspace parameter to get_tab_list() optional (3.90 KB, patch)
2012-12-04 10:15 UTC, Florian Müllner
none Details | Review
altTab: Re-implement 'switch-windows' keybinding (11.45 KB, patch)
2012-12-04 10:18 UTC, Florian Müllner
reviewed Details | Review
display: Make workspace parameter to get_tab_list() optional (3.89 KB, patch)
2012-12-04 10:27 UTC, Florian Müllner
needs-work Details | Review
display: Make workspace parameter to get_tab_list() optional (3.93 KB, patch)
2012-12-04 14:58 UTC, Florian Müllner
reviewed Details | Review
altTab: Factor out thumbnail creation (2.24 KB, patch)
2012-12-04 15:31 UTC, Florian Müllner
committed Details | Review
altTab: Re-implement 'switch-windows' keybinding (10.81 KB, patch)
2012-12-04 15:44 UTC, Florian Müllner
accepted-commit_now Details | Review
display: Make workspace parameter to get_tab_list() optional (3.98 KB, patch)
2012-12-04 16:57 UTC, Florian Müllner
committed Details | Review
altTab: Re-implement 'switch-windows' keybinding (10.77 KB, patch)
2012-12-04 17:12 UTC, Florian Müllner
committed Details | Review
Add 'switch-applications' keybinding (7.90 KB, patch)
2012-12-04 18:30 UTC, Florian Müllner
committed Details | Review
Add 'switch-windows-real' keybinding (5.40 KB, patch)
2012-12-04 18:56 UTC, Florian Müllner
none Details | Review
schemas: Add new 'switch-applications' keybinding (3.10 KB, patch)
2012-12-05 16:03 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2012-11-23 06:22:44 UTC
It's no big secret that there are a lot of complaints about the application switcher, so it might just make sense to offer a bit more flexibility in core itself. I actually came up with this approach quite a while ago, but didn't get myself to write the actual code (until now) - rather than adding a hidden option to swap out the existing switcher, a new 'switch-application' keybinding is added, which defaults to <alt>tab and triggers the existing switcher. The existing 'switch-windows' keybinding is then free to be used for a more traditional window switcher, which users can activate by setting up a keyboard shortcut in Settings - with that, users can even choose to use both switchers (e.g. using <alt>tab and <super>tab).
(selfish as I am, I hope that this is a better solution for people that depend on the current workspace special-casing in the app-switcher and we can land bug 661156 without too much hurt)
Comment 1 Florian Müllner 2012-11-23 06:22:48 UTC
Created attachment 229689 [details] [review]
schemas: Add new 'switch-applications' keybinding

GNOME Shell currently uses the 'switch-windows' keybinding for its
application switcher, although it does not switch between windows
but applications (duh!).
Add a new dedicated keybinding instead, which will free 'switch-windows'
to be used for window switching again. People unhappy with the Shell's
alt-tab popup may then use it instead of (or in addition to!) the
application-based switcher.
Comment 2 Florian Müllner 2012-11-23 06:23:34 UTC
Created attachment 229690 [details] [review]
Add 'switch-applications' keybinding

Add an additional "switcher" keybinding for switching between
applications rather than windows (like the existing 'switch-windows'
and 'switch-group' bindings).
The current implementation is only a stub, which is enough to be taken
over by gnome-shell for its application-based alt-tab popup - if anyone
feels the urge to actually implement an application switcher in mutter,
be my guest ... :-)
Comment 3 Florian Müllner 2012-11-23 06:24:42 UTC
Created attachment 229692 [details] [review]
altTab: Use 'switch-applications' for app switcher

The Shell's alt-tab popup is application-based, so using the
'switch-windows' keybinding for it never really made sense.
Use the newly added 'switch-applications' keybinding instead.
Comment 4 Florian Müllner 2012-11-23 06:24:47 UTC
Created attachment 229693 [details] [review]
altTab: Minor code cleanup
Comment 5 Florian Müllner 2012-11-23 06:24:52 UTC
Created attachment 229694 [details] [review]
altTab: Use more generic names in AltTabPopup

The alt-tab popup is currently strictly application-based, which is
reflected in its property/method names - first level items are "apps",
second level items "windows". However we are going to reintroduce a
window-based switcher with windows as first level items, so to avoid
the oddity of referring to those windows as "apps", use the more generic
terms "item" and "subitem".
Comment 6 Florian Müllner 2012-11-23 06:24:57 UTC
Created attachment 229695 [details] [review]
altTab: Re-implement 'switch-windows' keybinding

Now that we use the new 'switch-applications' keybinding for the
application-based alt-tab popup, we can use the 'switch-windows'
keybinding for a more traditional switcher.

Based heavily on the alternate-tab extension from Giovanni Campagna.
Comment 7 Florian Müllner 2012-11-23 06:26:55 UTC
In case anyone is wondering, first patch applies to gsettings-desktop-schemas, the second one to mutter, everything else is gnome-shell.
Comment 8 Jasper St. Pierre (not reading bugmail) 2012-11-23 06:59:44 UTC
Review of attachment 229689 [details] [review]:

How will this help / hurt migration? Those who assigned 'switch-windows' to a custom key binding may get screwed, right?
Comment 9 Jasper St. Pierre (not reading bugmail) 2012-11-23 07:01:54 UTC
Review of attachment 229690 [details] [review]:

WTF count is now 1. No.

::: src/core/display.c
@@ +4657,3 @@
 }
 
 #define IN_TAB_CHAIN(w,t) (((t) == META_TAB_LIST_NORMAL && META_WINDOW_IN_NORMAL_TAB_CHAIN (w)) \

This macro needs to be shot in the head and replaced with a function with a switch statement.

::: src/core/window-private.h
@@ +609,3 @@
   (((w)->input || (w)->take_focus ) && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) && (!(w)->skip_taskbar))
+#define META_WINDOW_IN_APPLICATION_TAB_CHAIN(w) \
+  FALSE /* not implemented */

OK, WTF
Comment 10 Jasper St. Pierre (not reading bugmail) 2012-11-23 07:02:30 UTC
Review of attachment 229692 [details] [review]:

Sure.
Comment 11 Jasper St. Pierre (not reading bugmail) 2012-11-23 07:03:39 UTC
Review of attachment 229693 [details] [review]:

How did this ever originally pass review?
Comment 12 Jasper St. Pierre (not reading bugmail) 2012-11-23 07:05:08 UTC
Review of attachment 229694 [details] [review]:

::: js/ui/altTab.js
@@ +193,1 @@
+        this._icons = this._switcher.icons;

Not a fan of the name "icons". Given how we have this._currentItem, might we have this._items that we're switching between?
Comment 13 Jasper St. Pierre (not reading bugmail) 2012-11-23 07:20:17 UTC
Review of attachment 229695 [details] [review]:

::: js/ui/altTab.js
@@ +37,3 @@
+};
+
+

Extra whitespace.

@@ +77,3 @@
         this._initialDelayTimeoutId = 0;
 
+        this._applicationBased = true;

eek

@@ +179,3 @@
+        let settings = new Gio.Settings({ schema: 'org.gnome.shell.window-switcher' });
+	if (!settings.get_boolean('current-workspace-only')) {
+	    // This is roughly what meta_display_get_tab_list does, except

Implement this in mutter, not in here. Notes below are extras.

@@ +182,3 @@
+	    // that it doesn't filter on workspace
+	    // See in particular src/core/window-private.h for the filters
+	    windows = global.get_window_actors().map(function(actor) {

Not a fan of using the window actor list instead of the list of non-transient windows that mutter already keeps

@@ +187,3 @@
+		return !win.is_override_redirect() &&
+		    win.get_window_type() != Meta.WindowType.DESKTOP &&
+		    win.get_window_type() != Meta.WindowType.DOCK;

Skip taskbar hint doesn't seem to be handled?

@@ +197,3 @@
+
+        // Filter away attached modal dialogs (switch to their parents instead)
+        return windows.filter(function(win) { return !win.is_attached_dialog(); });

Doesn't get_tab_list do this automatically? Shouldn't this only be the case for the get_window_actors case?

@@ +202,2 @@
     show : function(backward, binding, mask) {
+        this._applicationBased = (binding != 'switch-windows' &&

Given that the way this works, we create a new AltTabPopup, and then immediately call show with some arguments, it might make sense to move those some arguments into the constructor or something similar, rather than having the constructor fill in a bunch of bogus values.

@@ +370,3 @@
                 else
                     this._select(this._currentItem, this._previousSubitem());
+            } else if (this._applicationBased) {

I'd prefer this as:

    } else {
        if (this._applicationBased) {
            // ...
        } else {
            // ...
        }
    }

@@ +385,3 @@
                 else
                     this._select(this._currentItem, this._nextSubitem());
+            } else if (this._applicationBased) {

ditto

@@ +1206,3 @@
+        let settings = new Gio.Settings({ schema: 'org.gnome.shell.window-switcher' });
+	switch (settings.get_enum('app-icon-mode')) {
+	case AppIconMode.THUMBNAIL_ONLY:

I'm not sure this is any of our current styles for switch statements. Mind looking around and seeing exactly how inconsistent we are?

@@ +1214,3 @@
+                                             x_align: Clutter.ActorAlign.CENTER,
+                                             y_align: Clutter.ActorAlign.CENTER,
+                                             // usual hack for the usual bug in ClutterBinLayout...

this is like an inside joke at this point

@@ +1223,3 @@
+	    scale = Math.min(1.0, 128 / width, 128 / height);
+	    size = 128;
+            this.clone = new Clutter.Clone({ source: windowTexture,

refactor out into createClone() method or use flags or group switch statements or something

@@ +1246,3 @@
+	    if (this.app) {
+		this.appIcon = this.app.create_icon_texture(size);
+		this.appIcon.x_expand = this.appIcon.y_expand = true;

lol
Comment 14 Allan Day 2012-11-23 08:47:53 UTC
I don't have a problem with this in general, but can we please review the design before it lands? I've tried the alternative alt-tab extension. The experience isn't good enough for the core.
Comment 15 Jasper St. Pierre (not reading bugmail) 2012-11-23 16:59:28 UTC
(In reply to comment #14)
> I don't have a problem with this in general, but can we please review the
> design before it lands? I've tried the alternative alt-tab extension. The
> experience isn't good enough for the core.

I agree. Instead of popping up asking you to choose a mode, this provides:

  * A dedicated "switch windows" keybinding which switches windows, not applications

  * A GSettings key to determine what to display in the switcher: app icons, window thumbnails, or both.

  * A GSettings key about whether to care about windows on other workspaces or not.
Comment 16 Florian Müllner 2012-11-23 17:16:55 UTC
(In reply to comment #15)
> I agree. Instead of popping up asking you to choose a mode [...]

To be fair, I tried the extension before copy+pasting it, and it doesn't do that anymore. Nowadays it's pretty much a partly copy of AltTabPopup + the hunks > 3-4 lines in the last patch.
Comment 17 Florian Müllner 2012-11-23 17:18:23 UTC
(In reply to comment #14)
> I don't have a problem with this in general, but can we please review the
> design before it lands?

Oh, and of course we can do that - if we don't include it in core like this, it'll be part of the fallback-extensions set, so one way or another it'll need design review anyway :-)
Comment 18 Matthias Clasen 2012-11-28 16:29:03 UTC
So, what is this waiting for, design review ?
Comment 19 Florian Müllner 2012-11-30 19:07:04 UTC
Comment on attachment 229693 [details] [review]
altTab: Minor code cleanup

Attachment 229693 [details] pushed as cb08bd2 - altTab: Minor code cleanup
Comment 20 Florian Müllner 2012-12-03 18:01:42 UTC
Created attachment 230550 [details] [review]
display: Make workspace parameter to get_tab_list() optional

Currently meta_display_get_tab_list() will only return windows on
a single workspace. Make the workspace parameter optional to allow
requesting windows from all workspaces.
Comment 21 Florian Müllner 2012-12-03 18:03:43 UTC
Created attachment 230552 [details] [review]
altTab: Use 'switch-applications' for app switcher

Rebased onto bug 689528
Comment 22 Florian Müllner 2012-12-03 18:04:11 UTC
Created attachment 230553 [details] [review]
altTab: Rename AltTabPopup to AppSwitcherPopup

We will add support for a window-based popup in addition to the
current application-based one, so use a more descriptive name.
Comment 23 Florian Müllner 2012-12-03 18:12:44 UTC
Created attachment 230554 [details] [review]
altTab: Re-implement 'switch-windows' keybinding

(In reply to comment #13)
> Doesn't get_tab_list do this automatically? Shouldn't this only be the case for
> the get_window_actors case?

No, because the extension uses TabList.NORMAL_ALL instead of TabList.NORMAL - no idea why, the latter should be just fine.


> @@ +202,2 @@
>      show : function(backward, binding, mask) {
> +        this._applicationBased = (binding != 'switch-windows' &&
> 
> Given that the way this works, we create a new AltTabPopup, and then
> immediately call show with some arguments, it might make sense to move those
> some arguments into the constructor or something similar, rather than having
> the constructor fill in a bunch of bogus values.

Actually, with Rui's work in bug 689528 it is easier to just use separate classes altogether ...


> I'm not sure this is any of our current styles for switch statements. Mind
> looking around and seeing exactly how inconsistent we are?

Heh, the first patch version was just the extension code copy-pasted into altTab.js - at least I removed the most blatant cases of tabs/spaces mixups ;-)
Comment 24 Jasper St. Pierre (not reading bugmail) 2012-12-03 18:16:15 UTC
Review of attachment 230550 [details] [review]:

Eek. We moved away from MRU for other things, but I sort of left it in the alt-tab code out of laziness more than anything. Bonus points if you make it use the workspace stacking order rather than MRU.

::: src/core/display.c
@@ +4802,3 @@
+      GSList *w;
+
+      // Yay for mixing GList and GSList in the API

We should probably fix that.
Comment 25 Florian Müllner 2012-12-03 18:19:11 UTC
(In reply to comment #9)
> Review of attachment 229690 [details] [review]:
> 
> WTF count is now 1. No.

So before I'm going to address this - am I understanding you correctly that you want the new keybinding added *without* a mutter patch? Or are we using different definitions of "rejected"?
Comment 26 Florian Müllner 2012-12-03 18:21:17 UTC
(In reply to comment #8)
> How will this help / hurt migration? Those who assigned 'switch-windows' to a
> custom key binding may get screwed, right?

Yes. The only way I see around this is leaving 'switch-windows' as-is (switching windows in metacity/mutter and applications in gnome-shell) and add a new keybinding for the window-based switcher in gnome-shell ('switch-windows-no-really-i-mean-it-this-time' - ugh)
Comment 27 Florian Müllner 2012-12-03 18:23:08 UTC
(In reply to comment #24)
> Eek. We moved away from MRU for other things, but I sort of left it in the
> alt-tab code out of laziness more than anything. Bonus points if you make it
> use the workspace stacking order rather than MRU.

Sure, but not really related to either this patch or this bug report. Not a priority I'd say :-)
Comment 28 Jasper St. Pierre (not reading bugmail) 2012-12-03 18:33:20 UTC
(In reply to comment #25)
> (In reply to comment #9)
> > Review of attachment 229690 [details] [review] [details]:
> > 
> > WTF count is now 1. No.
> 
> So before I'm going to address this - am I understanding you correctly that you
> want the new keybinding added *without* a mutter patch? Or are we using
> different definitions of "rejected"?

I mean "this patch is so bad I am not allowing it in this form". Maybe we should have some common definitions of what the review statuses are supposed to mean, because I just use a sliding scale based on quality:

   * ================ * ================ * ================ *
rejected          needs_work          reviewed      accepted-commit_now
Comment 29 Florian Müllner 2012-12-03 18:39:27 UTC
(In reply to comment #28)
> I mean "this patch is so bad I am not allowing it in this form".

Ah, so we *are* using different definitions - for me:

  "not in this form" == "needs-work"
  "not in any form"  == "rejected"
Comment 30 drago01 2012-12-03 20:09:20 UTC
(In reply to comment #29)
> (In reply to comment #28)
> > I mean "this patch is so bad I am not allowing it in this form".
> 
> Ah, so we *are* using different definitions - for me:
> 
>   "not in this form" == "needs-work"
>   "not in any form"  == "rejected"

Yeah that has been my understanding as well.
Comment 31 Jasper St. Pierre (not reading bugmail) 2012-12-03 21:08:43 UTC
(In reply to comment #27)
> (In reply to comment #24)
> > Eek. We moved away from MRU for other things, but I sort of left it in the
> > alt-tab code out of laziness more than anything. Bonus points if you make it
> > use the workspace stacking order rather than MRU.
> 
> Sure, but not really related to either this patch or this bug report. Not a
> priority I'd say :-)

Right, but you're sort of making it worse, since you're mixing the two and doing a cmp on the user time, which we don't want to use.
Comment 32 Florian Müllner 2012-12-03 21:14:11 UTC
(In reply to comment #31)
> Right, but you're sort of making it worse, since you're mixing the two and
> doing a cmp on the user time, which we don't want to use.

Uhm - it's kinda hard to avoid? Or did we change the stack order to be independent from workspaces at some point?
Comment 33 Jasper St. Pierre (not reading bugmail) 2012-12-03 21:15:16 UTC
Yep. It swung back again to be not based on MRU lists.

http://git.gnome.org/browse/mutter/commit/?id=a3bf9b01aa7019798924b618160fcb184e096a3c
Comment 34 Jasper St. Pierre (not reading bugmail) 2012-12-03 21:17:05 UTC
(In reply to comment #23)
> Created an attachment (id=230554) [details] [review]
> altTab: Re-implement 'switch-windows' keybinding
> 
> (In reply to comment #13)
> > Doesn't get_tab_list do this automatically? Shouldn't this only be the case for
> > the get_window_actors case?
> 
> No, because the extension uses TabList.NORMAL_ALL instead of TabList.NORMAL -
> no idea why, the latter should be just fine.

Just checked. The regular alt-tab code does too. Was an bugfix because we didn't take the MRU of modal dialogs into account: see bug #667552 . If you can come up with a better solution, please do.
Comment 35 Florian Müllner 2012-12-03 21:32:32 UTC
(In reply to comment #33)
> Yep. It swung back again to be not based on MRU lists.
> 
> http://git.gnome.org/browse/mutter/commit/?id=a3bf9b01aa7019798924b618160fcb184e096a3c

What I mean is: just getting the list of windows from the stack will group them by workspace, which is not what we want in the popup, so I don't see how we can avoid sorting by user time.
Comment 36 Florian Müllner 2012-12-03 21:33:45 UTC
(I'm only referring to the case of listing windows from all workspaces of course, the other case is just fine)
Comment 37 Jasper St. Pierre (not reading bugmail) 2012-12-03 21:59:52 UTC
Hm. The server does keep a global stacking order, but I'm not sure that's what we want. Yeah, maybe sorting by global MRU is the lesser of all evils.
Comment 38 Jasper St. Pierre (not reading bugmail) 2012-12-03 22:01:13 UTC
Review of attachment 230550 [details] [review]:

::: src/core/display.c
@@ +4806,3 @@
+        mru_list = g_list_prepend (mru_list, w->data);
+      mru_list = g_list_sort (mru_list, mru_cmp);
+    }

else
  mru_list = workspace->mru_list;

This lets us skip the statements below.

@@ +4848,3 @@
 
+  if (workspace == NULL)
+    return tab_list;

Leaks mru_list.
Comment 39 Jasper St. Pierre (not reading bugmail) 2012-12-03 22:01:46 UTC
Review of attachment 230553 [details] [review]:

Sure.
Comment 40 Jasper St. Pierre (not reading bugmail) 2012-12-03 22:02:18 UTC
Review of attachment 230552 [details] [review]:

I think the regression issue is kind-of a big deal, but I'd prefer to get someone else's input
Comment 41 Jasper St. Pierre (not reading bugmail) 2012-12-03 22:09:30 UTC
Review of attachment 230554 [details] [review]:

::: js/ui/altTab.js
@@ +33,3 @@
+};
+
+

extra whitespace

@@ +36,1 @@
 const AppSwitcherPopup = new Lang.Class({

Regular app switcher needs to use WindowIcon, otherwise the app-icon-mode won't have any effect.

@@ +712,3 @@
+                                        vertical: true });
+        this.icon = null;
+        this._iconBin = new St.Widget({ layout_manager: new Clutter.BinLayout() });

Not a bin.

::: js/ui/windowManager.js
@@ +637,3 @@
+            this._workspaceSwitcherPopup.destroy();
+
+        let tabPopup = new AltTab.WindowSwitcherPopup();

I wonder what happens if both popups happen at once.

That should probably be handled globally, as I can imagine it can happen for CtrlAltTab as well, and for the new input method switcher.

We should probably have a Main.currentSwitcher or something.
Comment 42 Florian Müllner 2012-12-03 22:13:25 UTC
(In reply to comment #41)
> @@ +36,1 @@
>  const AppSwitcherPopup = new Lang.Class({
> 
> Regular app switcher needs to use WindowIcon, otherwise the app-icon-mode won't
> have any effect.

How does app-icon-mode make sense for the application-based switcher?
Comment 43 Jasper St. Pierre (not reading bugmail) 2012-12-03 22:24:13 UTC
Sorry, really out of it today.

I started off by thinking that the code that creates the window clones and app icons should be shared, and then decided to up it to "share WindowIcon", even though that makes no sense.
Comment 44 Florian Müllner 2012-12-03 22:26:51 UTC
Created attachment 230596 [details] [review]
display: Make workspace parameter to get_tab_list() optional

Fix leaks (both one noted in the review + the GSList that went unnoticed), switch to a more concise style
Comment 45 Jasper St. Pierre (not reading bugmail) 2012-12-03 22:33:34 UTC
Review of attachment 230596 [details] [review]:

The style changes make this impossible to review sanely. Keep those separate for now until we get a "-w" mode in Splinter, I guess.
Comment 46 Florian Müllner 2012-12-03 22:37:22 UTC
Created attachment 230600 [details] [review]
display: Make workspace parameter to get_tab_list() optional

Reattaching with -w
Comment 47 Florian Müllner 2012-12-03 22:43:13 UTC
Review of attachment 230600 [details] [review]:

::: src/core/display.c
@@ +4833,2 @@
     {
+      l_window=w->data;

Obviously needs to be
  MetaWindow *l_window ...
here - sorry, it's getting late here
Comment 48 Jasper St. Pierre (not reading bugmail) 2012-12-03 22:52:13 UTC
I guess I'd still prefer a style fixup patch afterwards.
Comment 49 Florian Müllner 2012-12-03 23:11:31 UTC
Created attachment 230601 [details] [review]
display: Clean up meta_display_get_tab_list()
Comment 50 Florian Müllner 2012-12-03 23:11:40 UTC
Created attachment 230602 [details] [review]
display: Make workspace parameter to get_tab_list() optional
Comment 51 Jasper St. Pierre (not reading bugmail) 2012-12-03 23:32:08 UTC
Review of attachment 230601 [details] [review]:

Of course.
Comment 52 Jasper St. Pierre (not reading bugmail) 2012-12-03 23:34:52 UTC
Review of attachment 230602 [details] [review]:

Works for me.

::: src/core/display.c
@@ +4799,3 @@
+  else
+    {
+      mru_list = g_list_copy (workspace->mru_list);

Hoping to prevent the copy, but I guess it's not that big of a deal.

You can do it somewhat cleanly like:

   GSList *free_mru_list = NULL;

   if (workspace == NULL)
     {
        free_mru_list = mru_list;
     }

   /* ... */

   g_slist_free (free_mru_list);

but with better names.

@@ +4830,3 @@
+   * other workspaces that demand attention
+   */
+  for (w = windows; workspace && w; w = w->next)

This is kind of sneaky. I'd prefer an explicit

if (workspace)
  {
  }
Comment 53 Allan Day 2012-12-03 23:38:47 UTC
Created attachment 230603 [details]
mockup

I've taken another look at the alternative alt-tab extension. It's generally OK, although there are two things that I think should be improved:

 1. Titles are displayed below every window, and they frequently get ellipsised. GNOME 2 solved this problem the same way that Windows did (and still does) - it only shows the title of the focused window. I'd recommend doing the same here.

 2. The application icons are way too big, and the positioning looks a bit off to me. 48x48px would be a more appropriate size.

A mockup is attached.
Comment 54 Florian Müllner 2012-12-04 01:03:26 UTC
Created attachment 230610 [details]
Screenshot of updated switcher

First shot of updating the switcher - there's a bit more padding above/below the label, OK anyway?
Comment 55 Allan Day 2012-12-04 09:06:07 UTC
Looks good to me. We might want to introduce more horizontal padding between the window thumbnails, too.
Comment 56 Florian Müllner 2012-12-04 10:15:24 UTC
Created attachment 230635 [details] [review]
display: Make workspace parameter to get_tab_list() optional

Updated according to review
Comment 57 Florian Müllner 2012-12-04 10:18:28 UTC
Created attachment 230636 [details] [review]
altTab: Re-implement 'switch-windows' keybinding

Updated according to mockup and review
Comment 58 Florian Müllner 2012-12-04 10:27:40 UTC
Created attachment 230637 [details] [review]
display: Make workspace parameter to get_tab_list() optional

Fix typo
Comment 59 Jasper St. Pierre (not reading bugmail) 2012-12-04 14:36:47 UTC
Review of attachment 230637 [details] [review]:

Getting closer.

::: src/core/display.c
@@ +4841,3 @@
+      }
+  else
+    g_list_free (mru_list);

Yeah, I was hoping to do it without depending on the state of the "workspace" variable.

I don't like it being in the same if statement. It's unrelated.
Comment 60 Jasper St. Pierre (not reading bugmail) 2012-12-04 14:49:36 UTC
Review of attachment 230636 [details] [review]:

::: js/ui/altTab.js
@@ +390,3 @@
+
+        this._switcherList = new WindowList(windows);
+        this._items = this._switcherList.icons;

"items = icons;" seems wrong.

@@ +709,3 @@
+        this.window = window;
+
+        this.actor = new St.BoxLayout({ style_class: 'alt-tab-app',

'alt-tab-item'

@@ +714,3 @@
+
+        this.actor.add(this._icon, { x_fill: false, y_fill: false } );
+        this.label = new St.Label({ text: window.get_title() });

Unused?

@@ +748,3 @@
+    },
+
+    _createWindowClone: function(window) {

Are you going to make these used for the main switcher as well, or?

We don't have to set_size in here.

@@ +813,3 @@
+        childBox.y2 = box.y2;
+        childBox.y1 = childBox.y2 - this._label.height;
+        this._label.allocate(childBox, flags);

We're just poorly reimplementing a BoxLayout here at this point, aren't we.

::: js/ui/windowManager.js
@@ +633,3 @@
 
+    _startWindowSwitcher : function(display, screen, window, binding) {
+        /* prevent a corner case where both popups show up at once */

As said in the last review, I'd like this to be handled centrally.
Comment 61 Florian Müllner 2012-12-04 14:58:11 UTC
Created attachment 230664 [details] [review]
display: Make workspace parameter to get_tab_list() optional

Currently meta_display_get_tab_list() will only return windows on
a single workspace. Make the workspace parameter optional to allow
requesting windows from all workspaces.
Comment 62 Florian Müllner 2012-12-04 14:58:54 UTC
(In reply to comment #59)
> I don't like it being in the same if statement. It's unrelated.

No, it's not - mru_list's memory is owned by the workspace if specified or owned by ourselves if not. I can only see two ways around this, one is to always allocate memory for mru_list (previous patch version), or to use different variables, which makes everything more verbose ...
Comment 63 Florian Müllner 2012-12-04 15:03:37 UTC
(In reply to comment #60)
> +        this.actor.add(this._icon, { x_fill: false, y_fill: false } );
> +        this.label = new St.Label({ text: window.get_title() });
> 
> Unused?

No.


> +
> +    _createWindowClone: function(window) {
> 
> Are you going to make these used for the main switcher as well, or?
> 
> We don't have to set_size in here.

Sigh. This is getting extremely unrelated to the scope of this bug.


> +    _startWindowSwitcher : function(display, screen, window, binding) {
> +        /* prevent a corner case where both popups show up at once */
> 
> As said in the last review, I'd like this to be handled centrally.

Is this actually more than a gut feeling? All the switcher popups are KeybindingMode.NONE, which means that once they are up, *all* keybindings (including any "competing" switchers) are blocked.
Comment 64 Florian Müllner 2012-12-04 15:06:13 UTC
(In reply to comment #60)
> +        this._switcherList = new WindowList(windows);
> +        this._items = this._switcherList.icons;
> 
> "items = icons;" seems wrong.

Oh, and just for the record: you considered the exact same line "a-c-n" in bug 689528 ;-)
Comment 65 Jasper St. Pierre (not reading bugmail) 2012-12-04 15:24:51 UTC
(In reply to comment #63)
> (In reply to comment #60)
> > +        this.actor.add(this._icon, { x_fill: false, y_fill: false } );
> > +        this.label = new St.Label({ text: window.get_title() });
> > 
> > Unused?
> 
> No.

Ah, it's used as the label_actor. Didn't see that. A rename to "a11yLabel" might be worthwhile.

> > +
> > +    _createWindowClone: function(window) {
> > 
> > Are you going to make these used for the main switcher as well, or?
> > 
> > We don't have to set_size in here.
> 
> Sigh. This is getting extremely unrelated to the scope of this bug.

We have time to do it right. I'd rather not have the same code duplicated throughout, when we can easily stuff it into a shared function.

> Is this actually more than a gut feeling? All the switcher popups are
> KeybindingMode.NONE, which means that once they are up, *all* keybindings
> (including any "competing" switchers) are blocked.

I keep forgetting that KeybindingMode.NONE means "all keybindings are blocked", I guess.
Comment 66 Florian Müllner 2012-12-04 15:30:31 UTC
(In reply to comment #65)
> Ah, it's used as the label_actor. Didn't see that. A rename to "a11yLabel"
> might be worthwhile.

It's used both as label_actor and to get the text of the currently selected window.
Comment 67 Florian Müllner 2012-12-04 15:31:57 UTC
Created attachment 230668 [details] [review]
altTab: Factor out thumbnail creation
Comment 68 Florian Müllner 2012-12-04 15:44:53 UTC
Created attachment 230669 [details] [review]
altTab: Re-implement 'switch-windows' keybinding

(In reply to comment #60)
> @@ +709,3 @@
> +        this.actor = new St.BoxLayout({ style_class: 'alt-tab-app',
> 
> 'alt-tab-item'

We don't actually use that style class at the moment, but if we did, I guess we'd want it to be shared with the app switcher, so I'll leave it as-is.


> +        childBox.y2 = box.y2;
> +        childBox.y1 = childBox.y2 - this._label.height;
> +        this._label.allocate(childBox, flags);
> 
> We're just poorly reimplementing a BoxLayout here at this point, aren't we.

Not really. In this case, the actor contains four children, three of them aligned horizontally at the top and one stretching all the bottom. Or in other words, if the parent class used a BoxLayout here, it would be horizontal and we'd need to jump through more hoops to implement the behavior in the mockup.


> ::: js/ui/windowManager.js
> +    _startWindowSwitcher : function(display, screen, window, binding) {
> +        /* prevent a corner case where both popups show up at once */
> 
> As said in the last review, I'd like this to be handled centrally.

As mentioned, the switcher popups block all other keybindings, so I'm leaving this as-is for now.
Comment 69 Jasper St. Pierre (not reading bugmail) 2012-12-04 16:06:41 UTC
Review of attachment 230668 [details] [review]:

What about app icons? Not worth it?
Comment 70 Jasper St. Pierre (not reading bugmail) 2012-12-04 16:09:59 UTC
Review of attachment 230669 [details] [review]:

Minor whitespace fixes, otherwise fine.

::: js/ui/altTab.js
@@ +735,3 @@
+            case AppIconMode.THUMBNAIL_ONLY:
+                size = WINDOW_PREVIEW_SIZE;
+                this._icon.add_actor(_createWindowClone(mutterWindow,

Shouldn't need wrapping now.

@@ +741,3 @@
+            case AppIconMode.BOTH:
+                size = WINDOW_PREVIEW_SIZE;
+                this._icon.add_actor(_createWindowClone(mutterWindow,

ditto
Comment 71 Jasper St. Pierre (not reading bugmail) 2012-12-04 16:10:54 UTC
Review of attachment 230664 [details] [review]:

I'd prefer the old patch.
Comment 72 Florian Müllner 2012-12-04 16:11:18 UTC
The app switcher uses a plain app.create_icon_texture(), so I'd say no.
Comment 73 Florian Müllner 2012-12-04 16:13:29 UTC
(In reply to comment #71)
> I'd prefer the old patch.

Which one? This is the 7th iteration.
Comment 74 Jasper St. Pierre (not reading bugmail) 2012-12-04 16:19:07 UTC
(In reply to comment #73)
> (In reply to comment #71)
> > I'd prefer the old patch.
> 
> Which one? This is the 7th iteration.

The one that does the:

    if (workspace)
      ...
    else
      g_list_free (mru_list);

I'm not the biggest fan, and I think the free_mru_list strategy would work really well, but you seem reluctant.
Comment 75 Florian Müllner 2012-12-04 16:27:19 UTC
(In reply to comment #74)
> I'm not the biggest fan, and I think the free_mru_list strategy would work
> really well, but you seem reluctant.

Uh? In what way does this differ from the current patch (except that I used a variable name of "mru_list" instead of "free_mru_list")?
Comment 76 Jasper St. Pierre (not reading bugmail) 2012-12-04 16:46:32 UTC
In the current patch, you do the "mru_list ? mru_list : workspace->mru_list" inline. I'm imagining that mru_list is set to an MRU list to traverse, and free_mru_list is set to a list to free. In the workspace == NULL case, mru_list and free_mru_list point to the newly built list, and in the otherwise case, mru_list is set to the workspace MRU list, but free_mru_list is set to NULL.
Comment 77 Florian Müllner 2012-12-04 16:57:36 UTC
Created attachment 230675 [details] [review]
display: Make workspace parameter to get_tab_list() optional

Fine, here's your bikeshed!
Comment 78 Jasper St. Pierre (not reading bugmail) 2012-12-04 17:04:46 UTC
Review of attachment 230675 [details] [review]:

Yay.
Comment 79 Jasper St. Pierre (not reading bugmail) 2012-12-04 17:05:05 UTC
Review of attachment 230668 [details] [review]:

OK.
Comment 80 Matthias Clasen 2012-12-04 17:06:55 UTC
Some quick feedback from trying this: 

when I have a single window, the one switcher pops up and shows me that one window, he other one just doesn't do anything, which makes it feel like it is broken.
Comment 81 Florian Müllner 2012-12-04 17:12:48 UTC
Created attachment 230678 [details] [review]
altTab: Re-implement 'switch-windows' keybinding

Interesting. This patch should fix the inconsistency.
Comment 82 Jasper St. Pierre (not reading bugmail) 2012-12-04 17:21:24 UTC
Review of attachment 230678 [details] [review]:

Two minor fixes, otherwise looks good.

::: js/ui/altTab.js
@@ +3,2 @@
 const Clutter = imports.gi.Clutter;
+const Gdk = imports.gi.Gdk;

Unused import.

@@ +4,3 @@
+const Gdk = imports.gi.Gdk;
+const Gio = imports.gi.Gio;
+const Gtk = imports.gi.Gtk;

Unused import.
Comment 83 Florian Müllner 2012-12-04 18:30:54 UTC
Created attachment 230685 [details] [review]
Add 'switch-applications' keybinding

Make the new keybinding an alias of 'switch-windows' instead of a stub.
Comment 84 Jasper St. Pierre (not reading bugmail) 2012-12-04 18:33:10 UTC
Review of attachment 230685 [details] [review]:

Sure.
Comment 85 Florian Müllner 2012-12-04 18:56:49 UTC
Created attachment 230687 [details] [review]
Add 'switch-windows-real' keybinding

GNOME Shell uses the existing 'switch-windows' keybindings to switch
between applications; in order to introduce a more traditional window
switcher as well, add an additional "switcher" keybinding.
As Mutter always switches between windows anyway, make it an alias to
the normal switcher when run standalone.

This is a slight variation of the "Add 'switch-applications' keybinding" patch; it leaves the 'switch-windows' keybindings alone and adds an additional one for the new window switcher, which means we won't interfere with existing settings (at the cost of some confusion when using dconf-editor/gsettings). If we go that route, the gsettings-desktop-schemas and "Use 'switch-applications' for app switcher" patches are obsolete and the window-switcher one needs some trivial adjustments.
Comment 86 Bastien Nocera 2012-12-05 16:02:36 UTC
Given that repurposing the switch-windows binding to do what it says would only affect people who changed the default, I'd say:
- Change the summary for switch-windows to match its name
- Add a switch-apps keybinding
- Switch the default between the 2 keys
- Repeat above steps for the backwards version
- Change the convert file to move the conversion from switch-windows to switch-apps with a comment
- Mention it in the release notes
Comment 87 Florian Müllner 2012-12-05 16:03:24 UTC
Created attachment 230778 [details] [review]
schemas: Add new 'switch-applications' keybinding

Also update the convert files as requested by hadess on IRC
Comment 88 Bastien Nocera 2012-12-05 16:04:40 UTC
Review of attachment 230778 [details] [review]:

Rest looks good.

::: schemas/wm-schemas.convert
@@ +44,3 @@
 switch-group = /apps/metacity/global_keybindings/switch_group
 switch-group-backward = /apps/metacity/global_keybindings/switch_group_backward
+switch-applications = /apps/metacity/global_keybindings/switch_windows

Missing comment here.
Comment 89 Florian Müllner 2012-12-05 17:46:12 UTC
Attachment 230601 [details] pushed as 3797eca - display: Clean up meta_display_get_tab_list()
Attachment 230675 [details] pushed as 8703dac - display: Make workspace parameter to get_tab_list() optional
Comment 90 Florian Müllner 2012-12-05 18:09:27 UTC
Comment on attachment 230778 [details] [review]
schemas: Add new 'switch-applications' keybinding

Attachment 230778 [details] pushed as 0f7a29d - schemas: Add new 'switch-applications' keybinding
Comment 91 Florian Müllner 2012-12-05 18:10:02 UTC
Comment on attachment 230685 [details] [review]
Add 'switch-applications' keybinding

Attachment 230685 [details] pushed as 2282326 - Add 'switch-applications' keybinding
Comment 92 Florian Müllner 2012-12-05 18:10:53 UTC
Attachment 230552 [details] pushed as 2fb1d70 - altTab: Use 'switch-applications' for app switcher
Attachment 230553 [details] pushed as aba4672 - altTab: Rename AltTabPopup to AppSwitcherPopup
Attachment 230668 [details] pushed as 525d3c2 - altTab: Factor out thumbnail creation
Attachment 230678 [details] pushed as e725f8a - altTab: Re-implement 'switch-windows' keybinding
Comment 93 Florian Müllner 2014-04-26 19:02:18 UTC
*** Bug 656651 has been marked as a duplicate of this bug. ***