From 11d695d50a852d9593061cd6d135ca6788f72a9f Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sun, 27 Sep 2026 18:38:05 -0700 Subject: [PATCH] Allow enabling or disabling custom decorations on windows --- src-tauri/src/lib.rs | 23 +++++--- src-tauri/tauri.windows.conf.json | 4 +- src/app/main/game/page.tsx | 3 +- src/app/main/layout.tsx | 15 ++++- src/app/main/library/page.tsx | 5 +- src/app/main/settings/page.tsx | 92 ++++++++++++++++++++++++------- src/app/update/layout.tsx | 9 +-- src/components/Sidebar.tsx | 55 +++++++++--------- src/providers/GlobalProvider.tsx | 1 + 9 files changed, 139 insertions(+), 68 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 7f13f27..a65ba6b 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -674,6 +674,19 @@ fn remove_stale_executable(app: AppHandle, version: String, executable: String) } } +#[allow(unused)] +#[tauri::command] +fn enable_custom_decorations_windows(app: AppHandle) { + #[cfg(target_os = "windows")] + { + use tauri_plugin_decorum::WebviewWindowExt; + + let window = app.get_webview_window("main").unwrap(); + window.set_decorations(false); + let _ = window.create_overlay_titlebar(); + } +} + #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { #[allow(unused)] @@ -714,7 +727,8 @@ pub fn run() { cancel_download, move_game_data, open_game_folder, - remove_stale_executable + remove_stale_executable, + enable_custom_decorations_windows ]) .setup(|app| { let custom_dir = app @@ -745,13 +759,6 @@ pub fn run() { } }); - #[cfg(target_os = "windows")] - { - use tauri_plugin_decorum::WebviewWindowExt; - if let Err(e) = window.create_overlay_titlebar() { - eprintln!("Failed to create overlay titlebar: {:?}", e); - } - } #[cfg(not(debug_assertions))] { use tauri_plugin_cli::CliExt; diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index e205c93..efbb2ab 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -18,9 +18,7 @@ "width": 1000, "height": 532, "minWidth": 1000, - "minHeight": 532, - "decorations": false, - "shadow": true + "minHeight": 532 } ], "security": { diff --git a/src/app/main/game/page.tsx b/src/app/main/game/page.tsx index fec8d7c..cd45e56 100644 --- a/src/app/main/game/page.tsx +++ b/src/app/main/game/page.tsx @@ -30,6 +30,7 @@ export default function GamePage () { needsRevisionUpdate, launchGame, developerMode, + useNativeDecorations, theme, accountSession, accountId, @@ -187,7 +188,7 @@ export default function GamePage () {
('dark') const [customDataLocation, setCustomDataLocation] = useState('') const [developerMode, setDeveloperMode] = useState(false) + const [useNativeDecorations, setUseNativeDecorations] = + useState(false) const [versionsList, setVersionsList] = useState>({}) const [modsList, setModsList] = useState< @@ -765,6 +767,13 @@ export default function RootLayout ({ await requestPermission() } + if ( + platform() == 'windows' && + !(settingsLocal.get('useNativeDecorations') ?? false) + ) { + invoke('enable_custom_decorations_windows') + } + setLoading(false) })() }, []) @@ -839,6 +848,9 @@ export default function RootLayout ({ setCustomDataLocation(v ?? '') ) watchSettings('developerMode', v => setDeveloperMode(v ?? false)) + watchSettings('useNativeDecorations', v => + setUseNativeDecorations(v ?? false) + ) watchVersions>('list', v => setVersionsList(v ?? {})) watchVersions>>('mods', v => @@ -902,6 +914,7 @@ export default function RootLayout ({ theme, customDataLocation, developerMode, + useNativeDecorations, versionsList, modsList, launchesList, @@ -923,7 +936,7 @@ export default function RootLayout ({ }} > - {platformName == 'windows' && ( + {platformName == 'windows' && !useNativeDecorations && (
)}
diff --git a/src/app/main/library/page.tsx b/src/app/main/library/page.tsx index cc09bc2..537dbb6 100644 --- a/src/app/main/library/page.tsx +++ b/src/app/main/library/page.tsx @@ -23,7 +23,8 @@ export default function LibraryPage () { setSelectedGame, setCategory, setManagingGame, - developerMode + developerMode, + useNativeDecorations } = useGlobal() const router = useRouter() @@ -59,7 +60,7 @@ export default function LibraryPage () {
Settings

- { - await settings?.set('linuxUseWine', !linuxUseWine) - }} - className={platform() == 'linux' ? '' : 'hidden'} - /> - {platform() == 'linux' && linuxUseWine && ( + {platform() == 'linux' && ( <> -

Wine Command:

- - await settings?.set('linuxWineCommand', e.target.value) - } - className='input-field my-1' - > + { + await settings?.set('linuxUseWine', !linuxUseWine) + }} + /> + {linuxUseWine && ( + <> +

Wine Command:

+ + await settings?.set('linuxWineCommand', e.target.value) + } + className='input-field my-1' + > + + )} + + )} + {platform() == 'windows' && ( + <> + { + if (useNativeDecorations) { + invoke('enable_custom_decorations_windows') + + const appWindow = getCurrentWindow() + const size = await appWindow.innerSize() + const newHeight = size.height - 32 + await appWindow.setSize( + new LogicalSize(size.width, newHeight) + ) + + await settings?.set( + 'useNativeDecorations', + !useNativeDecorations + ) + } else { + if ( + !(await ask( + 'Turning this off will require a launcher restart. If you have active downloads, you may want to wait before doing this.', + 'Are you sure?' + )) + ) { + return + } + const appWindow = getCurrentWindow() + appWindow.setDecorations(true) + + const size = await appWindow.innerSize() + const newHeight = size.height + 32 + await appWindow.setSize( + new LogicalSize(size.width, newHeight) + ) + + await settings?.set( + 'useNativeDecorations', + !useNativeDecorations + ) + await relaunch() + } + }} + /> )} - {platformName == 'windows' && ( -
- )} -
+
{children}
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index e46ca79..6197b53 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -44,6 +44,7 @@ export default function Sidebar () { setManagingGame, settings, developerMode, + useNativeDecorations, accountName, accountAdmin, sidebarShowGames @@ -71,32 +72,36 @@ export default function Sidebar () { }} /> )} -
= 26 - // ? ' mt-6' - ' mt-5' - : '') - } - onMouseDown={async e => { - if (platform() != 'macos') return - if (e.buttons === 1) { - if (e.detail === 2) { - await getCurrentWindow().toggleMaximize() - } else { - await getCurrentWindow().startDragging() - } + {!(platform() == 'windows' && useNativeDecorations) && ( +
= 26 + // ? ' mt-6' + ' mt-5' + : '') } - }} - > - -

- Lncvrt Games Launcher -

-
+ onMouseDown={async e => { + if (platform() != 'macos') return + if (e.buttons === 1) { + if (e.detail === 2) { + await getCurrentWindow().toggleMaximize() + } else { + await getCurrentWindow().startDragging() + } + } + }} + > + +

+ Lncvrt Games Launcher +

+
+ )}