Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: add Gnome 44 support #515

Merged
merged 27 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
086a6da
Added Polyfil for Meta.add_later.
jtaala Apr 20, 2023
56023a7
Added optional chain for `.end_grab_op` since in Gnome 44 it's been r…
jtaala Apr 22, 2023
20c85d1
FIX for another grab-related bug, see
jtaala Apr 22, 2023
c28a3da
Add guard/check to showWindow and animateWindow since I ran into a
jtaala Apr 22, 2023
c576027
Moved polyfill to kludges.js (where it should be). Cleaned up and gr…
jtaala Apr 23, 2023
566f628
FIX: no longer require second click to "click out" of pointer grab op…
jtaala Apr 25, 2023
00fc8a9
Updated readme to add gnome 44 as supported and clarify previous release
jtaala Apr 25, 2023
efb3cb6
Revert "FIX: no longer require second click to "click out" of pointer…
jtaala Apr 25, 2023
10cf92c
FIX (wayland compatible): no longer require second click to "click ou…
jtaala Apr 26, 2023
9918ed4
Added new GrabOp type introduced in Gnome 44 (MOVING_UNCONSTRAINED)
jtaala Apr 26, 2023
dd3bbb0
FIX: avoid 'click out' for scratch or floating windows (extra click c…
jtaala Apr 27, 2023
9caf8e8
FIXES: clickout of grab operation now replicates current cursor posit…
jtaala Apr 27, 2023
47a6d9e
FIX: for scratch or floating window click-out causing a re-grab op. …
jtaala Apr 27, 2023
98b5524
Remove Gnome tiling left/right shortcuts
tlevani Apr 30, 2023
e74ec48
Add the description for overriding GNOME tiling shortcuts to README
tlevani May 3, 2023
306543d
Remove Gnome tiling left/right shortcuts (#518)
jtaala May 4, 2023
c582a53
FIX: for simple window selection do not initate a move-grab operation
jtaala May 14, 2023
82ad909
FIX: warpPointer method fixed to use Clutter.get_default_backend().
jtaala May 14, 2023
1e108df
Updated `README.md` and pointing gnome 43 to the new gnome-43 branch.
jtaala May 14, 2023
ce6768a
Updated PaperWM version number.
jtaala May 14, 2023
477d546
Small improvement to README.md (formatting).
jtaala May 14, 2023
7358da5
FIX: in stack mode, if user clicks on window, ensureViewport on that
jtaala May 15, 2023
477e87a
Small change to guard end-grab if clone is null (and showed up in #524,
jtaala May 16, 2023
3d0f25e
On enable, paperwm now disables known keybind clashes, including:
jtaala May 18, 2023
1ac33b4
FIX: found root cause of keybind clashes! Was caused by method signature
jtaala May 19, 2023
1103443
Removed Gnome 44 specific settings as not needed now (which disabled …
jtaala May 19, 2023
18db715
Change to README.md to clarify new features and fixes backporting.
jtaala May 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down
42 changes: 40 additions & 2 deletions grab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
Expand All @@ -50,8 +66,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
Expand Down Expand Up @@ -461,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);
jtaala marked this conversation as resolved.
Show resolved Hide resolved
}
});

// // Make sure the window is on the correct workspace.
Expand Down
33 changes: 22 additions & 11 deletions kludges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
13 changes: 9 additions & 4 deletions tiling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -3311,8 +3312,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;
}
Expand All @@ -3321,8 +3324,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;
}
Expand Down