mirror of
https://github.com/siddharthvaddem/openscreen.git
synced 2026-11-02 04:54:20 +08:00
Use full-size layout and overflow clipping instead of 100vw/100vh on the HUD shell so the fixed 600×160 overlay does not gain a horizontal scrollbar when recording widens the toolbar. Fixes #305
75 lines
2.6 KiB
TypeScript
75 lines
2.6 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { LaunchWindow } from "./components/launch/LaunchWindow";
|
|
import { SourceSelector } from "./components/launch/SourceSelector";
|
|
import { Toaster } from "./components/ui/sonner";
|
|
import { TooltipProvider } from "./components/ui/tooltip";
|
|
import { ShortcutsConfigDialog } from "./components/video-editor/ShortcutsConfigDialog";
|
|
import VideoEditor from "./components/video-editor/VideoEditor";
|
|
import { ShortcutsProvider } from "./contexts/ShortcutsContext";
|
|
import { loadAllCustomFonts } from "./lib/customFonts";
|
|
|
|
export default function App() {
|
|
const [windowType, setWindowType] = useState("");
|
|
|
|
useEffect(() => {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const type = params.get("windowType") || "";
|
|
setWindowType(type);
|
|
if (type === "hud-overlay" || type === "source-selector") {
|
|
document.body.style.background = "transparent";
|
|
document.documentElement.style.background = "transparent";
|
|
document.getElementById("root")?.style.setProperty("background", "transparent");
|
|
}
|
|
|
|
// HUD window is a small fixed-size BrowserWindow (`electron/windows.ts`), not a full-screen
|
|
// surface. Pin the document shell to that viewport and hide overflow so the renderer cannot
|
|
// introduce scrollbars. Without this, `h-full` in `LaunchWindow` has no definite height chain
|
|
// from `html`/`body`, and stray overflow can still appear on some hosts (see issue #305).
|
|
if (type === "hud-overlay") {
|
|
document.documentElement.style.height = "100%";
|
|
document.documentElement.style.overflow = "hidden";
|
|
document.body.style.height = "100%";
|
|
document.body.style.margin = "0";
|
|
document.body.style.overflow = "hidden";
|
|
const root = document.getElementById("root");
|
|
root?.style.setProperty("height", "100%");
|
|
root?.style.setProperty("min-height", "0");
|
|
root?.style.setProperty("overflow", "hidden");
|
|
}
|
|
|
|
// Load custom fonts on app initialization
|
|
loadAllCustomFonts().catch((error) => {
|
|
console.error("Failed to load custom fonts:", error);
|
|
});
|
|
}, []);
|
|
|
|
const content = (() => {
|
|
switch (windowType) {
|
|
case "hud-overlay":
|
|
return <LaunchWindow />;
|
|
case "source-selector":
|
|
return <SourceSelector />;
|
|
case "editor":
|
|
return (
|
|
<ShortcutsProvider>
|
|
<VideoEditor />
|
|
<ShortcutsConfigDialog />
|
|
</ShortcutsProvider>
|
|
);
|
|
default:
|
|
return (
|
|
<div className="w-full h-full bg-background text-foreground">
|
|
<h1>Openscreen</h1>
|
|
</div>
|
|
);
|
|
}
|
|
})();
|
|
|
|
return (
|
|
<TooltipProvider>
|
|
{content}
|
|
<Toaster theme="dark" className="pointer-events-auto" />
|
|
</TooltipProvider>
|
|
);
|
|
}
|