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

fix(desktop): enforce main window size constraints #230

Merged
Changes from all commits
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
27 changes: 27 additions & 0 deletions apps/desktop/src/routes/(window-chrome)/(main).tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
useQueryClient,
} from "@tanstack/solid-query";
import { getVersion } from "@tauri-apps/api/app";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { LogicalSize } from "@tauri-apps/api/window";
import { cx } from "cva";
import {
JSX,
Expand All @@ -17,6 +19,7 @@
createResource,
createSignal,
onMount,
onCleanup,
} from "solid-js";
import { createStore, produce } from "solid-js/store";
import { fetch } from "@tauri-apps/plugin-http";
Expand Down Expand Up @@ -102,6 +105,25 @@
}
}

// Enforce window size with multiple safeguards
const currentWindow = await getCurrentWindow();
const MAIN_WINDOW_SIZE = { width: 300, height: 360 };

// Set initial size
currentWindow.setSize(new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height));

// Check size when app regains focus
const unlistenFocus = await currentWindow.onFocusChanged(({ payload: focused }) => {
if (focused) {
currentWindow.setSize(new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height));
}
});

// Listen for resize events
const unlistenResize = await currentWindow.onResized(() => {
currentWindow.setSize(new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height));
});

setTitlebar("hideMaximize", true);
setTitlebar(
"items",
Expand All @@ -121,6 +143,11 @@
<ChangelogButton />
</div>
);

onCleanup(() => {
unlistenFocus();
unlistenResize();
});
});

return (
Expand All @@ -147,7 +174,7 @@
</span>
</div>
<div class="flex items-center space-x-2">
{window.FLAGS.customS3 && (

Check failure on line 177 in apps/desktop/src/routes/(window-chrome)/(main).tsx

View workflow job for this annotation

GitHub Actions / Typecheck

Property 'customS3' does not exist on type 'Flags'.
<Tooltip.Root openDelay={0}>
<Tooltip.Trigger>
<button
Expand Down
Loading