Skip to content

Commit 8a54616

Browse files
committed
feat: add multi-tile window suggestions feature
1 parent 8b7dd00 commit 8a54616

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

resources/schemas/org.gnome.shell.extensions.tilingshell.gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@
187187
<summary>Enable window suggestions for screen edge snapping</summary>
188188
<description>Suggests windows to occupy empty tiles when snapping to screen edges.</description>
189189
</key>
190+
<key name="enable-multi-tile-window-suggestions" type="b">
191+
<default>false</default>
192+
<summary>Enable multi-tile window suggestions</summary>
193+
<description>Displays window suggestions in all available tiles after a snap.</description>
194+
</key>
190195

191196
<!-- keybindings -->
192197
<key type="as" name="move-window-right">

src/components/windowsSuggestions/tilingLayoutWithSuggestions.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import SignalHandling from '@utils/signalHandling';
1313
import SuggestionsTilePreview from '@components/windowsSuggestions/suggestionsTilePreview';
1414
import TilingShellWindowManager from '@components/windowManager/tilingShellWindowManager';
1515
import { unmaximizeWindow } from '@utils/gnomesupport';
16+
import Settings from '@settings/settings';
1617

1718
const debug = logger('TilingLayoutWithSuggestions');
1819

@@ -138,12 +139,33 @@ export default class TilingLayoutWithSuggestions extends LayoutWidget<Suggestion
138139
return;
139140
}
140141

141-
// find the leftmost preview
142+
// If multi-tile mode is enabled, show windows in all previews
143+
if (Settings.ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS) {
144+
// Show windows in all previews at once
145+
this._previews.forEach((preview) => {
146+
this._showWindowsInPreview(
147+
preview,
148+
nontiledWindows,
149+
monitorIndex,
150+
);
151+
});
152+
return;
153+
}
154+
155+
// Original single-tile mode logic - find the leftmost preview
142156
let preview = this._previews[0];
143157
this._previews.forEach((prev) => {
144158
if (prev.x < preview.x) preview = prev;
145159
});
146160

161+
this._showWindowsInPreview(preview, nontiledWindows, monitorIndex);
162+
}
163+
164+
private _showWindowsInPreview(
165+
preview: SuggestionsTilePreview,
166+
nontiledWindows: Meta.Window[],
167+
monitorIndex: number,
168+
): void {
147169
const clones = nontiledWindows.map((nonTiledWin) => {
148170
const winClone = new SuggestedWindowPreview(nonTiledWin);
149171
const winActor =
@@ -244,7 +266,30 @@ export default class TilingLayoutWithSuggestions extends LayoutWidget<Suggestion
244266
this._oldPreviews.push(...removed);
245267
nontiledWindows.splice(nontiledWindows.indexOf(nonTiledWin), 1);
246268
preview.close(true);
247-
this._recursivelyShowPopup(nontiledWindows, monitorIndex);
269+
270+
// In multi-tile mode, only close if all previews are filled or no more windows
271+
if (Settings.ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS) {
272+
if (
273+
this._previews.length === 0 ||
274+
nontiledWindows.length === 0
275+
) {
276+
this.close();
277+
} else {
278+
// Remove the window from all other previews since it's now assigned
279+
this._previews.forEach((prev) => {
280+
prev.removeAllWindows();
281+
this._showWindowsInPreview(
282+
prev,
283+
nontiledWindows,
284+
monitorIndex,
285+
);
286+
});
287+
}
288+
} else {
289+
// Original behavior: recursively show popup on the next vacant tile
290+
this._recursivelyShowPopup(nontiledWindows, monitorIndex);
291+
}
292+
248293
return Clutter.EVENT_STOP; // Blocca la propagazione
249294
});
250295
return winClone;

src/prefs.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export default class TilingShellExtensionPreferences extends ExtensionPreference
146146
this._buildSwitchRow(
147147
Settings.KEY_ENABLE_SMART_WINDOW_BORDER_RADIUS,
148148
_('Smart border radius'),
149-
_('Dynamically adapt to the windows actual border radius'),
149+
_("Dynamically adapt to the window's actual border radius"),
150150
),
151151
);
152152
windowBorderRow.add_row(
@@ -383,6 +383,15 @@ export default class TilingShellExtensionPreferences extends ExtensionPreference
383383
);
384384
windowsSuggestionsGroup.add(screenEdgesWindowSuggestionRow);
385385

386+
const multiTileWindowSuggestionRow = this._buildSwitchRow(
387+
Settings.KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS,
388+
_('Enable multi-tile window suggestions'),
389+
_(
390+
'Displays window suggestions in all available tiles after a snap',
391+
),
392+
);
393+
windowsSuggestionsGroup.add(multiTileWindowSuggestionRow);
394+
386395
prefsPage.add(windowsSuggestionsGroup);
387396

388397
// Layouts section

src/settings/settings.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export default class Settings {
121121
'enable-snap-assistant-windows-suggestions';
122122
static KEY_ENABLE_SCREEN_EDGES_WINDOWS_SUGGESTIONS =
123123
'enable-screen-edges-windows-suggestions';
124+
static KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS =
125+
'enable-multi-tile-window-suggestions';
124126

125127
static SETTING_MOVE_WINDOW_RIGHT = 'move-window-right';
126128
static SETTING_MOVE_WINDOW_LEFT = 'move-window-left';
@@ -468,6 +470,14 @@ export default class Settings {
468470
set_boolean(Settings.KEY_ENABLE_SCREEN_EDGES_WINDOWS_SUGGESTIONS, val);
469471
}
470472

473+
static get ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS(): boolean {
474+
return get_boolean(Settings.KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS);
475+
}
476+
477+
static set ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS(val: boolean) {
478+
set_boolean(Settings.KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS, val);
479+
}
480+
471481
static get_inner_gaps(scaleFactor: number = 1): {
472482
top: number;
473483
bottom: number;

0 commit comments

Comments
 (0)