From 8a54616572369f1821c55de65ea069917d8b272c Mon Sep 17 00:00:00 2001 From: Gregorein Date: Wed, 23 Apr 2025 19:56:51 +0200 Subject: [PATCH] feat: add multi-tile window suggestions feature --- ...e.shell.extensions.tilingshell.gschema.xml | 5 ++ .../tilingLayoutWithSuggestions.ts | 49 ++++++++++++++++++- src/prefs.ts | 11 ++++- src/settings/settings.ts | 10 ++++ 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/resources/schemas/org.gnome.shell.extensions.tilingshell.gschema.xml b/resources/schemas/org.gnome.shell.extensions.tilingshell.gschema.xml index 7b441e47..1f30add9 100644 --- a/resources/schemas/org.gnome.shell.extensions.tilingshell.gschema.xml +++ b/resources/schemas/org.gnome.shell.extensions.tilingshell.gschema.xml @@ -187,6 +187,11 @@ Enable window suggestions for screen edge snapping Suggests windows to occupy empty tiles when snapping to screen edges. + + false + Enable multi-tile window suggestions + Displays window suggestions in all available tiles after a snap. + diff --git a/src/components/windowsSuggestions/tilingLayoutWithSuggestions.ts b/src/components/windowsSuggestions/tilingLayoutWithSuggestions.ts index 5b92c59b..1ec4a338 100644 --- a/src/components/windowsSuggestions/tilingLayoutWithSuggestions.ts +++ b/src/components/windowsSuggestions/tilingLayoutWithSuggestions.ts @@ -13,6 +13,7 @@ import SignalHandling from '@utils/signalHandling'; import SuggestionsTilePreview from '@components/windowsSuggestions/suggestionsTilePreview'; import TilingShellWindowManager from '@components/windowManager/tilingShellWindowManager'; import { unmaximizeWindow } from '@utils/gnomesupport'; +import Settings from '@settings/settings'; const debug = logger('TilingLayoutWithSuggestions'); @@ -138,12 +139,33 @@ export default class TilingLayoutWithSuggestions extends LayoutWidget { + this._showWindowsInPreview( + preview, + nontiledWindows, + monitorIndex, + ); + }); + return; + } + + // Original single-tile mode logic - find the leftmost preview let preview = this._previews[0]; this._previews.forEach((prev) => { if (prev.x < preview.x) preview = prev; }); + this._showWindowsInPreview(preview, nontiledWindows, monitorIndex); + } + + private _showWindowsInPreview( + preview: SuggestionsTilePreview, + nontiledWindows: Meta.Window[], + monitorIndex: number, + ): void { const clones = nontiledWindows.map((nonTiledWin) => { const winClone = new SuggestedWindowPreview(nonTiledWin); const winActor = @@ -244,7 +266,30 @@ export default class TilingLayoutWithSuggestions extends LayoutWidget { + prev.removeAllWindows(); + this._showWindowsInPreview( + prev, + nontiledWindows, + monitorIndex, + ); + }); + } + } else { + // Original behavior: recursively show popup on the next vacant tile + this._recursivelyShowPopup(nontiledWindows, monitorIndex); + } + return Clutter.EVENT_STOP; // Blocca la propagazione }); return winClone; diff --git a/src/prefs.ts b/src/prefs.ts index 98f16d54..c141ea63 100644 --- a/src/prefs.ts +++ b/src/prefs.ts @@ -146,7 +146,7 @@ export default class TilingShellExtensionPreferences extends ExtensionPreference this._buildSwitchRow( Settings.KEY_ENABLE_SMART_WINDOW_BORDER_RADIUS, _('Smart border radius'), - _('Dynamically adapt to the window’s actual border radius'), + _("Dynamically adapt to the window's actual border radius"), ), ); windowBorderRow.add_row( @@ -383,6 +383,15 @@ export default class TilingShellExtensionPreferences extends ExtensionPreference ); windowsSuggestionsGroup.add(screenEdgesWindowSuggestionRow); + const multiTileWindowSuggestionRow = this._buildSwitchRow( + Settings.KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS, + _('Enable multi-tile window suggestions'), + _( + 'Displays window suggestions in all available tiles after a snap', + ), + ); + windowsSuggestionsGroup.add(multiTileWindowSuggestionRow); + prefsPage.add(windowsSuggestionsGroup); // Layouts section diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 3a890449..308828d4 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -121,6 +121,8 @@ export default class Settings { 'enable-snap-assistant-windows-suggestions'; static KEY_ENABLE_SCREEN_EDGES_WINDOWS_SUGGESTIONS = 'enable-screen-edges-windows-suggestions'; + static KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS = + 'enable-multi-tile-window-suggestions'; static SETTING_MOVE_WINDOW_RIGHT = 'move-window-right'; static SETTING_MOVE_WINDOW_LEFT = 'move-window-left'; @@ -468,6 +470,14 @@ export default class Settings { set_boolean(Settings.KEY_ENABLE_SCREEN_EDGES_WINDOWS_SUGGESTIONS, val); } + static get ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS(): boolean { + return get_boolean(Settings.KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS); + } + + static set ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS(val: boolean) { + set_boolean(Settings.KEY_ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS, val); + } + static get_inner_gaps(scaleFactor: number = 1): { top: number; bottom: number;