Skip to content

Commit

Permalink
Merge pull request #392 from Leleat/cherry-pick-from-354
Browse files Browse the repository at this point in the history
Some minor ports of commits from #354
  • Loading branch information
Leleat authored Feb 10, 2025
2 parents 21d781e + a2358b0 commit ebc23e1
Show file tree
Hide file tree
Showing 15 changed files with 1,163 additions and 348 deletions.
36 changes: 36 additions & 0 deletions ambient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import "@girs/gjs";
import "@girs/gjs/dom";
import "@girs/gnome-shell/ambient";
import "@girs/gnome-shell/extensions/global";

/***********************
* Module Augmentation *
***********************/

import "tiling-assistant@leleat-on-github/src/dependencies/gi.js";
import { Rect } from "tiling-assistant@leleat-on-github/src/extension/utility.js";

declare module "tiling-assistant@leleat-on-github/src/dependencies/gi.js" {
namespace Clutter {
interface Actor {
ease: (params: object) => void;
}
}

namespace GObject {
interface Object {
connectObject: (...args: unknown[]) => void;
disconnectObject: (object: object) => void;
}
}

namespace Meta {
interface Window {
assertExistence: () => void;
isTiled: boolean
tiledRect?: Rect
untiledRect?: Rect
}
}

}
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "ESNext",
"baseUrl": "."
},
"exclude": ["node_modules"]
}
1,283 changes: 1,043 additions & 240 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"type": "module",
"devDependencies": {
"@eslint/js": "^9.0.0",
"@girs/gjs": "^4.0.0-beta.19",
"@girs/gnome-shell": "^47.0.1",
"eslint": "^9.0.0"
}
}
5 changes: 2 additions & 3 deletions tiling-assistant@leleat-on-github/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { ExtensionPreferences } from './src/dependencies/prefs.js';

import LayoutPrefs from './src/prefs/layoutsPrefs.js';
import { Shortcuts } from './src/common.js';
// eslint-disable-next-line no-unused-vars
import { ShortcutListener } from './src/prefs/shortcutListener.js';
import './src/prefs/shortcutListener.js';

