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

View File

@ -24,8 +24,6 @@ var WINDOW_REPOSITIONING_DELAY = 750;
var LAYOUT_SCALE_WEIGHT = 1;
var LAYOUT_SPACE_WEIGHT = 0.1;
var WINDOW_ANIMATION_MAX_NUMBER_BLENDING = 3;
// Window Thumbnail Layout Algorithm
// =================================
//
@ -1155,123 +1153,6 @@ class Workspace extends St.Widget {
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() {
const animate =
this.metaWorkspace === null || this.metaWorkspace.active;
@ -1310,11 +1191,6 @@ class Workspace extends St.Widget {
this._overviewHiddenId = 0;
}
if (this._overviewShownId) {
Main.overview.disconnect(this._overviewShownId);
this._overviewShownId = 0;
}
if (this.metaWorkspace) {
this.metaWorkspace.disconnect(this._windowAddedId);
this.metaWorkspace.disconnect(this._windowRemovedId);
@ -1332,14 +1208,10 @@ class Workspace extends St.Widget {
_doneLeavingOverview() {
this.layout_manager.layout_frozen = false;
this.layout_manager.stateAdjustment.value = 0;
this._windows.forEach(w => (w.opacity = 255));
}
_doneShowingOverview() {
this.layout_manager.layout_frozen = false;
this.layout_manager.stateAdjustment.value = 1;
this._windows.forEach(w => (w.opacity = 255));
}
_isMyWindow(window) {

View File

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