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 673198 - workspacesDisplay: Connect to 'notify::n-workspaces' early
workspacesDisplay: Connect to 'notify::n-workspaces' early
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:
Blocks:
 
 
Reported: 2012-03-30 17:41 UTC by Florian Müllner
Modified: 2012-06-01 15:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
workspacesDisplay: Connect to 'notify::n-workspaces' early (2.54 KB, patch)
2012-03-30 17:41 UTC, Florian Müllner
reviewed Details | Review
workspacesDisplay: Connect to 'notify::n-workspaces' early (3.00 KB, patch)
2012-03-31 07:18 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2012-03-30 17:41:08 UTC
Fix a corner case for the workspace switcher:

 1. gsettings set org.gnome.desktop.wm.preferences num-workspaces 2
 2. place windows on two workspaces to make the switcher pop out
 3. restart with alt-f2 r

Expected behavior:
  The workspace switcher is zoomed out when entering the overview

Actual result:
  The workspace switcher is hidden
Comment 1 Florian Müllner 2012-03-30 17:41:11 UTC
Created attachment 210987 [details] [review]
workspacesDisplay: Connect to 'notify::n-workspaces' early

Currently we only connect to the 'notify::n-workspaces' signal the
first time the overview is shown, which means we will miss any
changes to the workspace layout in the meanwhile.
In particular, the decision of whether the workspace switcher should be
shown is taken before the dynamic workspace handling takes over, and is
thus based entirely on the value of the num-workspaces user preference
rather than the actual number of workspaces.
Just connect the signal in _init() (with the nice side-effect to make it
explicit that the signal handler won't ever be disconnected).
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-03-30 17:56:37 UTC
Review of attachment 210987 [details] [review]:

I'm not sure I like this patch. The only effect of connecting to the signal in _init is to make sure that _updateAlwaysZoom is called, but we could do that before in show(), right?
Comment 3 Florian Müllner 2012-03-30 18:11:31 UTC
(In reply to comment #2)
> I'm not sure I like this patch. The only effect of connecting to the signal in
> _init is to make sure that _updateAlwaysZoom is called, but we could do that
> before in show(), right?

If you mean something like

  if (this._nWorkspacesChangedId == 0)
      this._updateAlwaysZoom();

then yes, that's what my original patch did. I don't think it's particularly obvious to use the signal handler id like that, but it works.

Just doing it unconditionally would work as well of course, but every call except for the very first would be unnecessary, which just doesn't feel right :)
Comment 4 Jasper St. Pierre (not reading bugmail) 2012-03-30 18:25:18 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > I'm not sure I like this patch. The only effect of connecting to the signal in
> > _init is to make sure that _updateAlwaysZoom is called, but we could do that
> > before in show(), right?
> 
> If you mean something like
> 
>   if (this._nWorkspacesChangedId == 0)
>       this._updateAlwaysZoom();
> 
> then yes, that's what my original patch did. I don't think it's particularly
> obvious to use the signal handler id like that, but it works.

Yeah, I didn't like it either.

> Just doing it unconditionally would work as well of course, but every call
> except for the very first would be unnecessary, which just doesn't feel right
> :)

I think that's the cleaner approach.

Alternate suggestion:

    _workspacesChanged: function() {
        // We need to keep track of _alwaysZoomOut even before
        // workspaces exist, in order to make sure that our first
        // trip to the overview is handled correctly.
        this._updateAlwaysZoom();

        if (this._workspaces == null)
            return;

        ...
    }
Comment 5 Florian Müllner 2012-03-31 07:18:42 UTC
Created attachment 211019 [details] [review]
workspacesDisplay: Connect to 'notify::n-workspaces' early

(In reply to comment #4)
> Alternate suggestion:
> 
>     _workspacesChanged: function() {
>         // We need to keep track of _alwaysZoomOut even before
>         // workspaces exist, in order to make sure that our first
>         // trip to the overview is handled correctly.
>         this._updateAlwaysZoom();

That looks best to me - it gets rid of the oldNumWorkspaces == newNumWorkspaces optimization, but the whole test seems rather pointless anyway.

I left out the comment though, as I think it's misleading (we need to always keep track of _alwaysZoomOut, even when we bail out early because the overview is hidden - it just happens that we already did that correctly after the overview had been shown once)
Comment 6 Jasper St. Pierre (not reading bugmail) 2012-06-01 11:41:48 UTC
Review of attachment 211019 [details] [review]:

Yes.
Comment 7 Florian Müllner 2012-06-01 15:35:45 UTC
Attachment 211019 [details] pushed as 76005f5 - workspacesDisplay: Connect to 'notify::n-workspaces' early