Getting a St.Bin to refresh its position?



Hi all,

I'm trying to make a workspace switcher like the gnome-panel 2.X one
for gnome-shell: it's very much like the workspaces sidebar in the
overview, except that it lives in your top panel, only window icons
are shown (as opposed to the window thumbnail) and the desktop
background is not shown. So basically you get a real-time graphical
representation of the windows in each workspace, where each window is
really just a rectangle.

In essence my problem is that I have a WindowClone class (a
rectangle), and although I update its x and y position, I do not
*visually* see the rectangle change position like it should.
I want to do `windowClone.x = newx; windowClone.y = newy;` and see the
results instantly.

Further detail:

I have a Shell.GenericContainer() which sits in the top panel and
contains all the workspaces.

Each workspace is a St.Bin that takes up whatever space the
Shell.GenericContainer() allocates it.

The child of each workspace St.Bin is a St.Group.

In each workspace, I have one WindowClone per window in the workspace.
A WindowClone is a (styled) St.Bin that tracks the
position/size/minimized state of its underlying window (very much like
the WindowClone classes in workspaceThumbnail.js and workspace.js).

So, what happens is that the WindowClone tracks the size-changed and
position-changed events of its base window, and when that happens, it
sets the St.Bin's x, y, width and height accordingly.

My problem is that although the x/y/width/height get updated, I do not
*see* the change - the St.Bin that corresponds to my window does not
appear to change position within its workspace.

The only way I've found to get around this is to call
.queue_relayout() on the Shell.GenericContainer that contains the
workspaces (that contains the windows).

This means each window has to store a reference to the
great-grandparent Shell.GenericContainer so that whenever a
size-changed or position-changed event fires, I can call

    this.grandParent.queue_relayout()

so that I can visually see the window St.Bin change its position.

My questions are:
* should this be happening? in workspaceThumbnails.js, the
ThumbnailsBox is a Shell.GenericContainer containing
WorkspaceThumbnails (a Clutter.Group in a St.Group) containing
WindowClones (Clutter.Clone). When these WindowClones update their
position they do *not* have to call .queue_relayout() on the
Shell.GenericContainer, and their position is visually updated. So why
do I have to?
* if this *should* be happening, is the only way for me to get the
desired effect to store a pointer to the Shell.GenericContainer in
each WindowClone so that I can call .queue_relayout() on the
appropriate window events? It doesn't seem right that the WindowClone
should have to know about its great-grandparent in order to be
displayed correectly?
* is there a way for me to call WindowClone.propogate_queue_relayout()
such that the queue_relayout() request gets relayed up all the way to
the Shell.GenericContainer without me having to store the pointer
myself? This seems like a better way for it to be done (and calling
.queue_relayout() on the Window St.Bin and/or the Workspace
St.Group/St.Bin does not have the desired effect; only calling it on
the Shell.GenericContainer seems to cause the window St.Bins to be
repainted).

I notice that if I add a St.Bin directly to (say) global.stage,
updating its x/y causes *instant* relayout, so it must be something to
do with the way I've parented everything. I suspect the
Shell.GenericContainer.

cheers.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]