workspaces-display: Make workspacesView private

WorkspacesDisplay was introduced to manage the workspace objects
and views; however, the overview still accesses the view held
by the workspacesDisplay directly, which is a bit odd.
Add some additional methods needed by the overview, and make the
view a private property.

https://bugzilla.gnome.org/show_bug.cgi?id=652580
This commit is contained in:
Florian Müllner 2011-11-26 00:02:13 +01:00
parent 10df80b96a
commit f2c79be11a
4 changed files with 60 additions and 65 deletions

View File

@ -108,7 +108,6 @@ const Overview = new Lang.Class({
if (this.isDummy) { if (this.isDummy) {
this.animationInProgress = false; this.animationInProgress = false;
this.visible = false; this.visible = false;
this.workspaces = null;
return; return;
} }
@ -180,8 +179,6 @@ const Overview = new Lang.Class({
this._lastActiveWorkspaceIndex = -1; this._lastActiveWorkspaceIndex = -1;
this._lastHoveredWindow = null; this._lastHoveredWindow = null;
this._needsFakePointerEvent = false; this._needsFakePointerEvent = false;
this.workspaces = null;
}, },
// The members we construct that are implemented in JS might // The members we construct that are implemented in JS might
@ -587,13 +584,10 @@ const Overview = new Lang.Class({
this._workspacesDisplay.show(); this._workspacesDisplay.show();
this.workspaces = this._workspacesDisplay.workspacesView;
global.overlay_group.add_actor(this.workspaces.actor);
if (!this._desktopFade.child) if (!this._desktopFade.child)
this._desktopFade.child = this._getDesktopClone(); this._desktopFade.child = this._getDesktopClone();
if (!this.workspaces.getActiveWorkspace().hasMaximizedWindows()) { if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows()) {
this._desktopFade.opacity = 255; this._desktopFade.opacity = 255;
this._desktopFade.show(); this._desktopFade.show();
Tweener.addTween(this._desktopFade, Tweener.addTween(this._desktopFade,
@ -728,7 +722,7 @@ const Overview = new Lang.Class({
this.animationInProgress = true; this.animationInProgress = true;
this._hideInProgress = true; this._hideInProgress = true;
if (!this.workspaces.getActiveWorkspace().hasMaximizedWindows()) { if (!this._workspacesDisplay.activeWorkspaceHasMaximizedWindows()) {
this._desktopFade.opacity = 0; this._desktopFade.opacity = 0;
this._desktopFade.show(); this._desktopFade.show();
Tweener.addTween(this._desktopFade, Tweener.addTween(this._desktopFade,
@ -737,7 +731,7 @@ const Overview = new Lang.Class({
transition: 'easeOutQuad' }); transition: 'easeOutQuad' });
} }
this.workspaces.hide(); this._workspacesDisplay.zoomFromOverview();
// Make other elements fade out. // Make other elements fade out.
Tweener.addTween(this._group, Tweener.addTween(this._group,
@ -779,9 +773,6 @@ const Overview = new Lang.Class({
global.window_group.show(); global.window_group.show();
this.workspaces.destroy();
this.workspaces = null;
this._workspacesDisplay.hide(); this._workspacesDisplay.hide();
this._desktopFade.hide(); this._desktopFade.hide();

View File

@ -419,29 +419,6 @@ const ViewSelector = new Lang.Class({
// not when setting the initially selected one. // not when setting the initially selected one.
if (!tab.visible) if (!tab.visible)
tab.show(!firstSwitch); tab.show(!firstSwitch);
// Pull a Meg Ryan:
if (!firstSwitch && Main.overview.workspaces) {
if (tab != this._tabs[0]) {
Tweener.addTween(Main.overview.workspaces.actor,
{ opacity: 0,
time: 0.1,
transition: 'easeOutQuad',
onComplete: Lang.bind(this,
function() {
Main.overview.workspaces.actor.hide();
Main.overview.workspaces.actor.opacity = 255;
})
});
} else {
Main.overview.workspaces.actor.opacity = 0;
Main.overview.workspaces.actor.show();
Tweener.addTween(Main.overview.workspaces.actor,
{ opacity: 255,
time: 0.1,
transition: 'easeOutQuad' });
}
}
}, },
switchTab: function(id) { switchTab: function(id) {

View File

@ -94,10 +94,11 @@ const ScaledPoint = new Lang.Class({
const WindowClone = new Lang.Class({ const WindowClone = new Lang.Class({
Name: 'WindowClone', Name: 'WindowClone',
_init : function(realWindow) { _init : function(realWindow, workspace) {
this.realWindow = realWindow; this.realWindow = realWindow;
this.metaWindow = realWindow.meta_window; this.metaWindow = realWindow.meta_window;
this.metaWindow._delegate = this; this.metaWindow._delegate = this;
this._workspace = workspace;
let [borderX, borderY] = this._getInvisibleBorderPadding(); let [borderX, borderY] = this._getInvisibleBorderPadding();
this._windowClone = new Clutter.Clone({ source: realWindow.get_texture(), this._windowClone = new Clutter.Clone({ source: realWindow.get_texture(),
@ -383,19 +384,12 @@ const WindowClone = new Lang.Class({
this.emit('drag-begin'); this.emit('drag-begin');
}, },
_getWorkspaceActor : function() {
let index = this.metaWindow.get_workspace().index();
return Main.overview.workspaces.getWorkspaceByIndex(index);
},
handleDragOver : function(source, actor, x, y, time) { handleDragOver : function(source, actor, x, y, time) {
let workspace = this._getWorkspaceActor(); return this._workspace.handleDragOver(source, actor, x, y, time);
return workspace.handleDragOver(source, actor, x, y, time);
}, },
acceptDrop : function(source, actor, x, y, time) { acceptDrop : function(source, actor, x, y, time) {
let workspace = this._getWorkspaceActor(); this._workspace.acceptDrop(source, actor, x, y, time);
workspace.acceptDrop(source, actor, x, y, time);
}, },
_onDragCancelled : function (draggable, time) { _onDragCancelled : function (draggable, time) {
@ -1386,7 +1380,7 @@ const Workspace = new Lang.Class({
// Create a clone of a (non-desktop) window and add it to the window list // Create a clone of a (non-desktop) window and add it to the window list
_addWindowClone : function(win) { _addWindowClone : function(win) {
let clone = new WindowClone(win); let clone = new WindowClone(win, this);
let overlay = new WindowOverlay(clone, this._windowOverlaysGroup); let overlay = new WindowOverlay(clone, this._windowOverlaysGroup);
clone.connect('selected', clone.connect('selected',

View File

@ -157,10 +157,6 @@ const WorkspacesView = new Lang.Class({
return this._workspaces[active]; return this._workspaces[active];
}, },
getWorkspaceByIndex: function(index) {
return this._workspaces[index];
},
hide: function() { hide: function() {
let activeWorkspaceIndex = global.screen.get_active_workspace_index(); let activeWorkspaceIndex = global.screen.get_active_workspace_index();
let activeWorkspace = this._workspaces[activeWorkspaceIndex]; let activeWorkspace = this._workspaces[activeWorkspaceIndex];
@ -462,6 +458,7 @@ const WorkspacesDisplay = new Lang.Class({
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate)); this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('parent-set', Lang.bind(this, this._parentSet));
this.actor.set_clip_to_allocation(true); this.actor.set_clip_to_allocation(true);
let controls = new St.Bin({ style_class: 'workspace-controls', let controls = new St.Bin({ style_class: 'workspace-controls',
@ -483,7 +480,7 @@ const WorkspacesDisplay = new Lang.Class({
this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox(); this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
controls.add_actor(this._thumbnailsBox.actor); controls.add_actor(this._thumbnailsBox.actor);
this.workspacesView = null; this._workspacesView = null;
this._inDrag = false; this._inDrag = false;
this._cancelledDrag = false; this._cancelledDrag = false;
@ -514,6 +511,7 @@ const WorkspacesDisplay = new Lang.Class({
this._windowDragBeginId = 0; this._windowDragBeginId = 0;
this._windowDragCancelledId = 0; this._windowDragCancelledId = 0;
this._windowDragEndId = 0; this._windowDragEndId = 0;
this._notifyOpacityId = 0;
}, },
show: function() { show: function() {
@ -530,10 +528,11 @@ const WorkspacesDisplay = new Lang.Class({
this._workspaces[i] = new Workspace.Workspace(metaWorkspace, this._monitorIndex); this._workspaces[i] = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
} }
if (this.workspacesView) if (this._workspacesView)
this.workspacesView.destroy(); this._workspacesView.destroy();
this.workspacesView = new WorkspacesView(this._workspaces); this._workspacesView = new WorkspacesView(this._workspaces);
this._updateWorkspacesGeometry(); this._updateWorkspacesGeometry();
global.overlay_group.add_actor(this._workspacesView.actor);
this._restackedNotifyId = this._restackedNotifyId =
global.screen.connect('restacked', global.screen.connect('restacked',
@ -564,6 +563,10 @@ const WorkspacesDisplay = new Lang.Class({
this._onRestacked(); this._onRestacked();
}, },
zoomFromOverview: function() {
this._workspacesView.hide();
},
hide: function() { hide: function() {
this._controls.hide(); this._controls.hide();
this._thumbnailsBox.hide(); this._thumbnailsBox.hide();
@ -597,14 +600,18 @@ const WorkspacesDisplay = new Lang.Class({
this._windowDragEndId = 0; this._windowDragEndId = 0;
} }
this.workspacesView.destroy(); this._workspacesView.destroy();
this.workspacesView = null; this._workspacesView = null;
for (let w = 0; w < this._workspaces.length; w++) { for (let w = 0; w < this._workspaces.length; w++) {
this._workspaces[w].disconnectAll(); this._workspaces[w].disconnectAll();
this._workspaces[w].destroy(); this._workspaces[w].destroy();
} }
}, },
activeWorkspaceHasMaximizedWindows: function() {
return this._workspacesView.getActiveWorkspace().hasMaximizedWindows();
},
// zoomFraction property allows us to tween the controls sliding in and out // zoomFraction property allows us to tween the controls sliding in and out
set zoomFraction(fraction) { set zoomFraction(fraction) {
this._zoomFraction = fraction; this._zoomFraction = fraction;
@ -675,8 +682,34 @@ const WorkspacesDisplay = new Lang.Class({
this._updateWorkspacesGeometry(); this._updateWorkspacesGeometry();
}, },
_parentSet: function(actor, oldParent) {
if (oldParent && this._notifyOpacityId)
oldParent.disconnect(this._notifyOpacityId);
this._notifyOpacityId = 0;
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
function() {
let newParent = this.actor.get_parent();
if (!newParent)
return;
// This is kinda hackish - we want the primary view to
// appear as parent of this.actor, though in reality it
// is added directly to overlay_group
this._notifyOpacityId = newParent.connect('notify::opacity',
Lang.bind(this, function() {
let opacity = this.actor.get_parent().opacity;
this._workspacesView.actor.opacity = opacity;
if (opacity == 0)
this._workspacesView.actor.hide();
else
this._workspacesView.actor.show();
}));
}));
},
_updateWorkspacesGeometry: function() { _updateWorkspacesGeometry: function() {
if (!this.workspacesView) if (!this._workspacesView)
return; return;
let fullWidth = this.actor.allocation.x2 - this.actor.allocation.x1; let fullWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
@ -697,7 +730,7 @@ const WorkspacesDisplay = new Lang.Class({
let clipX = rtl ? x + controlsVisible : x; let clipX = rtl ? x + controlsVisible : x;
let clipY = y + (fullHeight - clipHeight) / 2; let clipY = y + (fullHeight - clipHeight) / 2;
this.workspacesView.setClipRect(clipX, clipY, clipWidth, clipHeight); this._workspacesView.setClipRect(clipX, clipY, clipWidth, clipHeight);
if (this._zoomOut) { if (this._zoomOut) {
width -= controlsNatural; width -= controlsNatural;
@ -713,7 +746,7 @@ const WorkspacesDisplay = new Lang.Class({
let difference = fullHeight - height; let difference = fullHeight - height;
y += difference / 2; y += difference / 2;
this.workspacesView.setGeometry(x, y, width, height, difference); this._workspacesView.setGeometry(x, y, width, height, difference);
}, },
_onRestacked: function() { _onRestacked: function() {
@ -725,7 +758,7 @@ const WorkspacesDisplay = new Lang.Class({
stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i; stackIndices[stack[i].get_meta_window().get_stable_sequence()] = i;
} }
this.workspacesView.syncStacking(stackIndices); this._workspacesView.syncStacking(stackIndices);
this._thumbnailsBox.syncStacking(stackIndices); this._thumbnailsBox.syncStacking(stackIndices);
}, },
@ -740,7 +773,7 @@ const WorkspacesDisplay = new Lang.Class({
this._updateAlwaysZoom(); this._updateAlwaysZoom();
this._updateZoom(); this._updateZoom();
if (this.workspacesView == null) if (this._workspacesView == null)
return; return;
let lostWorkspaces = []; let lostWorkspaces = [];
@ -776,7 +809,7 @@ const WorkspacesDisplay = new Lang.Class({
this._thumbnailsBox.removeThumbmails(removedIndex, removedNum); this._thumbnailsBox.removeThumbmails(removedIndex, removedNum);
} }
this.workspacesView.updateWorkspaces(oldNumWorkspaces, this._workspacesView.updateWorkspaces(oldNumWorkspaces,
newNumWorkspaces); newNumWorkspaces);
}, },
@ -789,7 +822,7 @@ const WorkspacesDisplay = new Lang.Class({
this._zoomOut = shouldZoom; this._zoomOut = shouldZoom;
this._updateWorkspacesGeometry(); this._updateWorkspacesGeometry();
if (!this.workspacesView) if (!this._workspacesView)
return; return;
Tweener.addTween(this, Tweener.addTween(this,
@ -797,7 +830,7 @@ const WorkspacesDisplay = new Lang.Class({
time: WORKSPACE_SWITCH_TIME, time: WORKSPACE_SWITCH_TIME,
transition: 'easeOutQuad' }); transition: 'easeOutQuad' });
this.workspacesView.updateWindowPositions(); this._workspacesView.updateWindowPositions();
} }
}, },