Skip to content

Commit

Permalink
version 16: introducing windows suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
domferr committed Jan 12, 2025
1 parent 31370e0 commit 57a9f50
Show file tree
Hide file tree
Showing 22 changed files with 1,631 additions and 1,031 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ This is a Gnome Shell extension implementing modern windows tiling system by ext

<img src="https://github.com/domferr/tilingshell/blob/main/doc/horiz_summary.jpg" align="center"/>

<details>
<summary><span align="center">See here the video overview</span></summary>

https://github.com/user-attachments/assets/2905f0a1-ecd4-47b5-a6bc-59f91716e685
</details>

Have issues, you want to suggest a new feature or contribute? Please open a new [issue](https://github.com/domferr/tilingshell/issues)!

## Usage ##
Expand Down
Binary file added doc/TilingShellOverview.mp4
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tilingshell",
"version": "15.1",
"version": "16.0",
"author": "Domenico Ferraro <[email protected]>",
"private": true,
"license": "GPL v2.0",
Expand All @@ -13,7 +13,7 @@
"build:package": "npm run clean:package; npm run build && cd ./dist && zip -qr ../[email protected] * && cd ../dist_legacy && zip -qr ../[email protected] *",
"clean:package": "rm -rf './dist/[email protected]'; rm -rf './dist_legacy/[email protected]'",
"install:extension": "mkdir -p ~/.local/share/gnome-shell/extensions/[email protected] && cp ./dist$([ $(gnome-shell --version | grep -o -E '[0-9]+' | head -n 1) -le 44 ] && echo '_legacy')/* ~/.local/share/gnome-shell/extensions/[email protected]/ -r",
"wayland-session": "dbus-run-session -- gnome-shell --nested --wayland",
"wayland-session": "dbus-run-session -- env MUTTER_DEBUG_NUM_DUMMY_MONITORS=1 MUTTER_DEBUG_DUMMY_MODE_SPECS=1920x1080 gnome-shell --nested --wayland",
"dev:wayland": "npm run build && npm run install:extension && npm run wayland-session",
"build:translations": "for file in $(ls translations/*.po); do mkdir -p resources/locale/$(basename $file .po)/LC_MESSAGES; msgfmt -c $file -o resources/locale/$(basename $file .po)/LC_MESSAGES/tilingshell.mo; done",
"create:translations": "xgettext --from-code=UTF-8 --output=translations/[email protected] -j --language=javascript --force-po dist/prefs.js dist/extension.js",
Expand Down
7 changes: 4 additions & 3 deletions resources/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Tiling Shell",
"description": "Extend Gnome Shell with advanced tiling window management. Supports multiple monitors, Windows 11 Snap Assistant, Fancy Zones, customised tiling layouts and more.",
"description": "Extend Gnome Shell with advanced tiling window management. Supports multiple monitors, Windows 11 Snap Assistant, Fancy Zones, automatic tiling, keyboard shortcuts, customised tiling layouts and more!",
"uuid": "[email protected]",
"shell-version": [
"42",
Expand All @@ -11,11 +11,12 @@
"47"
],
"version": 99,
"version-name": "15.1",
"version-name": "16.0",
"url": "https://github.com/domferr/tilingshell",
"settings-schema": "org.gnome.shell.extensions.tilingshell",
"gettext-domain": "tilingshell",
"donations": {
"kofi": "domferr"
"kofi": "domferr",
"patreon": "domferr"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@
<summary>Tile animation time (milliseconds)</summary>
<description>Animation time in milliseconds of the tiles</description>
</key>
<key name="enable-tiling-system-windows-suggestions" type="b">
<default>false</default>
<summary>Enable window suggestions for the tiling system</summary>
<description>Provides smart suggestions to fill empty tiles when using the tiling system.</description>
</key>
<key name="enable-snap-assistant-windows-suggestions" type="b">
<default>false</default>
<summary>Enable window suggestions for the snap assistant</summary>
<description>Offers suggestions to populate empty tiles when using the snap assistant.</description>
</key>
<key name="enable-screen-edges-windows-suggestions" type="b">
<default>false</default>
<summary>Enable window suggestions for screen edge snapping</summary>
<description>Suggests windows to occupy empty tiles when snapping to screen edges.</description>
</key>

<!-- keybindings -->
<key type="as" name="move-window-right">
Expand Down
43 changes: 36 additions & 7 deletions src/components/layout/LayoutWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export default class LayoutWidget<
protected _layout: Layout;
protected _innerGaps: Clutter.Margin;
protected _outerGaps: Clutter.Margin;
protected _scalingFactor: number;

constructor(params: LayoutWidgetConstructorProperties) {
super({ styleClass: params.styleClass || '' });
params.parent.add_child(this);
this._scalingFactor = 1;
if (params.scalingFactor) this.scalingFactor = params.scalingFactor;

this._previews = [];
Expand All @@ -50,6 +52,11 @@ export default class LayoutWidget<

public set scalingFactor(value: number) {
enableScalingFactorSupport(this, value);
this._scalingFactor = value;
}

public get scalingFactor(): number {
return this._scalingFactor;
}

public get innerGaps(): Clutter.Margin {
Expand All @@ -60,6 +67,10 @@ export default class LayoutWidget<
return this._outerGaps.copy();
}

public get layout(): Layout {
return this._layout;
}

protected draw_layout(): void {
this._previews = this._layout.tiles.map((tile) => {
const tileRect = TileUtils.apply_props(tile, this._containerRect);
Expand Down Expand Up @@ -93,21 +104,27 @@ export default class LayoutWidget<
}>,
): boolean {
let trigger_relayout = this._previews.length === 0;
if (params?.layout && this._layout !== params.layout) {
this._layout = params.layout;
trigger_relayout = true;
}
if (params?.innerGaps) {
trigger_relayout ||= !this._areGapsEqual(
this._innerGaps,
params.innerGaps,
);
this._innerGaps = params.innerGaps.copy();
trigger_relayout = true;
}
if (params?.outerGaps && this._outerGaps !== params.outerGaps) {
trigger_relayout ||= !this._areGapsEqual(
this._outerGaps,
params.outerGaps,
);
this._outerGaps = params.outerGaps.copy();
trigger_relayout = true;
}
if (params?.layout && this._layout !== params.layout) {
this._layout = params.layout;
trigger_relayout = true;
}
if (
params?.containerRect &&
this._containerRect !== params.containerRect
!this._containerRect.equal(params.containerRect)
) {
this._containerRect = params.containerRect.copy();
trigger_relayout = true;
Expand All @@ -132,4 +149,16 @@ export default class LayoutWidget<

return true;
}

private _areGapsEqual(
first: Clutter.Margin,
second: Clutter.Margin,
): boolean {
return (
first.bottom === second.bottom &&
first.top === second.top &&
first.left === second.left &&
first.right === second.right
);
}
}
52 changes: 34 additions & 18 deletions src/components/snapassist/snapAssist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SnapAssistContent extends St.BoxLayout {
private _signals: SignalHandling;
private _snapAssistLayouts: SnapAssistLayout[];
private _isEnlarged = false;
private _hoveredTile: SnapAssistTile | undefined;
private _hoveredInfo: [SnapAssistTile, SnapAssistLayout] | undefined;
private _bottomPadding: number;
private _blur: boolean;
private _snapAssistantThreshold: number;
Expand Down Expand Up @@ -263,24 +263,32 @@ class SnapAssistContent extends St.BoxLayout {
const wasEnlarged = this._isEnlarged;
this.handleOpening(window, ease, currPointerPos);
if (!this._showing || !this._isEnlarged) {
if (this._hoveredTile) this._hoveredTile.set_hover(false);
if (this._hoveredInfo) this._hoveredInfo[0].set_hover(false);

this._hoveredTile = undefined;
this._hoveredInfo = undefined;
if (wasEnlarged) {
this._container.emit(
SNAP_ASSIST_SIGNAL,
new Tile({ x: 0, y: 0, width: 0, height: 0, groups: [] }),
'',
);
}
return;
}

const changed = this.handleTileHovering(currPointerPos);
if (changed) {
const layoutHovered = this.handleTileHovering(currPointerPos);
if (layoutHovered) {
const snapTile = this._hoveredInfo
? this._hoveredInfo[0]
: undefined;
const snapLay = this._hoveredInfo
? this._hoveredInfo[1]
: undefined;
const tile =
this._hoveredTile?.tile ||
snapTile?.tile ||
new Tile({ x: 0, y: 0, width: 0, height: 0, groups: [] });
this._container.emit(SNAP_ASSIST_SIGNAL, tile);
const layoutId = snapLay?.layout.id ?? '';
this._container.emit(SNAP_ASSIST_SIGNAL, tile, layoutId);
}
}

Expand Down Expand Up @@ -339,25 +347,33 @@ class SnapAssistContent extends St.BoxLayout {
y: number;
}): boolean {
if (!this._isEnlarged) {
const changed = this._hoveredTile !== undefined;
if (this._hoveredTile) this._hoveredTile.set_hover(false);
const changed = this._hoveredInfo !== undefined;
if (this._hoveredInfo) this._hoveredInfo[0].set_hover(false);

this._hoveredTile = undefined;
this._hoveredInfo = undefined;
return changed;
}

let newTileHovered: SnapAssistTile | undefined;
let layoutHovered: SnapAssistLayout | undefined;
for (let index = 0; index < this._snapAssistLayouts.length; index++) {
const snapAssistLay = this._snapAssistLayouts[index];
newTileHovered = snapAssistLay.getTileBelow(currPointerPos);
if (newTileHovered) break;
newTileHovered =
this._snapAssistLayouts[index].getTileBelow(currPointerPos);
if (newTileHovered) {
layoutHovered = this._snapAssistLayouts[index];
break;
}
}
const tileChanged = newTileHovered !== this._hoveredTile;

const oldTile = this._hoveredInfo ? this._hoveredInfo[0] : undefined;
const tileChanged = newTileHovered !== oldTile;
if (tileChanged) {
this._hoveredTile?.set_hover(false);
this._hoveredTile = newTileHovered;
oldTile?.set_hover(false);
if (newTileHovered === undefined || layoutHovered === undefined)
this._hoveredInfo = undefined;
else this._hoveredInfo = [newTileHovered, layoutHovered];
}
if (this._hoveredTile) this._hoveredTile.set_hover(true);
if (this._hoveredInfo) this._hoveredInfo[0].set_hover(true);

return tileChanged;
}
Expand All @@ -373,7 +389,7 @@ export default class SnapAssist extends St.Widget {
GTypeName: 'SnapAssist',
Signals: {
'snap-assist': {
param_types: [Tile.$gtype],
param_types: [Tile.$gtype, String.$gtype], // tile, layout_id
},
},
};
Expand Down
95 changes: 0 additions & 95 deletions src/components/tilepreview/popupTilePreview.ts

This file was deleted.

Loading

0 comments on commit 57a9f50

Please sign in to comment.