Skip to content

Commit

Permalink
version 13.0: GNOME 47 support, show border around focused window, ne…
Browse files Browse the repository at this point in the history
…w keybindings and more
  • Loading branch information
domferr committed Sep 11, 2024
1 parent ab2a08e commit a529749
Show file tree
Hide file tree
Showing 13 changed files with 930 additions and 181 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tilingshell",
"version": "12.1",
"version": "13.0",
"author": "Domenico Ferraro <ferraro.domenico125@gmail.com>",
"private": true,
"license": "GPL v2.0",
Expand Down
5 changes: 3 additions & 2 deletions resources/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
"43",
"44",
"45",
"46"
"46",
"47"
],
"version": 99,
"version-name": "12.2",
"version-name": "13.0",
"url": "https://github.com/domferr/tilingshell",
"settings-schema": "org.gnome.shell.extensions.tilingshell",
"donations": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@
<summary>Quarter tiling threshold</summary>
<description>Threshold to trigger quarter tiling.</description>
</key>
<key name="enable-window-border" type="b">
<default>false</default>
<summary>Enable window border</summary>
<description>Show a border around focused window.</description>
</key>
<key name="window-border-color" type="s">
<default>'#ec5e5e'</default>
<summary>Focused window border color</summary>
<description>The color of the focused window's border.</description>
</key>
<key name="window-border-width" type="u">
<default>3</default>
<summary>Focused window border width</summary>
<description>The width of the focused window's border.</description>
</key>

<!-- keybindings -->
<key type="as" name="move-window-right">
Expand All @@ -130,6 +145,30 @@
<default><![CDATA[['<Super>Down']]]></default>
<summary>Move focused window to the tile below</summary>
</key>
<key type="as" name="span-window-right">
<default><![CDATA[['']]]></default>
<summary>Span focused window to the tile to its right</summary>
</key>
<key type="as" name="span-window-left">
<default><![CDATA[['']]]></default>
<summary>Span focused window to the tile to its left</summary>
</key>
<key type="as" name="span-window-up">
<default><![CDATA[['']]]></default>
<summary>Span focused window to the tile above</summary>
</key>
<key type="as" name="span-window-down">
<default><![CDATA[['']]]></default>
<summary>Span focused window to the tile below</summary>
</key>
<key type="as" name="span-window-all-tiles">
<default><![CDATA[['']]]></default>
<summary>Resize the focused window to span all tiles</summary>
</key>
<key type="as" name="untile-window">
<default><![CDATA[['']]]></default>
<summary>Untile the focused window</summary>
</key>
</schema>

</schemalist>
11 changes: 7 additions & 4 deletions src/components/tilingsystem/tilingLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import Layout from '../layout/Layout';
import Tile from '../layout/Tile';
import { buildRectangle, buildTileGaps } from '@utils/ui';
import TileUtils from '@components/layout/TileUtils';
import { logger } from '@utils/shell';

const debug = logger('TilingLayout');

