From 4dea1f801ae130b2a5c80537c4e05189dab0f6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 20 May 2019 23:25:14 +0200 Subject: [PATCH] lookingGlass: Use resultsArea to keep track of results Now that results are actors we can just use their container to keep track of them https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559 --- js/ui/lookingGlass.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 85e8874b1..38e45edb4 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -793,7 +793,6 @@ class LookingGlass extends St.BoxLayout { this._it = null; this._offset = 0; - this._results = []; // Sort of magic, but...eh. this._maxItems = 150; @@ -937,17 +936,14 @@ class LookingGlass extends St.BoxLayout { } _pushResult(command, obj) { - let index = this._results.length + this._offset; + let index = this._resultsArea.get_n_children() + this._offset; let result = new Result(this, CHEVRON + command, obj, index); - this._results.push(result); this._resultsArea.add(result); if (obj instanceof Clutter.Actor) this.setBorderPaintTarget(obj); - let children = this._resultsArea.get_children(); - if (children.length > this._maxItems) { - this._results.shift(); - children[0].destroy(); + if (this._resultsArea.get_n_children() > this._maxItems) { + this._resultsArea.get_first_child().destroy(); this._offset++; } this._it = obj; @@ -1034,7 +1030,7 @@ class LookingGlass extends St.BoxLayout { getResult(idx) { try { - return this._results[idx - this._offset].o; + return this._resultsArea.get_child_at_index(idx - this._offset).o; } catch (e) { throw new Error(`Unknown result at index ${idx}`); }