Skip to content

Commit

Permalink
keybindingHandler: maximize vertically/horizontally without gaps
Browse files Browse the repository at this point in the history
When maximizing a window vertically or horizontally, we've added gaps to
the window like we normally do to tiled windows. This makes sense if the
window is already tiled. If the window is floating, we shouldn't add
gaps to it and instead should keep the currently visible size.

Fixes #349
  • Loading branch information
Leleat committed Aug 5, 2024
1 parent 9c9b058 commit 731652c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/ignore-words.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
allws
Distro
finalX
finalY
fullscreen
gettext
Journalctl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,24 @@ export default class TilingKeybindingHandler {
Twm.untile(window);
}

// Maximize vertically even if the height may already be equal to the workArea
// e. g. via double-click titlebar, maximize-window-button or whatever
} else {
// is tiled normally
} else if (window.untiledRect) {
const tileRect = new Rect(currRect.x, workArea.y, currRect.width, workArea.height);
Twm.tile(window, tileRect);

// is floating
} else {
const width = Math.min(
currRect.width + Settings.getInt('window-gap'),
workArea.width
);
const constrainX = Math.max(
currRect.x - Settings.getInt('window-gap') / 2,
workArea.x
);
const finalX = Math.min(constrainX, workArea.x2 - width);
const tileRect = new Rect(finalX, workArea.y, width, workArea.height);
Twm.tile(window, tileRect);
}

// Toggle maximization horizontally
Expand All @@ -125,11 +138,24 @@ export default class TilingKeybindingHandler {
Twm.untile(window);
}

// Maximize horizontally even if the width may already be equal to the workArea
// e. g. via double-click titlebar, maximize-window-button or whatever
} else {
// is tiled normally
} else if (window.untiledRect) {
const tileRect = new Rect(workArea.x, currRect.y, workArea.width, currRect.height);
Twm.tile(window, tileRect);

// is floating
} else {
const height = Math.min(
currRect.height + Settings.getInt('window-gap'),
workArea.height
);
const constrainY = Math.max(
currRect.y - Settings.getInt('window-gap') / 2,
workArea.y
);
const finalY = Math.min(constrainY, workArea.y2 - height);
const tileRect = new Rect(workArea.x, finalY, workArea.width, height);
Twm.tile(window, tileRect);
}

// Restore window size
Expand Down

0 comments on commit 731652c

Please sign in to comment.