Skip to content

Commit

Permalink
Twm: Remove dead code in untile method
Browse files Browse the repository at this point in the history
The xAnchor parameter was used to restore the size of a window while
keeping the titlebar at the relative x position. Our extra calculations
were no longer needed (and also were no longer working) since GNOME 44
(https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942). So remove
that code.
  • Loading branch information
Leleat committed Jun 10, 2024
1 parent 0576f21 commit e5a1473
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
10 changes: 3 additions & 7 deletions tiling-assistant@leleat-on-github/src/extension/moveHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class MoveHandler {
const moveDist = getDistance(currPoint, oldPoint);

if (moveDist > 10) {
this._restoreSizeAndRestartGrab(window, x, y, grabOp);
this._restoreSizeAndRestartGrab(window, grabOp);

return GLib.SOURCE_REMOVE;
}
Expand Down Expand Up @@ -407,12 +407,8 @@ class MoveHandler {
}
}

_restoreSizeAndRestartGrab(window, px, py, grabOp) {
Twm.untile(window, {
restoreFullPos: false,
xAnchor: px,
skipAnim: this._wasMaximizedOnStart
});
_restoreSizeAndRestartGrab(window, grabOp) {
Twm.untile(window, { skipAnim: this._wasMaximizedOnStart });

this._onMoveStarted(window, grabOp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,10 @@ class TilingWindowManager {
* @param {boolean} [param.restoreFullPos=true] decides, if we restore the
* pre-tile position or whether the size while keeping the titlebar
* at the relative same position.
* @param {number} [param.xAnchor=undefined] used when wanting to restore the
* size while keeping titlebar at the relative x position. By default,
* we use the pointer position.
* @param {boolean} [param.skipAnim=false] decides, if we skip the until animation.
* @param {boolean} [param.clampToWorkspace=false] decides, if we skip the until animation.
*/
untile(window, { restoreFullPos = true, xAnchor = undefined, skipAnim = false, clampToWorkspace = false } = {}) {
untile(window, { restoreFullPos = true, skipAnim = false, clampToWorkspace = false } = {}) {
const wasMaximized = window.get_maximized();
if (wasMaximized)
window.unmaximize(wasMaximized);
Expand Down Expand Up @@ -285,16 +282,15 @@ class TilingWindowManager {
if (restoreFullPos) {
window.move_resize_frame(userOp, oldRect.x, oldRect.y, oldRect.width, oldRect.height);
} else {
// Resize the window while keeping the relative x pos (of the pointer)
const currWindowFrame = window.get_frame_rect();
xAnchor = xAnchor ?? global.get_pointer()[0];
const relativeMouseX = (xAnchor - currWindowFrame.x) / currWindowFrame.width;
const newPosX = xAnchor - oldRect.width * relativeMouseX;

// Wayland workaround for DND / restore position
Meta.is_wayland_compositor() && window.move_frame(true, newPosX, currWindowFrame.y);

window.move_resize_frame(userOp, newPosX, currWindowFrame.y, oldRect.width, oldRect.height);
window.move_resize_frame(
userOp,
currWindowFrame.x,
currWindowFrame.y,
oldRect.width,
oldRect.height
);
}

this.clearTilingProps(window.get_id());
Expand Down

0 comments on commit e5a1473

Please sign in to comment.