export default class Prefs extends ExtensionPreferences {
fillPreferencesWindow(window) {
Expand Down Expand Up @@ -145,7 +144,7 @@ export default class Prefs extends ExtensionPreferences {
settings.set_string(key, widget.get_rgba().to_string());
});

// initilaize color
// initialize color
const rgba = new Gdk.RGBA();
rgba.parse(settings.get_string(key));
widget.set_rgba(rgba);
Expand Down
4 changes: 2 additions & 2 deletions tiling-assistant@leleat-on-github/src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Settings {
}

/**
* @returns {Gio.Settings} the Gio.Settings object.
* @returns {import("./dependencies/gi.js").Gio.Settings} the Gio.Settings object.
*/
static getGioObject() {
return this._settings;
Expand Down Expand Up @@ -279,7 +279,7 @@ export class Layout {
}

/**
* @returns {[boolean, string]} whether the layout has valid rects and
* @returns {[boolean, string, number]} whether the layout has valid rects and
* a potential error message.
*/
validate() {
Expand Down
16 changes: 8 additions & 8 deletions tiling-assistant@leleat-on-github/src/extension/focusHint.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export default class FocusHintManager {

this._settingsChangedId = Settings.changed(
'focus-hint',
() => this._setHint(),
this
() => this._setHint()
);
this._setHint();

Expand Down Expand Up @@ -97,7 +96,9 @@ class Hint {
this._removeIdleWatcher();
}

indicate() {
/** @param {Meta.Window} focus */
// eslint-disable-next-line no-unused-vars
indicate(focus) {
throw new Error('`indicate` not implemented by Hint subclass!');
}

Expand Down Expand Up @@ -597,7 +598,7 @@ class StaticOutlineHint extends AnimatedOutlineHint {
/**
* This is really only used for the indication when changing workspaces...
*
* @param {Window} window -
* @param {Meta.Window} window -
* @param {number} workspaceSwitchAnimationDuration -
*/
indicate(window, workspaceSwitchAnimationDuration = 250) {
Expand Down Expand Up @@ -764,8 +765,8 @@ function createContainers(
let startingPos;

if (workspaceAnimationWindowClone) {
const actorAbsPos = getAbsPos(window.get_compositor_private(), monitorNr);
const cloneAbsPos = getAbsPos(workspaceAnimationWindowClone, monitorNr);
const actorAbsPos = getAbsPos(window.get_compositor_private());
const cloneAbsPos = getAbsPos(workspaceAnimationWindowClone);

startingPos = {
x: monitorRect.x + cloneAbsPos.x - actorAbsPos.x,
Expand Down Expand Up @@ -827,8 +828,7 @@ function createContainers(
* @returns {Clutter.Clone}
*/
function createWindowClone(windowActor, container) {
const monitor = windowActor.get_meta_window().get_monitor();
const { x, y } = getAbsPos(windowActor, monitor);
const { x, y } = getAbsPos(windowActor);

const windowClone = new Clutter.Clone({
source: windowActor,
Expand Down
11 changes: 5 additions & 6 deletions tiling-assistant@leleat-on-github/src/extension/moveHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default class TilingMoveHandler {

counter += 10;
if (counter >= 400) {
this._restoreSizeAndRestartGrab(window, x, y, grabOp);
this._restoreSizeAndRestartGrab(window, grabOp);
this._restoreSizeTimerId = null;
return GLib.SOURCE_REMOVE;
}
Expand All @@ -151,7 +151,7 @@ export default class TilingMoveHandler {
const oldPoint = { x, y };
const moveDist = Util.getDistance(currPoint, oldPoint);
if (moveDist > 10) {
this._restoreSizeAndRestartGrab(window, x, y, grabOp);
this._restoreSizeAndRestartGrab(window, grabOp);
this._restoreSizeTimerId = null;
return GLib.SOURCE_REMOVE;
}
Expand All @@ -175,7 +175,7 @@ export default class TilingMoveHandler {
// as often when compared to the position-changed signal.
if (Settings.getBoolean('low-performance-move-mode')) {
this._movingTimerId = GLib.timeout_add(
GLib.PRIORITY_IDLE,
GLib.PRIORITY_DEFAULT_IDLE,
this._movingTimerDuration,
this._onMoving.bind(
this,
Expand Down Expand Up @@ -343,7 +343,7 @@ export default class TilingMoveHandler {
const useIgnoreTa = defaultMode !== MoveModes.IGNORE_TA && pressed[ignoreTAMod] ||
noMod && defaultMode === MoveModes.IGNORE_TA;

let newMode = '';
let newMode;

if (useAdaptiveTiling)
newMode = MoveModes.ADAPTIVE_TILING;
Expand Down Expand Up @@ -422,10 +422,9 @@ export default class TilingMoveHandler {
}
}

_restoreSizeAndRestartGrab(window, px, py, grabOp) {
_restoreSizeAndRestartGrab(window, grabOp) {
Twm.untile(window, {
restoreFullPos: false,
xAnchor: px,
skipAnim: this._wasMaximizedOnStart
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const Indicator = GObject.registerClass(class TileEditingModeIndicator extends S
const workArea = new Rect(activeWs.get_work_area_for_monitor(this._monitor));

// Adjusted for window / screen gaps
const { x, y, width, height } = rect.addGaps(workArea);
const { x, y, width, height } = rect.addGaps(workArea, this._monitor);

this.ease({
x: x - display.x,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const TilingSwitcherPopup = GObject.registerClass({
}
}, class TilingSwitcherPopup extends AltTab.TilingAppSwitcherPopup {
/**
* @param {Meta.Windows[]} openWindows an array of Meta.Windows, which this
* @param {Meta.Window[]} openWindows an array of Meta.Windows, which this
* popup offers to tile.
* @param {Rect} freeScreenRect the Rect, which the popup will tile a window
* to. The popup will be centered in this rect.
Expand Down
Loading

0 comments on commit ebc23e1

Please sign in to comment.