workspacesView: Always use ZOOM transition

Workspaces are now always shown, so the code path to fade windows
instead of zooming out is dead now; remove it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1613>
This commit is contained in:
Florian Müllner 2020-06-28 14:42:44 +02:00 committed by Marge Bot
parent 252f2f5144
commit 3abfc25858
3 changed files with 21 additions and 186 deletions

View File

@ -404,7 +404,7 @@ var ViewSelector = GObject.registerClass({
animateToOverview() { animateToOverview() {
this.show(); this.show();
this.reset(); this.reset();
this._workspacesDisplay.animateToOverview(this._showAppsButton.checked); this._workspacesDisplay.animateToOverview();
this._activePage = null; this._activePage = null;
this._showPage(this._activitiesPage); this._showPage(this._activitiesPage);
@ -413,7 +413,7 @@ var ViewSelector = GObject.registerClass({
} }
animateFromOverview() { animateFromOverview() {
this._workspacesDisplay.animateFromOverview(false); this._workspacesDisplay.animateFromOverview();
this._showAppsButton.checked = false; this._showAppsButton.checked = false;

View File

@ -24,8 +24,6 @@ var WINDOW_REPOSITIONING_DELAY = 750;
var LAYOUT_SCALE_WEIGHT = 1; var LAYOUT_SCALE_WEIGHT = 1;
var LAYOUT_SPACE_WEIGHT = 0.1; var LAYOUT_SPACE_WEIGHT = 0.1;
var WINDOW_ANIMATION_MAX_NUMBER_BLENDING = 3;
// Window Thumbnail Layout Algorithm // Window Thumbnail Layout Algorithm
// ================================= // =================================
// //
@ -1155,123 +1153,6 @@ class Workspace extends St.Widget {
return false; return false;
} }
fadeToOverview() {
// We don't want to reposition windows while animating in this way.
this.layout_manager.layout_frozen = true;
this._overviewShownId = Main.overview.connect('shown', this._doneShowingOverview.bind(this));
if (this._windows.length == 0)
return;
if (this.metaWorkspace !== null && !this.metaWorkspace.active)
return;
this.layout_manager.stateAdjustment.value = 0;
// Special case maximized windows, since it doesn't make sense
// to animate windows below in the stack
let topMaximizedWindow;
// It is ok to treat the case where there is no maximized
// window as if the bottom-most window was maximized given that
// it won't affect the result of the animation
for (topMaximizedWindow = this._windows.length - 1; topMaximizedWindow > 0; topMaximizedWindow--) {
let metaWindow = this._windows[topMaximizedWindow].metaWindow;
if (metaWindow.maximized_horizontally && metaWindow.maximized_vertically)
break;
}
let nTimeSlots = Math.min(WINDOW_ANIMATION_MAX_NUMBER_BLENDING + 1, this._windows.length - topMaximizedWindow);
let windowBaseTime = Overview.ANIMATION_TIME / nTimeSlots;
let topIndex = this._windows.length - 1;
for (let i = 0; i < this._windows.length; i++) {
if (i < topMaximizedWindow) {
// below top-most maximized window, don't animate
this._windows[i].hideOverlay(false);
this._windows[i].opacity = 0;
} else {
let fromTop = topIndex - i;
let time;
if (fromTop < nTimeSlots) // animate top-most windows gradually
time = windowBaseTime * (nTimeSlots - fromTop);
else
time = windowBaseTime;
this._windows[i].opacity = 255;
this._fadeWindow(i, time, 0);
}
}
}
fadeFromOverview() {
this.layout_manager.layout_frozen = true;
this._overviewHiddenId = Main.overview.connect('hidden', this._doneLeavingOverview.bind(this));
if (this._windows.length == 0)
return;
for (let i = 0; i < this._windows.length; i++)
this._windows[i].remove_all_transitions();
if (this._layoutFrozenId > 0) {
GLib.source_remove(this._layoutFrozenId);
this._layoutFrozenId = 0;
}
if (this.metaWorkspace !== null && !this.metaWorkspace.active)
return;
this.layout_manager.stateAdjustment.value = 0;
// Special case maximized windows, since it doesn't make sense
// to animate windows below in the stack
let topMaximizedWindow;
// It is ok to treat the case where there is no maximized
// window as if the bottom-most window was maximized given that
// it won't affect the result of the animation
for (topMaximizedWindow = this._windows.length - 1; topMaximizedWindow > 0; topMaximizedWindow--) {
let metaWindow = this._windows[topMaximizedWindow].metaWindow;
if (metaWindow.maximized_horizontally && metaWindow.maximized_vertically)
break;
}
let nTimeSlots = Math.min(WINDOW_ANIMATION_MAX_NUMBER_BLENDING + 1, this._windows.length - topMaximizedWindow);
let windowBaseTime = Overview.ANIMATION_TIME / nTimeSlots;
let topIndex = this._windows.length - 1;
for (let i = 0; i < this._windows.length; i++) {
if (i < topMaximizedWindow) {
// below top-most maximized window, don't animate
this._windows[i].hideOverlay(false);
this._windows[i].opacity = 0;
} else {
let fromTop = topIndex - i;
let time;
if (fromTop < nTimeSlots) // animate top-most windows gradually
time = windowBaseTime * (fromTop + 1);
else
time = windowBaseTime * nTimeSlots;
this._windows[i].opacity = 0;
this._fadeWindow(i, time, 255);
}
}
}
_fadeWindow(index, duration, opacity) {
let clone = this._windows[index];
clone.hideOverlay(false);
if (clone.metaWindow.showing_on_its_workspace()) {
clone.ease({
opacity,
duration,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
});
} else {
// The window is hidden
clone.opacity = 0;
}
}
zoomToOverview() { zoomToOverview() {
const animate = const animate =
this.metaWorkspace === null || this.metaWorkspace.active; this.metaWorkspace === null || this.metaWorkspace.active;
@ -1310,11 +1191,6 @@ class Workspace extends St.Widget {
this._overviewHiddenId = 0; this._overviewHiddenId = 0;
} }
if (this._overviewShownId) {
Main.overview.disconnect(this._overviewShownId);
this._overviewShownId = 0;
}
if (this.metaWorkspace) { if (this.metaWorkspace) {
this.metaWorkspace.disconnect(this._windowAddedId); this.metaWorkspace.disconnect(this._windowAddedId);
this.metaWorkspace.disconnect(this._windowRemovedId); this.metaWorkspace.disconnect(this._windowRemovedId);
@ -1332,14 +1208,10 @@ class Workspace extends St.Widget {
_doneLeavingOverview() { _doneLeavingOverview() {
this.layout_manager.layout_frozen = false; this.layout_manager.layout_frozen = false;
this.layout_manager.stateAdjustment.value = 0;
this._windows.forEach(w => (w.opacity = 255));
} }
_doneShowingOverview() { _doneShowingOverview() {
this.layout_manager.layout_frozen = false; this.layout_manager.layout_frozen = false;
this.layout_manager.stateAdjustment.value = 1;
this._windows.forEach(w => (w.opacity = 255));
} }
_isMyWindow(window) { _isMyWindow(window) {

View File

@ -11,11 +11,6 @@ var { ANIMATION_TIME } = imports.ui.overview;
var WORKSPACE_SWITCH_TIME = 250; var WORKSPACE_SWITCH_TIME = 250;
var SCROLL_TIMEOUT_TIME = 150; var SCROLL_TIMEOUT_TIME = 150;
var AnimationType = {
ZOOM: 0,
FADE: 1,
};
const MUTTER_SCHEMA = 'org.gnome.mutter'; const MUTTER_SCHEMA = 'org.gnome.mutter';
var WorkspacesViewBase = GObject.registerClass({ var WorkspacesViewBase = GObject.registerClass({
@ -136,24 +131,16 @@ class WorkspacesView extends WorkspacesViewBase {
return this._workspaces[active]; return this._workspaces[active];
} }
animateToOverview(animationType) { animateToOverview() {
for (let w = 0; w < this._workspaces.length; w++) { for (let w = 0; w < this._workspaces.length; w++)
if (animationType == AnimationType.ZOOM) this._workspaces[w].zoomToOverview();
this._workspaces[w].zoomToOverview();
else
this._workspaces[w].fadeToOverview();
}
this._updateScrollPosition(); this._updateScrollPosition();
this._updateVisibility(); this._updateVisibility();
} }
animateFromOverview(animationType) { animateFromOverview() {
for (let w = 0; w < this._workspaces.length; w++) { for (let w = 0; w < this._workspaces.length; w++)
if (animationType == AnimationType.ZOOM) this._workspaces[w].zoomFromOverview();
this._workspaces[w].zoomFromOverview();
else
this._workspaces[w].fadeFromOverview();
}
} }
syncStacking(stackIndices) { syncStacking(stackIndices) {
@ -323,18 +310,12 @@ class ExtraWorkspaceView extends WorkspacesViewBase {
return this._workspace; return this._workspace;
} }
animateToOverview(animationType) { animateToOverview() {
if (animationType == AnimationType.ZOOM) this._workspace.zoomToOverview();
this._workspace.zoomToOverview();
else
this._workspace.fadeToOverview();
} }
animateFromOverview(animationType) { animateFromOverview() {
if (animationType == AnimationType.ZOOM) this._workspace.zoomFromOverview();
this._workspace.zoomFromOverview();
else
this._workspace.fadeFromOverview();
} }
syncStacking(stackIndices) { syncStacking(stackIndices) {
@ -385,7 +366,6 @@ class WorkspacesDisplay extends St.Widget {
Main.overview.connect('window-drag-end', Main.overview.connect('window-drag-end',
this._windowDragEnd.bind(this)); this._windowDragEnd.bind(this));
this._overviewShownId = Main.overview.connect('shown', () => { this._overviewShownId = Main.overview.connect('shown', () => {
this._inWindowFade = false;
this._syncWorkspacesActualGeometry(); this._syncWorkspacesActualGeometry();
}); });
@ -407,7 +387,6 @@ class WorkspacesDisplay extends St.Widget {
this._actualGeometry = null; this._actualGeometry = null;
this._inWindowDrag = false; this._inWindowDrag = false;
this._inWindowFade = false;
this._leavingOverview = false; this._leavingOverview = false;
this._gestureActive = false; // touch(pad) gestures this._gestureActive = false; // touch(pad) gestures
@ -566,22 +545,14 @@ class WorkspacesDisplay extends St.Widget {
primaryWorkspace.visible = visible; primaryWorkspace.visible = visible;
} }
animateToOverview(fadeOnPrimary) { animateToOverview() {
this.show(); this.show();
this._updateWorkspacesViews(); this._updateWorkspacesViews();
for (let i = 0; i < this._workspacesViews.length; i++) { for (let i = 0; i < this._workspacesViews.length; i++)
let animationType; this._workspacesViews[i].animateToOverview();
if (fadeOnPrimary && i == this._primaryIndex)
animationType = AnimationType.FADE;
else
animationType = AnimationType.ZOOM;
this._workspacesViews[i].animateToOverview(animationType);
}
this._inWindowFade = fadeOnPrimary; if (this._actualGeometry)
if (this._actualGeometry && !fadeOnPrimary)
this._syncWorkspacesActualGeometry(); this._syncWorkspacesActualGeometry();
this._restackedNotifyId = this._restackedNotifyId =
@ -594,17 +565,9 @@ class WorkspacesDisplay extends St.Widget {
this._keyPressEventId = global.stage.connect('key-press-event', this._onKeyPressEvent.bind(this)); this._keyPressEventId = global.stage.connect('key-press-event', this._onKeyPressEvent.bind(this));
} }
animateFromOverview(fadeOnPrimary) { animateFromOverview() {
for (let i = 0; i < this._workspacesViews.length; i++) { for (let i = 0; i < this._workspacesViews.length; i++)
let animationType; this._workspacesViews[i].animateFromOverview();
if (fadeOnPrimary && i == this._primaryIndex)
animationType = AnimationType.FADE;
else
animationType = AnimationType.ZOOM;
this._workspacesViews[i].animateFromOverview(animationType);
}
this._inWindowFade = fadeOnPrimary;
this._leavingOverview = true; this._leavingOverview = true;
this._updateSwipeTracker(); this._updateSwipeTracker();
@ -614,7 +577,7 @@ class WorkspacesDisplay extends St.Widget {
Main.layoutManager.getWorkAreaForMonitor(primaryIndex); Main.layoutManager.getWorkAreaForMonitor(primaryIndex);
this._getPrimaryView().ease({ this._getPrimaryView().ease({
x, y, width, height, x, y, width, height,
duration: fadeOnPrimary ? 0 : ANIMATION_TIME, duration: ANIMATION_TIME,
mode: Clutter.AnimationMode.EASE_OUT_QUAD, mode: Clutter.AnimationMode.EASE_OUT_QUAD,
}); });
} }
@ -737,7 +700,7 @@ class WorkspacesDisplay extends St.Widget {
_syncWorkspacesActualGeometry() { _syncWorkspacesActualGeometry() {
const primaryView = this._getPrimaryView(); const primaryView = this._getPrimaryView();
if (!primaryView || this._inWindowFade) if (!primaryView)
return; return;
primaryView.ease({ primaryView.ease({