[gnome-shell] search: Don't use max number of results if allocation width is 0
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] search: Don't use max number of results if allocation width is 0
- Date: Thu, 8 Aug 2019 17:45:41 +0000 (UTC)
commit 68e3f74ffd4f1c01e7f3d1c6a0fd90686188843d
Author: Jonas Dreßler <verdre v0yd nl>
Date: Wed Aug 7 16:42:17 2019 +0200
search: Don't use max number of results if allocation width is 0
Since commit 1a27ff6130e03e64d9e426ece72a12e4e2a80f50 we use the
allocation width of the GridSearchResults actor to calculate the max
number of results that can be shown for this search provider.
On the first run of the search, when no previous (cached) allocation is
available for the actor of GridSearchResults, the allocation width used
in `_getMaxDisplayedResults` will be 0, which in turn will make
`updateSearch` filter out all results returned by the search provider.
Now if this search provider is the only search provider that's enabled,
after calling `updateSearch`, the `SearchResults` class will call
`_updateSearchProgress` to check if any results are visible, assume
nothing was found and therefore hide the scrollView. This in turn causes
the GridSearchResults actor to not get a new allocation, which prevents
our code to fixup the max number of results on `notify::allocation` from
working: The number will continue to be 0 and we'll never show any
results.
To fix this regression, return -1 in `_getMaxDisplayedResults` if the
allocation width is 0 to inform `updateSearch` that we can't calculate
the maximum number yet and interpret a return value of -1 as "show all
results" in `updateSearch`. The same problem would probably also appear
if the allocation width is anything between 0 and the width of the
iconGrid with one icon in it, although this might as well be a valid
width in case a very small screen is used or with very large icons. So
let's only check for a width of 0 and hope the GridSearchResults actor
won't get weird temporary allocations in that range.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/672
js/ui/search.js | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index b1235eb65d..7a7a5071fc 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -245,7 +245,9 @@ var SearchResultsBase = class {
callback();
} else {
let maxResults = this._getMaxDisplayedResults();
- let results = this.provider.filterResults(providerResults, maxResults);
+ let results = maxResults > -1
+ ? this.provider.filterResults(providerResults, maxResults)
+ : providerResults;
let moreCount = Math.max(providerResults.length - results.length, 0);
this._ensureResultActors(results, successful => {
@@ -353,8 +355,11 @@ var GridSearchResults = class extends SearchResultsBase {
}
_getMaxDisplayedResults() {
- let allocation = this.actor.allocation;
- let nCols = this._grid.columnsForWidth(allocation.x2 - allocation.x1);
+ let width = this.actor.allocation.x2 - this.actor.allocation.x1;
+ if (width == 0)
+ return -1;
+
+ let nCols = this._grid.columnsForWidth(width);
return nCols * this._grid.getRowLimit();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]