Skip to content

Multi-tile Window Suggestion #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v16.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Have issues, you want to suggest a new feature or contribute? Please open a new
| [⬇️](#smart-border-radius) **Smart border radius** | [⬇️](#windows-suggestions) **Windows Suggestions**

## 🎉🎉 Tiling Shell's AWESOME Supporters!
Thank you to the :star2: **amazing** <a href="https://patreon.com/domferr"><img src="https://img.shields.io/badge/Patreons-F96854?logo=patreon&logoColor=white)" height="14px"/><a/> and **everyone** who donated on <a href="https://ko-fi.com/domferr"><img src="https://img.shields.io/badge/_Ko--fi-794bc4?logo=ko-fi&logoColor=white" height="14px"/><a/>! :medal_sports:Tomoyuki Kashiro and Markus Huggler on Patreon:medal_sports: and Nick, thy-fi, iatanas0v, Chris, wbezs, DaneshManoharan, Tamas, Ivan Banha and many more on Ko-fi! You are on a mission to **make Linux window management better for everyone**!
Thank you to the :star2: **amazing** <a href="https://patreon.com/domferr"><img src="https://img.shields.io/badge/Patreons-F96854?logo=patreon&logoColor=white)" height="14px"/><a/> and **everyone** who donated on <a href="https://ko-fi.com/domferr"><img src="https://img.shields.io/badge/_Ko--fi-794bc4?logo=ko-fi&logoColor=white" height="14px"/><a/>! :medal_sports:jane, Sean and Markus Huggler on Patreon:medal_sports: and Nick, thy-fi, iatanas0v, Chris, wbezs, DaneshManoharan, Tamas, Ivan Banha and many more on Ko-fi! You are on a mission to **make Linux window management better for everyone**!

### Tiling System ###
When grabbing and moving a window, press <kbd>CTRL</kbd> key to show the tiling layout (you can choose another key from the preferences). When moving on a tile, it will highlight. Ungrab the window to place that window on the highlighted tile.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<summary>Enable window suggestions for screen edge snapping</summary>
<description>Suggests windows to occupy empty tiles when snapping to screen edges.</description>
</key>
<key name="enable-multi-tile-window-suggestions" type="b">
<default>false</default>
<summary>Enable multi-tile window suggestions</summary>
<description>Displays window suggestions in all available tiles after a snap.</description>
</key>

<!-- keybindings -->
<key type="as" name="move-window-right">
Expand Down
49 changes: 47 additions & 2 deletions src/components/windowsSuggestions/tilingLayoutWithSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import LayoutWidget from '@components/layout/LayoutWidget';
import SignalHandling from '@utils/signalHandling';
import SuggestionsTilePreview from '@components/windowsSuggestions/suggestionsTilePreview';
import TilingShellWindowManager from '@components/windowManager/tilingShellWindowManager';
import Settings from '@settings/settings';

const debug = logger('TilingLayoutWithSuggestions');

Expand Down Expand Up @@ -137,12 +138,33 @@ export default class TilingLayoutWithSuggestions extends LayoutWidget<Suggestion
return;
}

// find the leftmost preview
// If multi-tile mode is enabled, show windows in all previews
if (Settings.ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS) {
// Show windows in all previews at once
this._previews.forEach((preview) => {
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 =
Expand Down Expand Up @@ -242,7 +264,30 @@ export default class TilingLayoutWithSuggestions extends LayoutWidget<Suggestion
this._oldPreviews.push(...removed);
nontiledWindows.splice(nontiledWindows.indexOf(nonTiledWin), 1);
preview.close(true);
this._recursivelyShowPopup(nontiledWindows, monitorIndex);

// In multi-tile mode, only close if all previews are filled or no more windows
if (Settings.ENABLE_MULTI_TILE_WINDOW_SUGGESTIONS) {
if (
this._previews.length === 0 ||
nontiledWindows.length === 0
) {
this.close();
} else {
// Remove the window from all other previews since it's now assigned
this._previews.forEach((prev) => {
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;
Expand Down
11 changes: 10 additions & 1 deletion src/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class TilingShellExtensionPreferences extends ExtensionPreference
this._buildSwitchRow(
Settings.KEY_ENABLE_SMART_WINDOW_BORDER_RADIUS,
_('Smart border radius'),
_('Dynamically adapt to the windows actual border radius'),
_("Dynamically adapt to the window's actual border radius"),
),
);
windowBorderRow.add_row(
Expand Down Expand Up @@ -334,6 +334,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
Expand Down
10 changes: 10 additions & 0 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,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';
Expand Down Expand Up @@ -439,6 +441,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;
Expand Down