From da577b5116c2104b7c452b7ffe385a0579358fc3 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Tue, 6 May 2025 10:57:38 +0900 Subject: [PATCH] [bugfix] Fix corner rounded bug. before: win10, corner rounded true. win 11 corner rounded true and when window maximized likewise. after: win10, corner rounded false. win 11 corner rounded true but turn to false when window maximized. --- src-ui/app/App.jsx | 2 + .../CornerRadiusController.jsx | 53 +++++++++++++++++++ src-ui/app/_app_controllers/index.js | 3 +- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src-ui/app/_app_controllers/CornerRadiusController.jsx diff --git a/src-ui/app/App.jsx b/src-ui/app/App.jsx index d645d774..7dc99689 100644 --- a/src-ui/app/App.jsx +++ b/src-ui/app/App.jsx @@ -9,6 +9,7 @@ import { UiSizeController, FontFamilyController, TransparencyController, + CornerRadiusController, PluginsController, } from "./_app_controllers/index.js"; @@ -39,6 +40,7 @@ export const App = () => { + {(currentIsBackendReady.data === false || currentIsVrctAvailable.data === false) ? diff --git a/src-ui/app/_app_controllers/CornerRadiusController.jsx b/src-ui/app/_app_controllers/CornerRadiusController.jsx new file mode 100644 index 00000000..1b84b9ad --- /dev/null +++ b/src-ui/app/_app_controllers/CornerRadiusController.jsx @@ -0,0 +1,53 @@ +import { useState, useEffect } from "react"; +import { getCurrentWindow } from "@tauri-apps/api/window"; + +export const CornerRadiusController = () => { + const [is_win11, setIsWin11] = useState(false); + const [is_maximized, setIsMaximized] = useState(false); + + // OS 判定(Win11 なら platformVersion の major ≥13) + useEffect(() => { + if (navigator.userAgentData?.getHighEntropyValues) { + navigator.userAgentData + .getHighEntropyValues(["platformVersion"]) + .then(({ platformVersion }) => { + const major = parseInt(platformVersion.split(".")[0], 10); + setIsWin11(major >= 13); + }) + .catch(() => { + setIsWin11(false); + }) + } else { + // フォールバックで Win10 扱い + setIsWin11(false); + } + }, []) + + + useEffect(() => { + let unlisten; + const setup = async () => { + const window = await getCurrentWindow(); + // 初期状態取得 + setIsMaximized(await window.isMaximized()); + // リサイズ時にも再取得 + const updateMax = () => window.isMaximized().then(setIsMaximized); + unlisten = await window.listen("tauri://resize", updateMax); + } + setup(); + + return () => { + if (unlisten) { + unlisten(); + } + } + }, []); + + // 角丸の適用 + useEffect(() => { + const radius = is_win11 && !is_maximized ? "10px" : "0"; + document.body.style.borderRadius = radius; + }, [is_win11, is_maximized]); + + return null;; +} \ No newline at end of file diff --git a/src-ui/app/_app_controllers/index.js b/src-ui/app/_app_controllers/index.js index d71c8b6e..ea67d783 100644 --- a/src-ui/app/_app_controllers/index.js +++ b/src-ui/app/_app_controllers/index.js @@ -6,4 +6,5 @@ export { ConfigPageCloseTriggerController } from "./ConfigPageCloseTriggerContro export { UiSizeController } from "./UiSizeController"; export { FontFamilyController } from "./FontFamilyController"; export { TransparencyController } from "./TransparencyController"; -export { PluginsController } from "./PluginsController"; \ No newline at end of file +export { PluginsController } from "./PluginsController"; +export { CornerRadiusController } from "./CornerRadiusController"; \ No newline at end of file