diff --git a/js/ui/search.js b/js/ui/search.js index 9a58e7981..dc2729a4a 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -465,8 +465,14 @@ const GridSearchResults = new Lang.Class({ Name: 'GridSearchResults', Extends: SearchResultsBase, - _init: function(provider) { + _init: function(provider, parentContainer) { this.parent(provider); + // We need to use the parent container to know how much results we can show. + // None of the actors in this class can be used for that, since the main actor + // goes hidden when no results are displayed, and then it lost its allocation. + // Then on the next use of _getMaxDisplayedResults allocation is 0, en therefore + // it doesn't show any result although we have some. + this._parentContainer = parentContainer; this._grid = new IconGrid.IconGrid({ rowLimit: MAX_GRID_SEARCH_RESULTS_ROWS, xAlign: St.Align.START }); @@ -477,7 +483,9 @@ const GridSearchResults = new Lang.Class({ }, _getMaxDisplayedResults: function() { - return this._grid.columnsForWidth(this._bin.width) * this._grid.getRowLimit(); + let parentThemeNode = this._parentContainer.get_theme_node(); + let availableWidth = parentThemeNode.adjust_for_width(this._parentContainer.width); + return this._grid.columnsForWidth(availableWidth) * this._grid.getRowLimit(); }, _renderResults: function(metas) { @@ -577,7 +585,7 @@ const SearchResults = new Lang.Class({ if (provider.appInfo) providerDisplay = new ListSearchResults(provider); else - providerDisplay = new GridSearchResults(provider); + providerDisplay = new GridSearchResults(provider, this._content); providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn)); this._content.add(providerDisplay.actor);