workspaceThumbnails: Replace loops with Array.find()
This is much more idiomatic and concise than iterating over thumbnails until we find the one we are looking for. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/710
This commit is contained in:
parent
ce63d21dcc
commit
dfdb139d9c
@ -711,14 +711,12 @@ var ThumbnailsBox = GObject.registerClass({
|
|||||||
_activateThumbnailAtPoint(stageX, stageY, time) {
|
_activateThumbnailAtPoint(stageX, stageY, time) {
|
||||||
let [r_, x_, y] = this.transform_stage_point(stageX, stageY);
|
let [r_, x_, y] = this.transform_stage_point(stageX, stageY);
|
||||||
|
|
||||||
for (let i = 0; i < this._thumbnails.length; i++) {
|
let thumbnail = this._thumbnails.find(t => {
|
||||||
let thumbnail = this._thumbnails[i];
|
let [, h] = t.get_transformed_size();
|
||||||
let [, h] = thumbnail.get_transformed_size();
|
return y >= t.y && y <= t.y + h;
|
||||||
if (y >= thumbnail.y && y <= thumbnail.y + h) {
|
});
|
||||||
thumbnail.activate(time);
|
if (thumbnail)
|
||||||
break;
|
thumbnail.activate(time);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onButtonRelease(actor, event) {
|
_onButtonRelease(actor, event) {
|
||||||
@ -1340,15 +1338,9 @@ var ThumbnailsBox = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_activeWorkspaceChanged(_wm, _from, _to, _direction) {
|
_activeWorkspaceChanged(_wm, _from, _to, _direction) {
|
||||||
let thumbnail;
|
|
||||||
let workspaceManager = global.workspace_manager;
|
let workspaceManager = global.workspace_manager;
|
||||||
let activeWorkspace = workspaceManager.get_active_workspace();
|
let activeWorkspace = workspaceManager.get_active_workspace();
|
||||||
for (let i = 0; i < this._thumbnails.length; i++) {
|
let thumbnail = this._thumbnails.find(t => t.metaWorkspace == activeWorkspace);
|
||||||
if (this._thumbnails[i].metaWorkspace == activeWorkspace) {
|
|
||||||
thumbnail = this._thumbnails[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._animatingIndicator = true;
|
this._animatingIndicator = true;
|
||||||
let indicatorThemeNode = this._indicator.get_theme_node();
|
let indicatorThemeNode = this._indicator.get_theme_node();
|
||||||
|
Loading…
Reference in New Issue
Block a user