Skip to content

Commit

Permalink
fix: fix issues uncovered by adding .jsconfig
Browse files Browse the repository at this point in the history
I've temporarily enabled `checkJs` and this uncovered some issues. They
were mostly wrong JSDoc comments. But there were also some actual issues
although I don't think they had observable bugs:

- GLib.PRIORITY_IDLE -> GLib.PRIORITY_DEFAULT_IDLE ... PRIORITY_IDLE
doen't exists
- removed unused variables in calls to focusHint.js::getAbsPos
- added a missing argument to addGaps call in tileEditingMode.js
- fix import for debugging shortcut in utility.js

(Also remove brackets in extension.js to satisfy the linter)
  • Loading branch information
Leleat committed Feb 3, 2025
1 parent fae5565 commit a2358b0
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 63 deletions.
2 changes: 1 addition & 1 deletion tiling-assistant@leleat-on-github/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,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
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Clutter, GLib, GObject, Meta, Mtk, Shell } from '../dependencies/gi.js';
import { GLib, Meta, Mtk, Shell } from '../dependencies/gi.js';
import { Main } from '../dependencies/shell.js';
import { getWindows } from '../dependencies/unexported/altTab.js';

Expand All @@ -13,7 +13,12 @@ export class TilingWindowManager {
static initialize() {
this._signals = new TilingSignals();

// { windowId1: [windowIdX, windowIdY, ...], windowId2: [...], ... }
/**
* @type {Map<number, number[]>} - {
* windowId1: [windowIdX, windowIdY, ...],
* windowId2: [...],
* }
*/
this._tileGroups = new Map();

/**
Expand Down Expand Up @@ -93,7 +98,7 @@ export class TilingWindowManager {
*
* @param {boolean} [allWorkspaces=false] determines whether we only want
* the windows from the current workspace.
* @returns {Meta.Windows[]} an array of of the open Meta.Windows in
* @returns {Meta.Window[]} an array of of the open Meta.Windows in
* stacking order.
*/
static getWindows(allWorkspaces = false) {
Expand All @@ -118,7 +123,7 @@ export class TilingWindowManager {

/**
* @param {Meta.Window} window a Meta.Window.
* @param {Meta.WorkArea|Rect|null} workArea useful for the grace period
* @param {Mtk.Rectangle|Rect|null} workArea useful for the grace period
* @returns whether the window is maximized. Be it using GNOME's native
* maximization or the maximization by this extension when using gaps.
*/
Expand All @@ -133,18 +138,15 @@ export class TilingWindowManager {
*
* @param {Meta.Window} window a Meta.Window to tile.
* @param {Rect} newRect the Rect the `window` will be tiled to.
* @param {boolean} [openTilingPopup=true] decides, if we open a Tiling
* @param {object} [param] the Rect the `window` will be tiled to.
* @param {boolean} [param.openTilingPopup=true] decides, if we open a Tiling
* Popup after the window is tiled and there is unambiguous free
* screen space.
* @param {number} [number=null] is used to get the workArea in which the
* window tiles on. It's used for gap calculation. We can't always rely on
* window.get_monitor with its monitor or global.display.get_current_monitor
* (the pointer monitor) because of the 'grace period' during a quick dnd
* towards a screen border since the pointer and the window will be on the
* 'wrong' monitor.
* @param {boolean} [skipAnim=false] decides, if we skip the tile animation.
* @param {boolean} [tileGroup=null] forces the creation of this tile group.
* @param {boolean} [fakeTile=false] don't create a new tile group, don't
* @param {boolean} [param.ignoreTA=false]
* @param {number} [param.monitorNr=null]
* @param {boolean} [param.skipAnim=false] decides, if we skip the tile animation.
* @param {boolean} [param.tileGroup=null] forces the creation of this tile group.
* @param {boolean} [param.fakeTile=false] don't create a new tile group, don't
* emit 'tiled' signal or open the Tiling Popup
*/
static async tile(window, newRect, {
Expand Down Expand Up @@ -273,10 +275,12 @@ export class TilingWindowManager {
* Untiles a tiled window and delete all tiling properties.
*
* @param {Meta.Window} window a Meta.Window to untile.
* @param {boolean} [restoreFullPos=true] decides, if we restore the
* @param {object} [params]
* @param {boolean} [params.restoreFullPos=true] decides, if we restore the
* pre-tile position or whether the size while keeping the titlebar
* at the relative same position.
* @param {boolean} [skipAnim=false] decides, if we skip the until animation.
* @param {boolean} [params.skipAnim=false] decides, if we skip the until animation.
* @param {boolean} [params.clampToWorkspace=false]
*/
static untile(window, { restoreFullPos = true, skipAnim = false, clampToWorkspace = false } = {}) {
const wasMaximized = window.get_maximized();
Expand Down Expand Up @@ -397,16 +401,14 @@ export class TilingWindowManager {
}

/**
* @returns {Map<number,number>}
* For ex: { windowId1: [windowIdX, windowIdY, ...], windowId2: ... }
* @returns {Map<number,number[]>}
*/
static getTileGroups() {
return this._tileGroups;
}

/**
* @param {Map<number, number>} tileGroups
* For ex: { windowId1: [windowIdX, windowIdY, ...], windowId2: ... }
* @param {Map<number, number[]>} tileGroups
*/
static setTileGroups(tileGroups) {
this._tileGroups = tileGroups;
Expand All @@ -421,7 +423,7 @@ export class TilingWindowManager {
* (i. e. ctrl-drag or tile editing mode+space). So manually create the
* tile group in those cases.
*
* @param {Meta.Windows[]} tileGroup an array of Meta.Windows to group
* @param {Meta.Window[]} tileGroup an array of Meta.Windows to group
* together.
*/
static updateTileGroup(tileGroup) {
Expand Down Expand Up @@ -563,13 +565,15 @@ export class TilingWindowManager {
* *tracked* tile groups since floating windows may overlap some tiled
* windows *at the moment* when this function is called.
*
* @param {boolean} [skipTopWindow=true] whether we ignore the focused window
* @param {object} [params]
* @param {boolean} [params.skipTopWindow=true] whether we ignore the focused window
* in the active search for the top tile group. The focused window may
* still be part of the returned array if it is part of another high-
* stacked window's tile group. This is mainly only useful, if the
* focused window isn't tiled (for example when dnd-ing a window).
* @param {number} [monitor=null] get the group for the monitor number.
* @returns {Meta.Windows[]} an array of tiled Meta.Windows.
* @param {number} [params.monitor=null] get the group for the monitor number.
*
* @returns {Meta.Window[]} an array of tiled Meta.Windows.
*/
static getTopTileGroup({ skipTopWindow = false, monitor = null } = {}) {
// 'Raise Tile Group' setting is enabled so we just return the tracked
Expand Down Expand Up @@ -674,10 +678,11 @@ export class TilingWindowManager {
*
* @param {Rect[]} rectList an array of Rects, which occupy the screen.
* Like usual, they shouldn't overlap each other.
* @param {Rect} [currRect=null] a Rect, which may be expanded.
* @param {Orientation} [orientation=null] The orientation we want to expand
* @param {object} [params]
* @param {Rect} [params.currRect=null] a Rect, which may be expanded.
* @param {Orientation} [params.orientation=null] The orientation we want to expand
* `currRect` into. If `null`, expand in both orientations.
* @param {Rect} [monitor=null] defaults to pointer monitor.
* @param {number} [params.monitorNr=null] defaults to pointer monitor.
* @returns {Rect} a new Rect.
*/
static getBestFreeRect(rectList, { currRect = null, orientation = null, monitorNr = null } = {}) {
Expand Down Expand Up @@ -802,9 +807,9 @@ export class TilingWindowManager {
/**
* Gets the nearest Meta.Window in the direction of `dir`.
*
* @param {Meta.Windows} currWindow the Meta.Window that the search starts
* @param {Meta.Window} currWindow the Meta.Window that the search starts
* from.
* @param {Meta.Windows[]} windows an array of the available Meta.Windows.
* @param {Meta.Window[]} windows an array of the available Meta.Windows.
* It may contain the current window itself. The windows shouldn't
* overlap each other.
* @param {Direction} dir the direction that is look into.
Expand Down Expand Up @@ -1153,7 +1158,9 @@ export class TilingWindowManager {
* Gets the top most non-overlapped/ing tiled windows ignoring
* the stacking order and tile groups.
*
* @param {{boolean, number}} param1
* @param {object} [param]
* @param {boolean} [param.skipTopWindow=false]
* @param {number} [param.monitor=null]
*/
static _getTopTiledWindows({ skipTopWindow = false, monitor = null } = {}) {
const openWindows = this.getWindows();
Expand Down
20 changes: 10 additions & 10 deletions tiling-assistant@leleat-on-github/src/extension/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class Util {
*/
static async __debugPrintTileGroups() {
log('--- Tiling Assistant: Start ---');
const twm = await import('./tilingWindowManager.js');
const twm = (await import('./tilingWindowManager.js')).TilingWindowManager;
const openWindows = twm.getWindows();
openWindows.forEach(w => {
if (!w.isTiled)
Expand Down Expand Up @@ -300,7 +300,7 @@ export class Rect {
* Gets a new rectangle where the screen and window gaps were
* added/subbed to/from `this`.
*
* @param {Rect} rect a tiled Rect
* @param {Rect} workArea a tiled Rect
* @param {number} monitor the number of the monitor to scale the gap to
* @returns {Rect} the rectangle after the gaps were taken into account
*/
Expand Down Expand Up @@ -382,7 +382,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {boolean}
*/
containsRect(rect) {
Expand All @@ -398,7 +398,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {boolean}
*/
couldFitRect(rect) {
Expand All @@ -407,7 +407,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {boolean}
*/
equal(rect) {
Expand Down Expand Up @@ -540,7 +540,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {boolean}
*/
horizOverlap(rect) {
Expand All @@ -549,7 +549,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {[boolean, Rect]}
*/
intersect(rect) {
Expand Down Expand Up @@ -653,7 +653,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {boolean}
*/
overlap(rect) {
Expand Down Expand Up @@ -699,7 +699,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {Rect}
*/
union(rect) {
Expand All @@ -708,7 +708,7 @@ export class Rect {
}

/**
* @param {Rect} rect
* @param {Rect|Mtk.Rectangle} rect
* @returns {boolean}
*/
vertOverlap(rect) {
Expand Down
3 changes: 0 additions & 3 deletions tiling-assistant@leleat-on-github/src/prefs/layoutRowEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ export const LayoutRowEntry = GObject.registerClass({
this._rectAppButton.set_icon_name(iconName);
}

/**
* @param {Gtk.Button} appButton src of the event.
*/
_onAppButtonClicked() {
// Reset app button, if it already has an app attached
if (this._item.appId) {
Expand Down
6 changes: 2 additions & 4 deletions tiling-assistant@leleat-on-github/src/prefs/layoutsPrefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ export default class {
try {
parentDir.make_directory_with_parents(null);
} catch (e) {
if (e.code !== Gio.IOErrorEnum.EXISTS) {
if (e.code !== Gio.IOErrorEnum.EXISTS)
throw e;
}
}

// Create file, if it doesn't exist.
Expand All @@ -182,9 +181,8 @@ export default class {
try {
file.create(Gio.FileCreateFlags.NONE, null);
} catch (e) {
if (e.code !== Gio.IOErrorEnum.EXISTS) {
if (e.code !== Gio.IOErrorEnum.EXISTS)
throw e;
}
}

return file;
Expand Down
Loading

0 comments on commit a2358b0

Please sign in to comment.