Skip to content
Open
Show file tree
Hide file tree
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
95 changes: 20 additions & 75 deletions electron/hudOverlayBounds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,21 @@ describe("getHudOverlayWindowBounds", () => {
expect(getHudOverlayWindowBounds(workArea, true)).toEqual(workArea);
});

it("uses a bottom-centered compact fallback when mouse passthrough is unavailable", () => {
expect(getHudOverlayWindowBounds(workArea, false)).toEqual({
x: 650,
y: 920,
width: 860,
height: 160,
});
it("uses the full work area when mouse passthrough is supported", () => {
expect(getHudOverlayWindowBounds(workArea, true)).toEqual(workArea);
});

it("expands the non-passthrough fallback for HUD menus and hover interaction", () => {
expect(getHudOverlayWindowBounds(workArea, false, true)).toEqual({
x: 650,
y: 540,
width: 860,
height: 540,
});
it("uses full display work area bounds for the overlay window", () => {
expect(getHudOverlayWindowBounds(workArea, false)).toEqual(workArea);
Comment thread
sahilcodexx marked this conversation as resolved.
});

it("keeps the compact fallback inside small displays", () => {
expect(
getHudOverlayWindowBounds(
{
x: -100,
y: 20,
width: 640,
height: 420,
},
false,
),
).toEqual({
x: -100,
y: 280,
width: 640,
height: 160,
});
it("expands to full work area bounds", () => {
expect(getHudOverlayWindowBounds(workArea, false, true)).toEqual(workArea);
});

it("fits the expanded fallback inside small displays", () => {
expect(
getHudOverlayWindowBounds(
{
x: -100,
y: 20,
width: 640,
height: 420,
},
false,
true,
),
).toEqual({
x: -100,
y: 20,
width: 640,
height: 420,
});
it("preserves full work area bounds inside small displays", () => {
const small = { x: -100, y: 20, width: 640, height: 420 };
expect(getHudOverlayWindowBounds(small, false)).toEqual(small);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
});
});

Expand All @@ -84,64 +44,49 @@ describe("resizeHudOverlayFallbackBounds", () => {
height: 1080,
};

it("preserves the dragged bottom edge when expanding", () => {
it("returns full work area when expanding", () => {
expect(
resizeHudOverlayFallbackBounds(
workArea,
{
x: 420,
y: 700,
width: 860,
width: 1200,
height: 160,
},
true,
),
).toEqual({
x: 420,
y: 320,
width: 860,
height: 540,
});
).toEqual(workArea);
});

it("preserves the dragged bottom edge when compacting", () => {
it("returns full work area when compacting", () => {
expect(
resizeHudOverlayFallbackBounds(
workArea,
{
x: 420,
y: 320,
width: 860,
height: 540,
y: 260,
width: 1200,
height: 600,
},
false,
),
).toEqual({
x: 420,
y: 700,
width: 860,
height: 160,
});
).toEqual(workArea);
});

it("keeps resized fallback bounds inside the display work area", () => {
it("returns full work area inside the display work area", () => {
expect(
resizeHudOverlayFallbackBounds(
workArea,
{
x: 1500,
y: 900,
width: 860,
width: 1200,
height: 160,
},
true,
),
).toEqual({
x: 1060,
y: 520,
width: 860,
height: 540,
});
).toEqual(workArea);
});
});

Expand Down
10 changes: 7 additions & 3 deletions electron/hudOverlayBounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export interface HudOverlayWorkArea {
height: number;
}

const NON_PASSTHROUGH_HUD_WIDTH_DIP = 860;
const NON_PASSTHROUGH_HUD_WIDTH_DIP = 1200;
const NON_PASSTHROUGH_HUD_COMPACT_HEIGHT_DIP = 160;
const NON_PASSTHROUGH_HUD_EXPANDED_HEIGHT_DIP = 540;
const NON_PASSTHROUGH_HUD_EXPANDED_HEIGHT_DIP = 600;

function clamp(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max);
Expand All @@ -18,7 +18,7 @@ export function getHudOverlayWindowBounds(
mousePassthroughSupported: boolean,
fallbackExpanded = false,
): HudOverlayWorkArea {
if (mousePassthroughSupported) {
if (mousePassthroughSupported || process.platform === "linux") {
return { ...workArea };
}

Expand Down Expand Up @@ -55,6 +55,10 @@ export function resizeHudOverlayFallbackBounds(
currentBounds: HudOverlayWorkArea,
fallbackExpanded: boolean,
): HudOverlayWorkArea {
if (process.platform === "linux") {
return { ...workArea };
}

const nextBounds = getHudOverlayWindowBounds(workArea, false, fallbackExpanded);
const maxX = workArea.x + workArea.width - nextBounds.width;
const maxY = workArea.y + workArea.height - nextBounds.height;
Expand Down
4 changes: 1 addition & 3 deletions electron/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ function setHudOverlayMousePassthrough(ignore: boolean) {
}

if (!isHudOverlayMousePassthroughSupported()) {
if (process.platform !== "linux") {
setHudOverlayFallbackExpanded(!ignore);
}
setHudOverlayFallbackExpanded(!ignore);
hudOverlayWindow.setIgnoreMouseEvents(false);
return;
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/launch/LaunchWindow.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
align-items: center;
gap: 10px;
width: max-content;
max-width: 1200px;
max-width: 100%;
background: var(--launch-bar-bg);
border: 1px solid var(--launch-bar-border);
border-radius: 20px;
Expand Down Expand Up @@ -95,8 +95,6 @@
color: #4eeeb0;
}



.menuCard {
width: 300px;
max-height: 400px;
Expand Down