commit fe04ceb284b566b996d2082f33163e0fae8d0da2 Author: taoky Date: Thu Mar 28 01:29:55 2024 +0800 moveHandler: replace hack that no longer works in GNOME 46 Use global.display.is_grabbed() available from GNOME 44 instead. Fixes https://github.com/Leleat/Tiling-Assistant/issues/327. diff --git a/tiling-assistant@leleat-on-github/src/extension/moveHandler.js b/tiling-assistant@leleat-on-github/src/extension/moveHandler.js index 6bdb166..ebfed96 100644 --- a/tiling-assistant@leleat-on-github/src/extension/moveHandler.js +++ b/tiling-assistant@leleat-on-github/src/extension/moveHandler.js @@ -95,11 +95,6 @@ export default class TilingMoveHandler { this._latestPreviewTimerId = null; } - if (this._cursorChangeTimerId) { - GLib.Source.remove(this._cursorChangeTimerId); - this._cursorChangeTimerId = null; - } - if (this._restoreSizeTimerId) { GLib.Source.remove(this._restoreSizeTimerId); this._restoreSizeTimerId = null; @@ -130,33 +125,10 @@ export default class TilingMoveHandler { if ((window.tiledRect || this._wasMaximizedOnStart) && restoreSetting === RestoreOn.ON_GRAB_START ) { - // HACK: - // The grab begin signal (and thus this function call) gets fired - // at the moment of the first click. However I don't want to restore - // the window size on just a click. Only if the user actually wanted - // to start a grab i.e. if the click is held for a bit or if the - // cursor moved while holding the click. I assume a cursor change - // means the grab was released since I couldn't find a better way... - let grabReleased = false; - let cursorId = global.display.connect('cursor-updated', () => { - grabReleased = true; - cursorId && global.display.disconnect(cursorId); - cursorId = 0; - }); - // Clean up in case my assumption mentioned above is wrong - // and the cursor never gets updated or something else... - this._cursorChangeTimerId && GLib.Source.remove(this._cursorChangeTimerId); - this._cursorChangeTimerId = GLib.timeout_add(GLib.PRIORITY_LOW, 400, () => { - cursorId && global.display.disconnect(cursorId); - cursorId = 0; - this._cursorChangeTimerId = null; - return GLib.SOURCE_REMOVE; - }); - let counter = 0; this._restoreSizeTimerId && GLib.Source.remove(this._restoreSizeTimerId); this._restoreSizeTimerId = GLib.timeout_add(GLib.PRIORITY_HIGH_IDLE, 10, () => { - if (grabReleased) { + if (!global.display.is_grabbed()) { this._restoreSizeTimerId = null; return GLib.SOURCE_REMOVE; }