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

macos: implement resize overlay #2077

Merged
merged 5 commits into from
Aug 11, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
renderer: fix underflow possibility in padding calculation
mitchellh committed Aug 11, 2024
commit bac258e6d26581f81ff78db57eb3183370029b94
10 changes: 8 additions & 2 deletions src/renderer/size.zig
Original file line number Diff line number Diff line change
@@ -43,8 +43,14 @@ pub const ScreenSize = struct {
const grid_height = grid.rows * cell.height;
const padded_width = grid_width + (padding.left + padding.right);
const padded_height = grid_height + (padding.top + padding.bottom);
const leftover_width = self.width - padded_width;
const leftover_height = self.height - padded_height;

// Note these have to use a saturating subtraction to avoid underflow
// because our padding can cause the padded sizes to be larger than
// our real screen if the screen is shrunk to a minimal size such
// as 1x1.
const leftover_width = self.width -| padded_width;
const leftover_height = self.height -| padded_height;

return .{
.top = 0,
.bottom = leftover_height,