From 086a6da37dc4fe51e4fe0445a03a7791934770ef Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Thu, 20 Apr 2023 23:21:30 +1000 Subject: [PATCH 01/26] Added Polyfil for Meta.add_later. --- tiling.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tiling.js b/tiling.js index d4ee4c65..ec6f6d60 100644 --- a/tiling.js +++ b/tiling.js @@ -32,6 +32,13 @@ var Gdk = imports.gi.Gdk; var workspaceManager = global.workspace_manager; var display = global.display; +// Polyfill for Gnome 44 +if (!Meta.later_add) { + Meta.later_add = function(...args) { + global.compositor.get_laters().add(...args); + } +} + /** @type {Spaces} */ var spaces; From 56023a79c5f827749de2bd868208570553b60cca Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sat, 22 Apr 2023 12:07:39 +1000 Subject: [PATCH 02/26] Added optional chain for `.end_grab_op` since in Gnome 44 it's been replaced with new clutter grabs. --- grab.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grab.js b/grab.js index d6073bb5..9b4c89df 100644 --- a/grab.js +++ b/grab.js @@ -50,8 +50,11 @@ var MoveGrab = class MoveGrab { this.center = center; if (this.grabbed) return; + this.grabbed = true - global.display?.end_grab_op(global.get_current_time()); + + global.display.end_grab_op?.(global.get_current_time()); + global.display.set_cursor(Meta.Cursor.MOVE_OR_RESIZE_WINDOW); this.dispatcher = new Navigator.getActionDispatcher(Clutter.GrabState.POINTER) this.actor = this.dispatcher.actor From 20c85d1247b1d8b726ef3d23b1b024f18fd3c7c2 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sat, 22 Apr 2023 14:38:11 +1000 Subject: [PATCH 03/26] FIX for another grab-related bug, see https://github.com/paperwm/PaperWM/commit/88f793c20b6db74e43d98db4699ddcde7a69ea61#r110071632. --- navigator.js | 1 - 1 file changed, 1 deletion(-) diff --git a/navigator.js b/navigator.js index 94811d44..d6090326 100644 --- a/navigator.js +++ b/navigator.js @@ -87,7 +87,6 @@ function getModLock(mods) { grab = Main.pushModal(this.actor) // We expect at least a keyboard grab here if ((grab.get_seat_state() & Clutter.GrabState.KEYBOARD) === 0) { - Main.popModal(grabHandle); log("Failed to grab modal"); throw new Error('Could not grab modal') } From c28a3da085db624f66e4a58f0bc6b9637bbaca8e Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sat, 22 Apr 2023 15:03:02 +1000 Subject: [PATCH 04/26] Add guard/check to showWindow and animateWindow since I ran into a Window.clone undefined exception during testing. --- tiling.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tiling.js b/tiling.js index ec6f6d60..0c74e39c 100644 --- a/tiling.js +++ b/tiling.js @@ -3318,8 +3318,10 @@ function showWindow(metaWindow) { let actor = metaWindow.get_compositor_private(); if (!actor) return false; - metaWindow.clone.cloneActor.hide(); - metaWindow.clone.cloneActor.source = null; + if (metaWindow.clone?.cloneActor) { + metaWindow.clone.cloneActor.hide(); + metaWindow.clone.cloneActor.source = null; + } actor.show(); return true; } @@ -3328,8 +3330,10 @@ function animateWindow(metaWindow) { let actor = metaWindow.get_compositor_private(); if (!actor) return false; - metaWindow.clone.cloneActor.show(); - metaWindow.clone.cloneActor.source = actor; + if (metaWindow.clone?.cloneActor) { + metaWindow.clone.cloneActor.show(); + metaWindow.clone.cloneActor.source = actor; + } actor.hide(); return true; } From c5760279987a69716a751a978110c7a89dd05ff5 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sun, 23 Apr 2023 22:05:09 +1000 Subject: [PATCH 05/26] Moved polyfill to kludges.js (where it should be). Cleaned up and grouped other polyfills. --- kludges.js | 33 ++++++++++++++++++++++----------- tiling.js | 7 ------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/kludges.js b/kludges.js index eb4d4ad1..95e3c93c 100644 --- a/kludges.js +++ b/kludges.js @@ -43,29 +43,25 @@ function overrideHotCorners() { } } +// polyfill for 3.28 (`get_monitor_scale` first appeared in 3.31.92). if (!global.display.get_monitor_scale) { - // `get_monitor_scale` first appeared in 3.31.92. Polyfill a fallback for 3.28 global.display.constructor.prototype.get_monitor_scale = () => 1.0; } +// polyfill for 3.28 (`get_monitor_neighbor_index`) if (!global.display.get_monitor_neighbor_index) { - // `get_monitor_neighbor_index` polyfill a fallback for 3.28 global.display.constructor.prototype.get_monitor_neighbor_index = function(...args) { return global.screen.get_monitor_neighbor_index(...args); } } -if (!global.display.set_cursor) { - global.display.constructor.prototype.set_cursor = global.screen.set_cursor.bind(global.screen); -} - // polyfill for 3.28 if (!Meta.DisplayDirection && Meta.ScreenDirection) { Meta.DisplayDirection = Meta.ScreenDirection; } +// polyfill for 3.28 if (!St.Settings) { - // `St.Settings` doesn't exist in 3.28 - polyfill: let Gtk = imports.gi.Gtk; let gtkSettings = Gtk.Settings.get_default(); let polyfillSettings = new (class PolyfillStSettings { @@ -82,14 +78,14 @@ if (!St.Settings) { }; } +// polyfill for 3.28 if (!Clutter.Actor.prototype.set) { - // `set` doesn't exist in 3.28 - polyfill: Clutter.Actor.prototype.set = function(params) { Object.assign(this, params); } } -// Polyfill gnome-3.34 transition API, taken from gnome-shell/js/ui/environment.js +// polyfill 3.34 transition API, taken from gnome-shell/js/ui/environment.js if (version[0] >= 3 && version[1] < 34) { function _makeEaseCallback(params, cleanup) { let onComplete = params.onComplete; @@ -179,7 +175,12 @@ if (version[0] >= 3 && version[1] < 34) { }; } -// Polyfill +// polyfill +if (!global.display.set_cursor) { + global.display.constructor.prototype.set_cursor = global.screen.set_cursor.bind(global.screen); +} + +// polyfill if (!Clutter.Actor.prototype.raise) { Clutter.Actor.prototype.raise = function raise(above) { const parent = this.get_parent(); @@ -189,12 +190,14 @@ if (!Clutter.Actor.prototype.raise) { } } +// polyfill if (!Clutter.Actor.prototype.raise_top) { Clutter.Actor.prototype.raise_top = function raise_top() { this.raise(null); } } +// polyfill if (!Clutter.Actor.prototype.reparent) { Clutter.Actor.prototype.reparent = function reparent(newParent) { const parent = this.get_parent(); @@ -205,11 +208,19 @@ if (!Clutter.Actor.prototype.reparent) { } } -if (! Clutter.Vertex) { +// polyfill +if (!Clutter.Vertex) { const {Graphene} = imports.gi; Clutter.Vertex = Graphene.Point3D; } +// polyfill for 44 +if (!Meta.later_add && global.compositor?.get_laters()) { + Meta.later_add = function(...args) { + global.compositor.get_laters().add(...args); + } +} + // Workspace.Workspace._realRecalculateWindowPositions // Sort tiled windows in the correct order function _realRecalculateWindowPositions(flags) { diff --git a/tiling.js b/tiling.js index 0c74e39c..7cb4e4de 100644 --- a/tiling.js +++ b/tiling.js @@ -32,13 +32,6 @@ var Gdk = imports.gi.Gdk; var workspaceManager = global.workspace_manager; var display = global.display; -// Polyfill for Gnome 44 -if (!Meta.later_add) { - Meta.later_add = function(...args) { - global.compositor.get_laters().add(...args); - } -} - /** @type {Spaces} */ var spaces; From 566f628c5bf0d985b74b9f685f21554e2f961ebd Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 25 Apr 2023 11:27:19 +1000 Subject: [PATCH 06/26] FIX: no longer require second click to "click out" of pointer grab operation to force `end_grab_op`. --- grab.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/grab.js b/grab.js index 9b4c89df..cdc957cd 100644 --- a/grab.js +++ b/grab.js @@ -476,6 +476,17 @@ var MoveGrab = class MoveGrab { } global.display.set_cursor(Meta.Cursor.DEFAULT); + + /** + * Gnome 44 removed the ability to manually end_grab_op. + * Previously we would end the grab_op before doing + * PaperWM grabs. In 44, we can't do this so the grab op + * may still be in progress, which is okay, but won't be ended + * until we "click out". We do this here if needed. + */ + if (!global.display.end_grab_op) { + imports.gi.Atspi.generate_mouse_event(0,0,'b1c'); + } } activateDndTarget(zone, first) { From 00fc8a9fed2bb06649000dc1b7d24ebcb2945a05 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 25 Apr 2023 13:37:50 +1000 Subject: [PATCH 07/26] Updated readme to add gnome 44 as supported and clarify previous release support. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 56ec45a0..8b0856b3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ PaperWM is an experimental [Gnome Shell](https://wiki.gnome.org/Projects/GnomeShell) extension providing scrollable tiling of windows and per monitor workspaces. It's inspired by paper notebooks and tiling window managers. -Supports Gnome Shell from 3.28 to 43 on X11 and wayland. +Supports Gnome Shell from 3.28 to 44 on X11 and wayland. + +>**Note:** while PaperWM can be installed on a wide range of Gnome versions, fixes and new features, in general, aren't backported to prevous Gnome Shell versions. While technically an [extension](https://wiki.gnome.org/Projects/GnomeShell/Extensions) it's to a large extent built on top of the Gnome desktop rather than merely extending it. @@ -14,8 +16,8 @@ We hang out on [zulip](https://paperwm.zulipchat.com). Clone the repo and check out the branch supporting the Gnome Shell version you're running. -- 44 (experimental, not officially supported yet, please report bugs): https://github.com/paperwm/PaperWM/tree/develop -- 43 (experimental, please report bugs): https://github.com/paperwm/PaperWM/tree/develop +- 44 (targeted for current support, please report bugs): https://github.com/paperwm/PaperWM/tree/develop +- 43 (targeted for current support, please report bugs): https://github.com/paperwm/PaperWM/tree/develop - 42: https://github.com/paperwm/PaperWM/tree/gnome-42 - 40: https://github.com/paperwm/PaperWM/tree/gnome-40 - 3.28-3.38: https://github.com/paperwm/PaperWM/tree/gnome-3.38 From efb3cb681a473664955d9543a14a78d3332ac978 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 25 Apr 2023 18:20:23 +1000 Subject: [PATCH 08/26] Revert "FIX: no longer require second click to "click out" of pointer grab operation to force `end_grab_op`." `gi.Atspi` appears to have severe issues in Wayland - was getting gnome shell hard crash in wayland with this (X11 is fine). This reverts commit 566f628c5bf0d985b74b9f685f21554e2f961ebd. --- grab.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/grab.js b/grab.js index cdc957cd..9b4c89df 100644 --- a/grab.js +++ b/grab.js @@ -476,17 +476,6 @@ var MoveGrab = class MoveGrab { } global.display.set_cursor(Meta.Cursor.DEFAULT); - - /** - * Gnome 44 removed the ability to manually end_grab_op. - * Previously we would end the grab_op before doing - * PaperWM grabs. In 44, we can't do this so the grab op - * may still be in progress, which is okay, but won't be ended - * until we "click out". We do this here if needed. - */ - if (!global.display.end_grab_op) { - imports.gi.Atspi.generate_mouse_event(0,0,'b1c'); - } } activateDndTarget(zone, first) { From 10cf92c2453e6c985dedf8d9305227313b6dc288 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Thu, 27 Apr 2023 05:11:35 +1000 Subject: [PATCH 09/26] FIX (wayland compatible): no longer require second click to "click out" of pointer grab operation to force `end_grab_op` Now using Clutter virtual device to "click out" - safe to use in X11 and Wayland. --- grab.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/grab.js b/grab.js index 9b4c89df..bc17ede7 100644 --- a/grab.js +++ b/grab.js @@ -18,13 +18,13 @@ var Utils = Extension.imports.utils; var Tweener = Utils.tweener; var Navigator = Extension.imports.navigator; +var virtualPointer; function isInRect(x, y, r) { return r.x <= x && x < r.x + r.width && r.y <= y && y < r.y + r.height; } - function monitorAtPoint(gx, gy) { for (let monitor of Main.layoutManager.monitors) { if (isInRect(gx, gy, monitor)) @@ -33,6 +33,22 @@ function monitorAtPoint(gx, gy) { return null; } +/** + * Returns a virtual pointer (i.e. mouse) device that can be used to + * "clickout" of a drag operation when `grab_end_op` is unavailable + * (i.e. as of Gnome 44 where `grab_end_op` was removed). + * @returns Clutter.VirtualInputDevice + */ +function getVirtualPointer() { + if (!virtualPointer) { + virtualPointer = Clutter.get_default_backend() + .get_default_seat() + .create_virtual_device(Clutter.InputDeviceType.POINTER_DEVICE); + } + + return virtualPointer; +} + var MoveGrab = class MoveGrab { constructor(metaWindow, type, space) { this.window = metaWindow; @@ -476,6 +492,20 @@ var MoveGrab = class MoveGrab { } global.display.set_cursor(Meta.Cursor.DEFAULT); + + /** + * Gnome 44 removed the ability to manually end_grab_op. + * Previously we would end the grab_op before doing + * PaperWM grabs. In 44, we can't do this so the grab op + * may still be in progress, which is okay, but won't be ended + * until we "click out". We do this here if needed. + */ + if (!global.display.end_grab_op) { + getVirtualPointer().notify_button(Clutter.get_current_event_time(), + Clutter.BUTTON_PRIMARY, Clutter.ButtonState.PRESSED); + getVirtualPointer().notify_button(Clutter.get_current_event_time(), + Clutter.BUTTON_PRIMARY, Clutter.ButtonState.RELEASED); + } } activateDndTarget(zone, first) { From 9918ed4c083f0f2386bebe880387455ffc54a289 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Thu, 27 Apr 2023 06:10:54 +1000 Subject: [PATCH 10/26] Added new GrabOp type introduced in Gnome 44 (MOVING_UNCONSTRAINED) --- tiling.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tiling.js b/tiling.js index 7cb4e4de..0b3edc79 100644 --- a/tiling.js +++ b/tiling.js @@ -3145,6 +3145,7 @@ function grabBegin(metaWindow, type) { }) break; case Meta.GrabOp.MOVING: + case Meta.GrabOp.MOVING_UNCONSTRAINED: // introduced in Gnome 44 inGrab = new Extension.imports.grab.MoveGrab(metaWindow, type); if (utils.getModiferState() & Clutter.ModifierType.CONTROL_MASK) { From dd3bbb0b2afadf1adc9ee98b5dee0a26aa7452f2 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Thu, 27 Apr 2023 20:54:51 +1000 Subject: [PATCH 11/26] FIX: avoid 'click out' for scratch or floating windows (extra click can cause holding onto titlebar and maximizing window). Moved click out to main loop after activate. --- grab.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/grab.js b/grab.js index bc17ede7..59e0d712 100644 --- a/grab.js +++ b/grab.js @@ -480,6 +480,25 @@ var MoveGrab = class MoveGrab { // ensure window is properly activated after layout/ensureViewport tweens Mainloop.timeout_add(0, () => { Main.activateWindow(metaWindow); + + // if floating or scratch, then exit (no need to click-out) + if (this.initialSpace.isFloating(metaWindow) || + Scratch.isScratchWindow(metaWindow)) { + return; + } + /** + * Gnome 44 removed the ability to manually end_grab_op. + * Previously we would end the grab_op before doing + * PaperWM grabs. In 44, we can't do this so the grab op + * may still be in progress, which is okay, but won't be ended + * until we "click out". We do this here if needed. + */ + if (!global.display.end_grab_op) { + getVirtualPointer().notify_button(Clutter.get_current_event_time(), + Clutter.BUTTON_PRIMARY, Clutter.ButtonState.PRESSED); + getVirtualPointer().notify_button(Clutter.get_current_event_time(), + Clutter.BUTTON_PRIMARY, Clutter.ButtonState.RELEASED); + } }); // // Make sure the window is on the correct workspace. @@ -492,20 +511,6 @@ var MoveGrab = class MoveGrab { } global.display.set_cursor(Meta.Cursor.DEFAULT); - - /** - * Gnome 44 removed the ability to manually end_grab_op. - * Previously we would end the grab_op before doing - * PaperWM grabs. In 44, we can't do this so the grab op - * may still be in progress, which is okay, but won't be ended - * until we "click out". We do this here if needed. - */ - if (!global.display.end_grab_op) { - getVirtualPointer().notify_button(Clutter.get_current_event_time(), - Clutter.BUTTON_PRIMARY, Clutter.ButtonState.PRESSED); - getVirtualPointer().notify_button(Clutter.get_current_event_time(), - Clutter.BUTTON_PRIMARY, Clutter.ButtonState.RELEASED); - } } activateDndTarget(zone, first) { From 9caf8e8318f28cb5b2a9d5d7b62ca7bb19758c31 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Thu, 27 Apr 2023 23:52:40 +1000 Subject: [PATCH 12/26] FIXES: clickout of grab operation now replicates current cursor position. Also moved to Meta.LaterType.BEFORE_REDRAW for safety. --- grab.js | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/grab.js b/grab.js index 59e0d712..abcbe293 100644 --- a/grab.js +++ b/grab.js @@ -475,30 +475,10 @@ var MoveGrab = class MoveGrab { // and layout will work correctly etc. this.window = null; - this.initialSpace.layout(); // ensure window is properly activated after layout/ensureViewport tweens - Mainloop.timeout_add(0, () => { + Meta.later_add(Meta.LaterType.IDLE, () => { Main.activateWindow(metaWindow); - - // if floating or scratch, then exit (no need to click-out) - if (this.initialSpace.isFloating(metaWindow) || - Scratch.isScratchWindow(metaWindow)) { - return; - } - /** - * Gnome 44 removed the ability to manually end_grab_op. - * Previously we would end the grab_op before doing - * PaperWM grabs. In 44, we can't do this so the grab op - * may still be in progress, which is okay, but won't be ended - * until we "click out". We do this here if needed. - */ - if (!global.display.end_grab_op) { - getVirtualPointer().notify_button(Clutter.get_current_event_time(), - Clutter.BUTTON_PRIMARY, Clutter.ButtonState.PRESSED); - getVirtualPointer().notify_button(Clutter.get_current_event_time(), - Clutter.BUTTON_PRIMARY, Clutter.ButtonState.RELEASED); - } }); // // Make sure the window is on the correct workspace. @@ -511,6 +491,28 @@ var MoveGrab = class MoveGrab { } global.display.set_cursor(Meta.Cursor.DEFAULT); + + /** + * Gnome 44 removed the ability to manually end_grab_op. + * Previously we would end the grab_op before doing + * PaperWM grabs. In 44, we can't do this so the grab op + * may still be in progress, which is okay, but won't be ended + * until we "click out". We do this here if needed. + */ + Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => { + if (!global.display.end_grab_op) { + // move to current cursort position + let [x, y, _mods] = global.get_pointer(); + getVirtualPointer().notify_absolute_motion( + Clutter.get_current_event_time(), + x, y); + + getVirtualPointer().notify_button(Clutter.get_current_event_time(), + Clutter.BUTTON_PRIMARY, Clutter.ButtonState.PRESSED); + getVirtualPointer().notify_button(Clutter.get_current_event_time(), + Clutter.BUTTON_PRIMARY, Clutter.ButtonState.RELEASED); + } + }); } activateDndTarget(zone, first) { From 47a6d9ead03c899a96cf5efe57d7b747a74db262 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Fri, 28 Apr 2023 04:50:29 +1000 Subject: [PATCH 13/26] FIX: for scratch or floating window click-out causing a re-grab op. See https://github.com/paperwm/PaperWM/issues/495#issuecomment-1526807903. --- grab.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grab.js b/grab.js index abcbe293..5eb45832 100644 --- a/grab.js +++ b/grab.js @@ -58,6 +58,10 @@ var MoveGrab = class MoveGrab { this.initialSpace = space || Tiling.spaces.spaceOfWindow(metaWindow); this.zoneActors = new Set(); + + // save whether this was tiled window at start of grab + this.wasTiled = !(this.initialSpace.isFloating(metaWindow) || + Scratch.isScratchWindow(metaWindow)); } begin({center} = {}) { @@ -500,7 +504,7 @@ var MoveGrab = class MoveGrab { * until we "click out". We do this here if needed. */ Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => { - if (!global.display.end_grab_op) { + if (!global.display.end_grab_op && this.wasTiled) { // move to current cursort position let [x, y, _mods] = global.get_pointer(); getVirtualPointer().notify_absolute_motion( From 98b5524d2af95c562d838d8357e0111958967782 Mon Sep 17 00:00:00 2001 From: Tomislav Levanic Date: Mon, 1 May 2023 00:09:29 +0200 Subject: [PATCH 14/26] Remove Gnome tiling left/right shortcuts --- set-recommended-gnome-shell-settings.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/set-recommended-gnome-shell-settings.sh b/set-recommended-gnome-shell-settings.sh index 1b0cb90a..6cc7535e 100755 --- a/set-recommended-gnome-shell-settings.sh +++ b/set-recommended-gnome-shell-settings.sh @@ -51,7 +51,9 @@ set-with-backup org.gnome.shell.overrides edge-tiling false # Attached modal dialogs isn't handled very well set-with-backup org.gnome.shell.overrides attach-modal-dialogs false - +# Gnome 44 tiling left/right shortcuts collide with PaperWM shortcuts (super + left/right) +set-with-backup org.gnome.mutter.keybindings toggle-tiled-left "[]" +set-with-backup org.gnome.mutter.keybindings toggle-tiled-right "[]" echo echo "Run $RESTORE_SETTINGS_SCRIPT to revert changes" From e74ec481464b586b7c2f1b6ec38b46da7b0c577f Mon Sep 17 00:00:00 2001 From: Tomislav Levanic Date: Wed, 3 May 2023 13:27:05 +0200 Subject: [PATCH 15/26] Add the description for overriding GNOME tiling shortcuts to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8b0856b3..f23fd48b 100644 --- a/README.md +++ b/README.md @@ -432,6 +432,8 @@ There's a few Gnome Shell settings which works poorly with PaperWM. Namely spanning all monitors - `edge-tiling`: We don't support the native half tiled windows - `attach-modal-dialogs`: Attached modal dialogs can cause visual glitching +- `toggle-tiled-left`: Default GNOME keyboard shortcut `super+left` collides with a default PaperWM shortcut. We disable the GNOME shortcut +- `toggle-tiled-right`: Default GNOME keyboard shortcut `super+right` collides with a default PaperWM shortcut. We disable the GNOME shortcut To use the recommended settings run [`set-recommended-gnome-shell-settings.sh`](https://github.com/paperwm/PaperWM/blob/master/set-recommended-gnome-shell-settings.sh). A "restore previous settings" script is generated so the original settings is not lost. From c582a53c71f8b2ee3e21dfff879efc307a4e8b1d Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sun, 14 May 2023 18:19:15 +1000 Subject: [PATCH 16/26] FIX: for simple window selection do not initate a move-grab operation (previous versions did this). Simplifying this behaviour avoids getting stuck in a move-grab operations when clicking on a window. --- grab.js | 2 +- tiling.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/grab.js b/grab.js index 5eb45832..960bd146 100644 --- a/grab.js +++ b/grab.js @@ -503,7 +503,7 @@ var MoveGrab = class MoveGrab { * may still be in progress, which is okay, but won't be ended * until we "click out". We do this here if needed. */ - Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => { + Meta.later_add(Meta.LaterType.IDLE, () => { if (!global.display.end_grab_op && this.wasTiled) { // move to current cursort position let [x, y, _mods] = global.get_pointer(); diff --git a/tiling.js b/tiling.js index 0b3edc79..da4c7e6e 100644 --- a/tiling.js +++ b/tiling.js @@ -1399,8 +1399,12 @@ border-radius: ${borderWidth}px; if (windowAtPoint) { ensureViewport(windowAtPoint, this); spaces.selectedSpace = this - inGrab = new Extension.imports.grab.MoveGrab(windowAtPoint, Meta.GrabOp.MOVING, this); - inGrab.begin(); + /** + * disabled to address gnome-44 grab issues. Simple selection of window + * should not execute a MoveGrab (avoid getting stuck in grab state). + */ + //inGrab = new Extension.imports.grab.MoveGrab(windowAtPoint, Meta.GrabOp.MOVING, this); + //inGrab.begin(); } else if (inPreview) { spaces.selectedSpace = this; Navigator.getNavigator().finish(); @@ -1666,11 +1670,12 @@ var Spaces = class Spaces extends Map { this.signals.connect(display, 'window-created', this.window_created.bind(this)); + this.signals.connect(display, 'grab-op-begin', (display, mw, type) => grabBegin(mw, type)); this.signals.connect(display, 'grab-op-end', (display, mw, type) => grabEnd(mw, type)); - + this.signals.connect(Main.layoutManager, 'monitors-changed', this.monitorsChanged.bind(this)); this.signals.connect(global.window_manager, 'switch-workspace', From 82ad90986d69ae8b1d95b2eee01efac9924787a3 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sun, 14 May 2023 20:10:47 +1000 Subject: [PATCH 17/26] FIX: warpPointer method fixed to use Clutter.get_default_backend(). FIX: resizing with decrement/increment size steps now uses display.focus_window if metaWindow not defined. --- tiling.js | 4 ++++ utils.js | 16 +++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tiling.js b/tiling.js index da4c7e6e..426348ba 100644 --- a/tiling.js +++ b/tiling.js @@ -3376,6 +3376,7 @@ function toggleMaximizeHorizontally(metaWindow) { } function resizeHInc(metaWindow) { + metaWindow = metaWindow || display.focus_window; let frame = metaWindow.get_frame_rect(); let monitor = Main.layoutManager.monitors[metaWindow.get_monitor()]; let space = spaces.spaceOfWindow(metaWindow); @@ -3396,6 +3397,7 @@ function resizeHInc(metaWindow) { } function resizeHDec(metaWindow) { + metaWindow = metaWindow || display.focus_window; let frame = metaWindow.get_frame_rect(); let monitor = Main.layoutManager.monitors[metaWindow.get_monitor()]; let space = spaces.spaceOfWindow(metaWindow); @@ -3417,6 +3419,7 @@ function resizeHDec(metaWindow) { } function resizeWInc(metaWindow) { + metaWindow = metaWindow || display.focus_window; let frame = metaWindow.get_frame_rect(); let monitor = Main.layoutManager.monitors[metaWindow.get_monitor()]; let space = spaces.spaceOfWindow(metaWindow); @@ -3437,6 +3440,7 @@ function resizeWInc(metaWindow) { } function resizeWDec(metaWindow) { + metaWindow = metaWindow || display.focus_window; let frame = metaWindow.get_frame_rect(); let monitor = Main.layoutManager.monitors[metaWindow.get_monitor()]; let space = spaces.spaceOfWindow(metaWindow); diff --git a/utils.js b/utils.js index 14ec2647..8fa52f06 100644 --- a/utils.js +++ b/utils.js @@ -270,7 +270,6 @@ function toggleCloneMarks() { } } - function sum(array) { return array.reduce((a, b) => a + b, 0); } @@ -285,18 +284,9 @@ function zip(...as) { } function warpPointer(x, y) { - // 3.36 added support for warping in wayland - if (Meta.is_wayland_compositor() && Clutter.Backend.prototype.get_default_seat) { - let backend = Clutter.get_default_backend(); - let seat = backend.get_default_seat(); - seat.warp_pointer(x, y); - return; - } else { - let display = Gdk.Display.get_default(); - let deviceManager = display.get_device_manager(); - let pointer = deviceManager.get_client_pointer(); - pointer.warp(Gdk.Screen.get_default(), x, y) - } + let backend = Clutter.get_default_backend(); + let seat = backend.get_default_seat(); + seat.warp_pointer(x, y); } /** From 1e108df2a858162ac2cc800faad7343bc7f1f89c Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sun, 14 May 2023 21:26:23 +1000 Subject: [PATCH 18/26] Updated `README.md` and pointing gnome 43 to the new gnome-43 branch. Develop is then targeting gnome-44. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f23fd48b..97f7ccc3 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ We hang out on [zulip](https://paperwm.zulipchat.com). Clone the repo and check out the branch supporting the Gnome Shell version you're running. - 44 (targeted for current support, please report bugs): https://github.com/paperwm/PaperWM/tree/develop -- 43 (targeted for current support, please report bugs): https://github.com/paperwm/PaperWM/tree/develop +- 43: https://github.com/paperwm/PaperWM/tree/gnome-43 - 42: https://github.com/paperwm/PaperWM/tree/gnome-42 - 40: https://github.com/paperwm/PaperWM/tree/gnome-40 - 3.28-3.38: https://github.com/paperwm/PaperWM/tree/gnome-3.38 From ce6768a861955421a1715035c358fd6b77e1d714 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sun, 14 May 2023 21:35:48 +1000 Subject: [PATCH 19/26] Updated PaperWM version number. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index dc41ab26..c64cbe50 100644 --- a/metadata.json +++ b/metadata.json @@ -5,6 +5,6 @@ "url": "https://github.com/paperwm/PaperWM", "settings-schema": "org.gnome.Shell.Extensions.PaperWM", "shell-version": [ "42", "43", "44" ], - "version": "43.0", + "version": "44.0", "session-modes": [ "unlock-dialog", "user" ] } From 477d546e5a78280cb324379a365225b0f702ad8d Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sun, 14 May 2023 21:43:45 +1000 Subject: [PATCH 20/26] Small improvement to README.md (formatting). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 97f7ccc3..fd3dbdeb 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ We hang out on [zulip](https://paperwm.zulipchat.com). Clone the repo and check out the branch supporting the Gnome Shell version you're running. -- 44 (targeted for current support, please report bugs): https://github.com/paperwm/PaperWM/tree/develop +- 44 (targeted for current support): https://github.com/paperwm/PaperWM/tree/develop - 43: https://github.com/paperwm/PaperWM/tree/gnome-43 - 42: https://github.com/paperwm/PaperWM/tree/gnome-42 - 40: https://github.com/paperwm/PaperWM/tree/gnome-40 From 7358da5466d0f03551c0036fd2da3f3bb4f7e37a Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Tue, 16 May 2023 04:42:04 +1000 Subject: [PATCH 21/26] FIX: in stack mode, if user clicks on window, ensureViewport on that viewport and exit stack mode. --- tiling.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tiling.js b/tiling.js index 426348ba..189309ac 100644 --- a/tiling.js +++ b/tiling.js @@ -1387,28 +1387,24 @@ border-radius: ${borderWidth}px; this.actor.insert_child_below(this.background, null); - this.signals.connect( - this.background, 'button-press-event', + this.signals.connect(this.background, 'button-press-event', (actor, event) => { if (inGrab) { return; } + + /** + * if user clicks on window, then ensureViewport on that window before exiting + */ let [gx, gy, $] = global.get_pointer(); let [ok, x, y] = this.actor.transform_stage_point(gx, gy); let windowAtPoint = !Gestures.gliding && this.getWindowAtPoint(x, y); if (windowAtPoint) { ensureViewport(windowAtPoint, this); - spaces.selectedSpace = this - /** - * disabled to address gnome-44 grab issues. Simple selection of window - * should not execute a MoveGrab (avoid getting stuck in grab state). - */ - //inGrab = new Extension.imports.grab.MoveGrab(windowAtPoint, Meta.GrabOp.MOVING, this); - //inGrab.begin(); - } else if (inPreview) { - spaces.selectedSpace = this; - Navigator.getNavigator().finish(); } + + spaces.selectedSpace = this; + Navigator.getNavigator().finish(); }); this.signals.connect( @@ -1502,7 +1498,6 @@ border-radius: ${borderWidth}px; layout of oldSpace if present. */ addAll(oldSpace) { - // On gnome-shell-restarts the windows are moved into the viewport, but // they're moved minimally and the stacking is not changed, so the tiling // order is preserved (sans full-width windows..) @@ -2159,7 +2154,6 @@ var Spaces = class Spaces extends Map { const padding_percentage = 4; let last = monitorSpaces.length - 1; monitorSpaces.forEach((space, i) => { - let padding = (space.height * scale / 100) * padding_percentage; let center = (space.height - (space.height * scale)) / 2; let space_y; From 477e87a4f04a01ad05245852c0cf645fd19bec0c Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Wed, 17 May 2023 08:45:56 +1000 Subject: [PATCH 22/26] Small change to guard end-grab if clone is null (and showed up in #524, although that was on gnome 42, which isn't strictly supported in this branch... but this change won't hurt). --- grab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grab.js b/grab.js index 960bd146..bbab2589 100644 --- a/grab.js +++ b/grab.js @@ -393,7 +393,7 @@ var MoveGrab = class MoveGrab { time: prefs.animation_time, scale_x: 1, scale_y: 1, - opacity: clone.__oldOpacity || 255 + opacity: clone?.__oldOpacity ?? 255, }; if (this.dnd) { From 3d0f25e2d12d2fb18be090e33e52b3a0a40b030d Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Fri, 19 May 2023 01:31:17 +1000 Subject: [PATCH 23/26] On enable, paperwm now disables known keybind clashes, including: org.gnome.desktop.wm.keybindings switch-group org.gnome.desktop.wm.keybindings switch-group-backward org.gnome.desktop.wm.keybindings switch-to-workspace-left org.gnome.desktop.wm.keybindings switch-to-workspace-right --- keybindings.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/keybindings.js b/keybindings.js index e5f9de72..d3d4cabc 100644 --- a/keybindings.js +++ b/keybindings.js @@ -10,6 +10,7 @@ var Gdk = imports.gi.Gdk; var Gtk = imports.gi.Gtk; var Gio = imports.gi.Gio; var Meta = imports.gi.Meta; +var GLib = imports.gi.GLib; var Utils = Extension.imports.utils; var Main = imports.ui.main; @@ -568,14 +569,38 @@ function getActionId(mutterName) { function overrideAction(mutterName, action) { let id = getActionId(mutterName); Main.wm.setCustomKeybindingHandler(mutterName, Shell.ActionMode.NORMAL, - action.keyHandler); + action.keyHandler); if (id === Meta.KeyBindingAction.NONE) return; actionIdMap[id] = action; } +/** + * Disables known keybind clashes with default gnome operations. + */ +function disableKnownClashes() { + // disable specific actions known to cause issues + const mutterbinds = convenience.getSettings('org.gnome.mutter.keybindings'); + [ + 'toggle-tiled-left', 'toggle-tiled-right' + ].forEach(key => { + try { + mutterbinds.set_value(key, new GLib.Variant('as', [])); + } catch (e) {} + }); + + const wmbinds = convenience.getSettings('org.gnome.desktop.wm.keybindings'); + [ + 'switch-group', 'switch-group-backward', + 'switch-to-workspace-left', 'switch-to-workspace-right', + ].forEach(key => { + try { + wmbinds.set_value(key, new GLib.Variant('as', [])); + } catch (e) {} + }); +} + function resolveConflicts() { - resetConflicts(); for (let conflict of Settings.findConflicts()) { let {name, conflicts} = conflict; let action = byMutterName(name); @@ -600,8 +625,7 @@ function resetConflicts() { ) { Main.wm.setCustomKeybindingHandler( name, - Shell.ActionMode.NORMAL | - Shell.ActionMode.OVERVIEW, + Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, Main.wm._showWorkspaceSwitcher.bind(Main.wm)); continue; } @@ -663,7 +687,7 @@ function resetConflicts() { break; case 'toggle-application-view': // overview._controls: Backward compatibility for 3.34 and below: - const viewSelector = (Main.overview._overview._controls || Main.overview.viewSelector || Main.overview._controls.viewSelector); + const viewSelector = (Main.overview._overview._controls || Main.overview.viewSelector || Main.overview._controls.viewSelector); Main.wm.setCustomKeybindingHandler( name, @@ -710,6 +734,7 @@ function resetConflicts() { } function enable() { + disableKnownClashes(); let schemas = [...Settings.conflictSettings, convenience.getSettings(KEYBINDINGS_KEY)]; schemas.forEach(schema => { From 1ac33b4620c1cecc9578eab50b92fbe2ee109673 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Fri, 19 May 2023 10:23:04 +1000 Subject: [PATCH 24/26] FIX: found root cause of keybind clashes! Was caused by method signature mismatch on Gtk.accelerator_parse. --- keybindings.js | 27 +-------------------------- settings.js | 2 +- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/keybindings.js b/keybindings.js index d3d4cabc..d92737cf 100644 --- a/keybindings.js +++ b/keybindings.js @@ -575,32 +575,8 @@ function overrideAction(mutterName, action) { actionIdMap[id] = action; } -/** - * Disables known keybind clashes with default gnome operations. - */ -function disableKnownClashes() { - // disable specific actions known to cause issues - const mutterbinds = convenience.getSettings('org.gnome.mutter.keybindings'); - [ - 'toggle-tiled-left', 'toggle-tiled-right' - ].forEach(key => { - try { - mutterbinds.set_value(key, new GLib.Variant('as', [])); - } catch (e) {} - }); - - const wmbinds = convenience.getSettings('org.gnome.desktop.wm.keybindings'); - [ - 'switch-group', 'switch-group-backward', - 'switch-to-workspace-left', 'switch-to-workspace-right', - ].forEach(key => { - try { - wmbinds.set_value(key, new GLib.Variant('as', [])); - } catch (e) {} - }); -} - function resolveConflicts() { + resetConflicts(); for (let conflict of Settings.findConflicts()) { let {name, conflicts} = conflict; let action = byMutterName(name); @@ -734,7 +710,6 @@ function resetConflicts() { } function enable() { - disableKnownClashes(); let schemas = [...Settings.conflictSettings, convenience.getSettings(KEYBINDINGS_KEY)]; schemas.forEach(schema => { diff --git a/settings.js b/settings.js index 4ab95cdc..a4103f20 100644 --- a/settings.js +++ b/settings.js @@ -242,7 +242,7 @@ function keystrToKeycombo(keystr) { keystr = keystr.replace('Above_Tab', 'A'); aboveTab = true; } - let [key, mask] = Gtk.accelerator_parse(keystr); + let [accel, key, mask] = Gtk.accelerator_parse(keystr); if (aboveTab) key = META_KEY_ABOVE_TAB; From 1103443fe9acd10eae70d36e3fe9d2c59f49d705 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sat, 20 May 2023 06:14:40 +1000 Subject: [PATCH 25/26] Removed Gnome 44 specific settings as not needed now (which disabled keybinds that used to clash before fixing keybind clash detection). Also renamed parameter for keybind fix to reflect Gtk documentation name better. --- set-recommended-gnome-shell-settings.sh | 4 ---- settings.js | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/set-recommended-gnome-shell-settings.sh b/set-recommended-gnome-shell-settings.sh index 6cc7535e..df13ed2f 100755 --- a/set-recommended-gnome-shell-settings.sh +++ b/set-recommended-gnome-shell-settings.sh @@ -51,9 +51,5 @@ set-with-backup org.gnome.shell.overrides edge-tiling false # Attached modal dialogs isn't handled very well set-with-backup org.gnome.shell.overrides attach-modal-dialogs false -# Gnome 44 tiling left/right shortcuts collide with PaperWM shortcuts (super + left/right) -set-with-backup org.gnome.mutter.keybindings toggle-tiled-left "[]" -set-with-backup org.gnome.mutter.keybindings toggle-tiled-right "[]" - echo echo "Run $RESTORE_SETTINGS_SCRIPT to revert changes" diff --git a/settings.js b/settings.js index a4103f20..57655599 100644 --- a/settings.js +++ b/settings.js @@ -242,7 +242,7 @@ function keystrToKeycombo(keystr) { keystr = keystr.replace('Above_Tab', 'A'); aboveTab = true; } - let [accel, key, mask] = Gtk.accelerator_parse(keystr); + let [ok, key, mask] = Gtk.accelerator_parse(keystr); if (aboveTab) key = META_KEY_ABOVE_TAB; From 18db715066e0d70f30233e72e3c2a59ee2037749 Mon Sep 17 00:00:00 2001 From: Jay Ta'ala Date: Sat, 20 May 2023 06:51:43 +1000 Subject: [PATCH 26/26] Change to README.md to clarify new features and fixes backporting. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd3dbdeb..9421ed32 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ PaperWM is an experimental [Gnome Shell](https://wiki.gnome.org/Projects/GnomeSh Supports Gnome Shell from 3.28 to 44 on X11 and wayland. ->**Note:** while PaperWM can be installed on a wide range of Gnome versions, fixes and new features, in general, aren't backported to prevous Gnome Shell versions. +>**Note:** while PaperWM can be installed on a wide range of Gnome versions, new features aren't generally backported to prevous Gnome Shell versions. Fixes may be backported on request (please submit a [new issue](https://github.com/paperwm/PaperWM/issues/new/choose) if you've identified a recent fix that should be backported and you can help with testing). While technically an [extension](https://wiki.gnome.org/Projects/GnomeShell/Extensions) it's to a large extent built on top of the Gnome desktop rather than merely extending it.