diff --git a/tiling-assistant@leleat-on-github/src/extension/activeWindowHint.js b/tiling-assistant@leleat-on-github/src/extension/activeWindowHint.js index a2701cf..5b4a004 100644 --- a/tiling-assistant@leleat-on-github/src/extension/activeWindowHint.js +++ b/tiling-assistant@leleat-on-github/src/extension/activeWindowHint.js @@ -237,7 +237,6 @@ class AlwaysActiveWindowHint extends Hint { super._init(); this._window = null; - this._signalIds = []; this._updateGeometry(); this._updateStyle(); @@ -271,8 +270,8 @@ class AlwaysActiveWindowHint extends Hint { _reset() { this._cancelShowLater(); - this._signalIds.forEach(id => this._window.disconnect(id)); - this._signalIds = []; + + this._window?.disconnectObject(this); this._window = null; } @@ -296,8 +295,16 @@ class AlwaysActiveWindowHint extends Hint { } this._window = window; - this._signalIds.push(window.connect('position-changed', () => this._updateGeometry())); - this._signalIds.push(window.connect('size-changed', () => this._updateGeometry())); + this._window.connectObject( + 'position-changed', + () => this._updateGeometry(), + this + ); + this._window.connectObject( + 'size-changed', + () => this._updateGeometry(), + this + ); // Don't show hint on maximzed/fullscreen windows if (window.is_fullscreen() || Twm.isMaximized(window)) { diff --git a/tiling-assistant@leleat-on-github/src/extension/moveHandler.js b/tiling-assistant@leleat-on-github/src/extension/moveHandler.js index 92c784d..249d38b 100644 --- a/tiling-assistant@leleat-on-github/src/extension/moveHandler.js +++ b/tiling-assistant@leleat-on-github/src/extension/moveHandler.js @@ -18,17 +18,22 @@ export default class TilingMoveHandler { constructor() { const moveOps = [Meta.GrabOp.MOVING, Meta.GrabOp.KEYBOARD_MOVING]; - this._displaySignals = []; - const g1Id = global.display.connect('grab-op-begin', (src, window, grabOp) => { - grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED - - if (window && moveOps.includes(grabOp)) - this._onMoveStarted(window, grabOp); - }); - this._displaySignals.push(g1Id); + global.display.connectObject( + 'grab-op-begin', + (src, window, grabOp) => { + grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED + + if (window && moveOps.includes(grabOp)) + this._onMoveStarted(window, grabOp); + }, + this + ); - const wId = global.display.connect('window-entered-monitor', this._onMonitorEntered.bind(this)); - this._displaySignals.push(wId); + global.display.connectObject( + 'window-entered-monitor', + this._onMonitorEntered.bind(this), + this + ); // Save the windows, which need to make space for the // grabbed window (this is for the so called 'adaptive mode'): @@ -82,7 +87,8 @@ export default class TilingMoveHandler { this._wmPrefs.disconnectObject(this); this._wmPrefs = null; - this._displaySignals.forEach(sId => global.display.disconnect(sId)); + global.display.disconnectObject(this); + this._tilePreview.destroy(); if (this._latestMonitorLockTimerId) { diff --git a/tiling-assistant@leleat-on-github/src/extension/resizeHandler.js b/tiling-assistant@leleat-on-github/src/extension/resizeHandler.js index c258b37..cf112bf 100644 --- a/tiling-assistant@leleat-on-github/src/extension/resizeHandler.js +++ b/tiling-assistant@leleat-on-github/src/extension/resizeHandler.js @@ -38,23 +38,27 @@ export default class TilingResizeHandler { } }; - const g1 = global.display.connect('grab-op-begin', (d, window, grabOp) => { + global.display.connectObject( + 'grab-op-begin', + (d, window, grabOp) => { grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED if (window && isResizing(grabOp)) this._onResizeStarted(window, grabOp); - }); - const g2 = global.display.connect('grab-op-end', (d, window, grabOp) => { + }, + this + ); + global.display.connectObject( + 'grab-op-end', + (d, window, grabOp) => { grabOp &= ~1024; // META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED if (window && isResizing(grabOp)) this._onResizeFinished(window, grabOp); - }); - this._displaySignals = []; - this._displaySignals.push(g1); - this._displaySignals.push(g2); + }, + this + ); - this._sizeChangedId = 0; this._preGrabRects = new Map(); // Save the windows, which are to be resized (passively) along the // actively grabbed one, and a resizeOp. A resizeOp saves the side @@ -64,7 +68,7 @@ export default class TilingResizeHandler { } destroy() { - this._displaySignals.forEach(sId => global.display.disconnect(sId)); + global.display.disconnectObject(this); } _onResizeStarted(window, grabOp) { @@ -147,8 +151,11 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, grabOp, null)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, grabOp, null), + this + ); break; case Meta.GrabOp.RESIZING_S: @@ -163,8 +170,11 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, grabOp, null)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, grabOp, null), + this + ); break; case Meta.GrabOp.RESIZING_E: @@ -179,8 +189,11 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, null, grabOp)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, null, grabOp), + this + ); break; case Meta.GrabOp.RESIZING_W: @@ -195,8 +208,11 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, null, grabOp)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, null, grabOp), + this + ); break; // Resizing intercardinal directions: @@ -212,8 +228,11 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_N, Meta.GrabOp.RESIZING_W)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_N, Meta.GrabOp.RESIZING_W), + this + ); break; case Meta.GrabOp.RESIZING_NE: @@ -228,8 +247,11 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_N, Meta.GrabOp.RESIZING_E)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_N, Meta.GrabOp.RESIZING_E), + this + ); break; case Meta.GrabOp.RESIZING_SW: @@ -244,8 +266,11 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_S, Meta.GrabOp.RESIZING_W)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_S, Meta.GrabOp.RESIZING_W), + this + ); break; case Meta.GrabOp.RESIZING_SE: @@ -260,17 +285,17 @@ export default class TilingResizeHandler { resizeOp && this._resizeOps.set(otherWindow, resizeOp); } - this._sizeChangedId = window.connect('size-changed', - this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_S, Meta.GrabOp.RESIZING_E)); + window.connectObject( + 'size-changed', + this._onResizing.bind(this, window, Meta.GrabOp.RESIZING_S, Meta.GrabOp.RESIZING_E), + this + ); } } // Update the windows' tiledRects _onResizeFinished(window, grabOp) { - if (this._sizeChangedId) { - window.disconnect(this._sizeChangedId); - this._sizeChangedId = 0; - } + window.disconnectObject(this); if (!window.isTiled) return; diff --git a/tiling-assistant@leleat-on-github/src/extension/tilingWindowManager.js b/tiling-assistant@leleat-on-github/src/extension/tilingWindowManager.js index 95cfeeb..84c1aac 100644 --- a/tiling-assistant@leleat-on-github/src/extension/tilingWindowManager.js +++ b/tiling-assistant@leleat-on-github/src/extension/tilingWindowManager.js @@ -19,16 +19,23 @@ export class TilingWindowManager { // [windowIds] this._unmanagingWindows = []; - this._wsAddedId = global.workspace_manager.connect('workspace-added', this._onWorkspaceAdded.bind(this)); - this._wsRemovedId = global.workspace_manager.connect('workspace-removed', this._onWorkspaceRemoved.bind(this)); + global.workspace_manager.connectObject( + 'workspace-added', + this._onWorkspaceAdded.bind(this), + this + ); + global.workspace_manager.connectObject( + 'workspace-removed', + this._onWorkspaceRemoved.bind(this), + this + ); } static destroy() { this._signals.destroy(); this._signals = null; - global.workspace_manager.disconnect(this._wsAddedId); - global.workspace_manager.disconnect(this._wsRemovedId); + global.workspace_manager.disconnectObject(this); this._tileGroups.clear(); this._unmanagingWindows = [];