workspacesView: Scale inactive workspaces
As per the latest mockups, then horizontally snapping, the active workspace should be highlighted. Because WorkspacesView clips to allocation, we cannot simply scale up the active one. Instead, scale down the inactive ones. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1613>
This commit is contained in:
parent
b64103efca
commit
4cf5b4a6d8
@ -1,7 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
/* exported Workspace */
|
/* exported Workspace */
|
||||||
|
|
||||||
const { Clutter, GLib, GObject, Meta, St } = imports.gi;
|
const { Clutter, GLib, GObject, Graphene, Meta, St } = imports.gi;
|
||||||
|
|
||||||
const Background = imports.ui.background;
|
const Background = imports.ui.background;
|
||||||
const DND = imports.ui.dnd;
|
const DND = imports.ui.dnd;
|
||||||
@ -936,6 +936,7 @@ class Workspace extends St.Widget {
|
|||||||
_init(metaWorkspace, monitorIndex) {
|
_init(metaWorkspace, monitorIndex) {
|
||||||
super._init({
|
super._init({
|
||||||
style_class: 'window-picker',
|
style_class: 'window-picker',
|
||||||
|
pivot_point: new Graphene.Point({ x: 0.5, y: 0.5 }),
|
||||||
layout_manager: new WorkspaceLayout(metaWorkspace, monitorIndex),
|
layout_manager: new WorkspaceLayout(metaWorkspace, monitorIndex),
|
||||||
reactive: true,
|
reactive: true,
|
||||||
});
|
});
|
||||||
|
@ -17,6 +17,8 @@ const MUTTER_SCHEMA = 'org.gnome.mutter';
|
|||||||
const WORKSPACE_MIN_SPACING = 24;
|
const WORKSPACE_MIN_SPACING = 24;
|
||||||
const WORKSPACE_MAX_SPACING = 80;
|
const WORKSPACE_MAX_SPACING = 80;
|
||||||
|
|
||||||
|
const WORKSPACE_INACTIVE_SCALE = 0.94;
|
||||||
|
|
||||||
var WorkspacesViewBase = GObject.registerClass({
|
var WorkspacesViewBase = GObject.registerClass({
|
||||||
GTypeFlags: GObject.TypeFlags.ABSTRACT,
|
GTypeFlags: GObject.TypeFlags.ABSTRACT,
|
||||||
}, class WorkspacesViewBase extends St.Widget {
|
}, class WorkspacesViewBase extends St.Widget {
|
||||||
@ -83,6 +85,7 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
this._fitModeAdjustment = fitModeAdjustment;
|
this._fitModeAdjustment = fitModeAdjustment;
|
||||||
this._fitModeNotifyId = this._fitModeAdjustment.connect('notify::value', () => {
|
this._fitModeNotifyId = this._fitModeAdjustment.connect('notify::value', () => {
|
||||||
this._updateVisibility();
|
this._updateVisibility();
|
||||||
|
this._updateWorkspacesState();
|
||||||
this.queue_relayout();
|
this.queue_relayout();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -212,6 +215,20 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
return Math.clamp(spacing, WORKSPACE_MIN_SPACING, WORKSPACE_MAX_SPACING);
|
return Math.clamp(spacing, WORKSPACE_MIN_SPACING, WORKSPACE_MAX_SPACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateWorkspacesState() {
|
||||||
|
const adj = this._scrollAdjustment;
|
||||||
|
|
||||||
|
// Fade and scale inactive workspaces
|
||||||
|
this._workspaces.forEach((w, index) => {
|
||||||
|
const distanceToCurrentWorkspace = Math.abs(adj.value - index);
|
||||||
|
|
||||||
|
const progress = 1 - Math.clamp(distanceToCurrentWorkspace, 0, 1);
|
||||||
|
|
||||||
|
const scale = Util.lerp(WORKSPACE_INACTIVE_SCALE, 1, progress);
|
||||||
|
w.set_scale(scale, scale);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
vfunc_allocate(box) {
|
vfunc_allocate(box) {
|
||||||
this.set_allocation(box);
|
this.set_allocation(box);
|
||||||
|
|
||||||
@ -349,6 +366,8 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
this._workspaces[j].destroy();
|
this._workspaces[j].destroy();
|
||||||
this._workspaces.splice(j, 1);
|
this._workspaces.splice(j, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._updateWorkspacesState();
|
||||||
}
|
}
|
||||||
|
|
||||||
_activeWorkspaceChanged(_wm, _from, _to, _direction) {
|
_activeWorkspaceChanged(_wm, _from, _to, _direction) {
|
||||||
@ -411,6 +430,7 @@ class WorkspacesView extends WorkspacesViewBase {
|
|||||||
metaWorkspace.activate(global.get_current_time());
|
metaWorkspace.activate(global.get_current_time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._updateWorkspacesState();
|
||||||
this.queue_relayout();
|
this.queue_relayout();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user