workspaceThumbnail: Sync indicator with WorkspacesDisplay

Now that both ThumbnailsBox and WorkspacesDisplay use single adjustments for
controlling indicator and scrolling, create the adjustment in OverviewControls
and pass it to both objects, effectively syncing indicator to scrolling.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/821
This commit is contained in:
Alexander Mikhaylenko
2019-07-08 13:03:20 +05:00
committed by Florian Müllner
parent f55ff01239
commit 9c1940ef9d
4 changed files with 53 additions and 52 deletions

View File

@ -7,7 +7,6 @@ const Background = imports.ui.background;
const DND = imports.ui.dnd;
const Main = imports.ui.main;
const Workspace = imports.ui.workspace;
const WorkspacesView = imports.ui.workspacesView;
// The maximum size of a thumbnail is 1/10 the width and height of the screen
let MAX_THUMBNAIL_SCALE = 1 / 10.;
@ -628,7 +627,7 @@ var ThumbnailsBox = GObject.registerClass({
0, Infinity, 0),
},
}, class ThumbnailsBox extends St.Widget {
_init() {
_init(scrollAdjustment) {
super._init({ reactive: true,
style_class: 'workspace-thumbnails',
request_mode: Clutter.RequestMode.WIDTH_FOR_HEIGHT });
@ -701,18 +700,17 @@ var ThumbnailsBox = GObject.registerClass({
this._syncStackingId = 0;
this._workareasChangedId = 0;
let workspaceManager = global.workspace_manager;
let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
this._scrollAdjustment = new St.Adjustment({
value: activeWorkspaceIndex,
lower: 0,
page_increment: 1,
page_size: 1,
step_increment: 0,
upper: workspaceManager.n_workspaces,
});
this._scrollAdjustment = scrollAdjustment;
this._scrollAdjustment.connect('notify::value', adj => {
let workspaceManager = global.workspace_manager;
let activeIndex = workspaceManager.get_active_workspace_index();
this._animatingIndicator = adj.value !== activeIndex;
if (!this._animatingIndicator)
this._queueUpdateStates();
this._scrollAdjustment.connect('notify::value', () => {
this.queue_relayout();
});
}
@ -915,9 +913,6 @@ var ThumbnailsBox = GObject.registerClass({
_createThumbnails() {
let workspaceManager = global.workspace_manager;
this._switchWorkspaceNotifyId =
global.window_manager.connect('switch-workspace',
this._activeWorkspaceChanged.bind(this));
this._nWorkspacesNotifyId =
workspaceManager.connect('notify::n-workspaces',
this._workspacesChanged.bind(this));
@ -950,10 +945,6 @@ var ThumbnailsBox = GObject.registerClass({
if (this._thumbnails.length == 0)
return;
if (this._switchWorkspaceNotifyId > 0) {
global.window_manager.disconnect(this._switchWorkspaceNotifyId);
this._switchWorkspaceNotifyId = 0;
}
if (this._nWorkspacesNotifyId > 0) {
let workspaceManager = global.workspace_manager;
workspaceManager.disconnect(this._nWorkspacesNotifyId);
@ -982,8 +973,6 @@ var ThumbnailsBox = GObject.registerClass({
let oldNumWorkspaces = validThumbnails.length;
let newNumWorkspaces = workspaceManager.n_workspaces;
this._scrollAdjustment.upper = newNumWorkspaces;
if (newNumWorkspaces > oldNumWorkspaces) {
this.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);
} else {
@ -1368,17 +1357,4 @@ var ThumbnailsBox = GObject.registerClass({
childBox.y2 = indicatorY2 + indicatorBottomFullBorder;
this._indicator.allocate(childBox, flags);
}
_activeWorkspaceChanged(_wm, from, to, _direction) {
this._scrollAdjustment.value = from;
this._animatingIndicator = true;
this._scrollAdjustment.ease(to, {
progress_mode: Clutter.AnimationMode.EASE_OUT_QUAD,
duration: WorkspacesView.WORKSPACE_SWITCH_TIME,
onComplete: () => {
this._animatingIndicator = false;
this._queueUpdateStates();
},
});
}
});