Skip to content

Commit

Permalink
Merge pull request #353 from Leleat/fix-349
Browse files Browse the repository at this point in the history
keybindingHandler: maximize vertically/horizontally without gaps
  • Loading branch information
Leleat authored Aug 5, 2024
2 parents 5af3a58 + 731652c commit 3dc55cb
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 3dc55cb

Please sign in to comment.