export interface DynamicTilePreviewConstructorProperties
extends Partial<TilePreviewConstructorProperties> {
Expand Down Expand Up @@ -375,16 +378,16 @@ export default class TilingLayout extends LayoutWidget<DynamicTilePreview> {

switch (direction) {
case Meta.DisplayDirection.RIGHT:
if (preview.x <= source.x) continue;
if (preview.innerX <= source.x) continue;
break;
case Meta.DisplayDirection.LEFT:
if (preview.x >= source.x) continue;
if (preview.innerX >= source.x) continue;
break;
case Meta.DisplayDirection.DOWN:
if (preview.y <= source.y) continue;
if (preview.innerY <= source.y) continue;
break;
case Meta.DisplayDirection.UP:
if (preview.y >= source.y) continue;
if (preview.innerY >= source.y) continue;
break;
default:
continue;
Expand Down
72 changes: 55 additions & 17 deletions src/components/tilingsystem/tilingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export class TilingManager {
private _edgeTilingManager: EdgeTilingManager;

private _workArea: Mtk.Rectangle;
private _innerGaps: Clutter.Margin;
private _outerGaps: Clutter.Margin;
private _enableScaling: boolean;

private _isGrabbingWindow: boolean;
Expand Down Expand Up @@ -69,10 +67,6 @@ export class TilingManager {
monitor.index,
);

// handle scale factor of the monitor
this._innerGaps = buildMargin(Settings.get_inner_gaps());
this._outerGaps = buildMargin(Settings.get_outer_gaps());

// get the monitor's workarea
this._workArea = Main.layoutManager.getWorkAreaForMonitor(
this._monitor.index,
Expand All @@ -82,14 +76,18 @@ export class TilingManager {
);
this._edgeTilingManager = new EdgeTilingManager(this._workArea);

// handle scale factor of the monitor
const innerGaps = buildMargin(Settings.get_inner_gaps());
const outerGaps = buildMargin(Settings.get_outer_gaps());
const monitorScalingFactor = this._enableScaling
? getMonitorScalingFactor(monitor.index)
: undefined;

// build the tiling layout
this._tilingLayout = new TilingLayout(
layout,
this._innerGaps,
this._outerGaps,
innerGaps,
outerGaps,
this._workArea,
monitorScalingFactor,
);
Expand Down Expand Up @@ -137,12 +135,12 @@ export class TilingManager {
);

this._signals.connect(Settings, Settings.SETTING_INNER_GAPS, () => {
this._innerGaps = buildMargin(Settings.get_inner_gaps());
this._tilingLayout.relayout({ innerGaps: this._innerGaps });
const innerGaps = buildMargin(Settings.get_inner_gaps());
this._tilingLayout.relayout({ innerGaps });
});
this._signals.connect(Settings, Settings.SETTING_OUTER_GAPS, () => {
this._outerGaps = buildMargin(Settings.get_outer_gaps());
this._tilingLayout.relayout({ outerGaps: this._outerGaps });
const outerGaps = buildMargin(Settings.get_outer_gaps());
this._tilingLayout.relayout({ outerGaps });
});

this._signals.connect(
Expand Down Expand Up @@ -177,13 +175,25 @@ export class TilingManager {
);
}

public onUntileWindow(window: Meta.Window, force: boolean): void {
const destination = (window as ExtendedWindow).originalSize;
if (!destination) return;

this._easeWindowRect(window, destination, false, force);

(window as ExtendedWindow).originalSize = undefined;
}

public onKeyboardMoveWindow(
window: Meta.Window,
direction: Meta.DisplayDirection,
force: boolean = false,
force: boolean,
spanFlag: boolean,
): boolean {
let destination: { rect: Mtk.Rectangle; tile: Tile } | undefined;
if (window.get_maximized()) {
if (spanFlag) return false;

switch (direction) {
case Meta.DisplayDirection.DOWN:
window.unmaximize(Meta.MaximizeFlags.BOTH);
Expand All @@ -200,16 +210,18 @@ export class TilingManager {
}

// find the nearest tile
const windowRect = window.get_frame_rect().copy();
const windowRectCopy = window.get_frame_rect().copy();
if (!destination) {
destination = this._tilingLayout.getNearestTile(
windowRect,
windowRectCopy,
direction,
);
}

// there isn't a tile near the window
if (!destination) {
if (spanFlag) return false;

// handle maximize of window
if (
direction === Meta.DisplayDirection.UP &&
Expand All @@ -222,8 +234,17 @@ export class TilingManager {
}

if (!(window as ExtendedWindow).assignedTile && !window.get_maximized())
(window as ExtendedWindow).originalSize = windowRect;
(window as ExtendedWindow).originalSize = windowRectCopy;

if (spanFlag) {
destination.rect = destination.rect.union(windowRectCopy);
destination.tile = TileUtils.build_tile(
destination.rect,
this._workArea,
);
}

// ensure the assigned tile is a COPY
(window as ExtendedWindow).assignedTile = new Tile({
...destination.tile,
});
Expand Down Expand Up @@ -730,7 +751,7 @@ export class TilingManager {
this._selectedTilesPreview.openAbove(window, true, edgeTile);
}

public onTileFromWindowMenu(tile: Tile, window: Meta.Window) {
private _easeWindowRectFromTile(tile: Tile, window: Meta.Window) {
// We apply the proportions to get tile size and position relative to the work area
const scaledRect = TileUtils.apply_props(tile, this._workArea);
// ensure the rect doesn't go horizontally beyond the workarea
Expand Down Expand Up @@ -795,4 +816,21 @@ export class TilingManager {
);
this._easeWindowRect(window, destinationRect);
}

public onTileFromWindowMenu(tile: Tile, window: Meta.Window) {
this._easeWindowRectFromTile(tile, window);
}

public onSpanAllTiles(window: Meta.Window) {
this._easeWindowRectFromTile(
new Tile({
x: 0,
y: 0,
width: 1,
height: 1,
groups: [],
}),
window,
);
}
}
Loading

0 comments on commit a529749

Please sign in to comment.