Fade out desktop icons when showing overview

As desktop icons don't have any purpose in the overview (except for
distracting the user), fade them out when entering the overview.

Unfortunately, the fading effect affects performance, therefore hide
icons directly when there are maximized windows on the desktop.

https://bugzilla.gnome.org/show_bug.cgi?id=600999
This commit is contained in:
Florian Müllner 2010-01-06 04:53:36 +01:00
parent 1d2bb5c51c
commit 03a750176b
2 changed files with 67 additions and 50 deletions

View File

@ -47,8 +47,6 @@ let _errorLogStack = [];
let _startDate; let _startDate;
let background = null; let background = null;
let _windowAddedSignalId = null;
let _windowRemovedSignalId = null;
function start() { function start() {
// Add a binding for "global" in the global JS namespace; (gjs // Add a binding for "global" in the global JS namespace; (gjs
@ -149,10 +147,8 @@ function start() {
}); });
background = global.create_root_pixmap_actor(); background = global.create_root_pixmap_actor();
global.screen.connect('workspace-switched', _onWorkspaceSwitched);
global.stage.add_actor(background); global.stage.add_actor(background);
background.lower_bottom(); background.lower_bottom();
_onWorkspaceSwitched(global.screen, -1);
global.connect('screen-size-changed', _relayout); global.connect('screen-size-changed', _relayout);
@ -214,45 +210,6 @@ function _getAndClearErrorStack() {
return errors; return errors;
} }
function showBackground() {
background.show();
}
function hideBackground() {
background.hide();
}
function _onWorkspaceSwitched(screen, from) {
let workspace = screen.get_active_workspace();
if (from != -1) {
let old_workspace = screen.get_workspace_by_index(from);
if (_windowAddedSignalId !== null)
old_workspace.disconnect(_windowAddedSignalId);
if (background.windowRemovedSignalId !== null)
old_workspace.disconnect(_windowRemovedSignalId);
}
_windowAddedSignalId = workspace.connect('window-added', function(workspace, win) {
if (win.window_type == Meta.WindowType.DESKTOP)
hideBackground();
});
_windowRemovedSignalId = workspace.connect('window-removed', function(workspace, win) {
if (win.window_type == Meta.WindowType.DESKTOP)
showBackground();
});
function _isDesktop(win) {
return win.window_type == Meta.WindowType.DESKTOP;
}
if (workspace.list_windows().some(_isDesktop))
hideBackground();
else
showBackground();
}
function _relayout() { function _relayout() {
let primary = global.get_primary_monitor(); let primary = global.get_primary_monitor();
panel.actor.set_position(primary.x, primary.y); panel.actor.set_position(primary.x, primary.y);

View File

@ -283,20 +283,58 @@ function DesktopClone(window) {
DesktopClone.prototype = { DesktopClone.prototype = {
_init : function(window) { _init : function(window) {
this.actor = new Clutter.Group({ reactive: true });
let background = new Clutter.Clone({ source: Main.background.source });
this.actor.add_actor(background);
if (window) { if (window) {
this.actor = new Clutter.Clone({ source: window.get_texture(), this._desktop = new Clutter.Clone({ source: window.get_texture() });
reactive: true }); this.actor.add_actor(this._desktop);
this._desktop.hide();
} else { } else {
this.actor = new Clutter.Clone({ source: Main.background.source, this._desktop = null;
reactive: true,
width: global.screen_width,
height: global.screen_height });
} }
this.actor.connect('button-release-event', this.actor.connect('button-release-event',
Lang.bind(this, this._onButtonRelease)); Lang.bind(this, this._onButtonRelease));
}, },
zoomFromOverview: function(fadeInIcons) {
if (this._desktop == null)
return;
if (fadeInIcons) {
this._desktop.opacity = 0;
this._desktop.show();
Tweener.addTween(this._desktop,
{ opacity: 255,
time: Overview.ANIMATION_TIME,
transition: "easeOutQuad" });
}
},
zoomToOverview: function(fadeOutIcons) {
if (this._desktop == null)
return;
if (fadeOutIcons) {
this._desktop.opacity = 255;
this._desktop.show();
Tweener.addTween(this._desktop,
{ opacity: 0,
time: Overview.ANIMATION_TIME,
transition: "easeOutQuad",
onComplete: Lang.bind(this,
function() {
this._desktop.hide();
})
});
} else {
this._desktop.hide();
}
},
_onButtonRelease : function (actor, event) { _onButtonRelease : function (actor, event) {
this.emit('selected', event.get_time()); this.emit('selected', event.get_time());
} }
@ -601,7 +639,6 @@ Workspace.prototype = {
}, },
_lookupIndex: function (metaWindow) { _lookupIndex: function (metaWindow) {
let index, clone;
for (let i = 0; i < this._windows.length; i++) { for (let i = 0; i < this._windows.length; i++) {
if (this._windows[i].metaWindow == metaWindow) { if (this._windows[i].metaWindow == metaWindow) {
return i; return i;
@ -1152,6 +1189,18 @@ Workspace.prototype = {
this.positionWindows(WindowPositionFlags.ANIMATE); this.positionWindows(WindowPositionFlags.ANIMATE);
}, },
// check for maximized windows on the workspace
_haveMaximizedWindows: function() {
for (let i = 1; i < this._windows.length; i++) {
let metaWindow = this._windows[i].metaWindow;
if (metaWindow.showing_on_its_workspace() &&
metaWindow.maximized_horizontally &&
metaWindow.maximized_vertically)
return true;
}
return false;
},
// Animate the full-screen to Overview transition. // Animate the full-screen to Overview transition.
zoomToOverview : function(animate) { zoomToOverview : function(animate) {
this.actor.set_position(this.gridX, this.gridY); this.actor.set_position(this.gridX, this.gridY);
@ -1163,6 +1212,12 @@ Workspace.prototype = {
else else
this.positionWindows(WindowPositionFlags.ZOOM); this.positionWindows(WindowPositionFlags.ZOOM);
let active = global.screen.get_active_workspace_index();
let fadeInIcons = (animate &&
active == this.workspaceNum &&
!this._haveMaximizedWindows());
this._desktop.zoomToOverview(fadeInIcons);
this._visible = true; this._visible = true;
}, },
@ -1203,6 +1258,11 @@ Workspace.prototype = {
} }
} }
let active = global.screen.get_active_workspace_index();
let fadeOutIcons = (active == this.workspaceNum &&
!this._haveMaximizedWindows());
this._desktop.zoomFromOverview(fadeOutIcons);
this._visible = false; this._visible = false;
}, },