From 6b17ab9b9d7942171d398de14838293259ad29bb Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Tue, 17 Feb 2026 16:12:32 -0700 Subject: [PATCH] Add custom topbar for windows, and remove flags like right click --- src-tauri/Cargo.toml | 2 + src-tauri/capabilities/default.json | 9 ++++ src-tauri/src/lib.rs | 67 +++++++++++++++++++++-------- src-tauri/tauri.windows.conf.json | 8 +++- src/App.css | 2 + src/App.tsx | 8 +++- 6 files changed, 75 insertions(+), 21 deletions(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index cba6aaa..c1bc7c1 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -23,6 +23,8 @@ reqwest = { version = "0.13.2", default-features = false, features = ["stream", tauri-plugin-opener = "2.5.3" tauri-plugin-dialog = "2.6.0" sha2 = "0.10.9" +tauri-plugin-decorum = "1.1.1" +tauri-plugin-prevent-default = "4.0.3" [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] tauri-plugin-single-instance = "2.4.0" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 8897ff7..11f7f2b 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -7,7 +7,16 @@ ], "permissions": [ "core:default", + "core:window:allow-close", + "core:window:allow-center", + "core:window:allow-minimize", + "core:window:allow-maximize", + "core:window:allow-set-size", + "core:window:allow-set-focus", + "core:window:allow-is-maximized", "core:window:allow-start-dragging", + "core:window:allow-toggle-maximize", + "decorum:allow-show-snap-overlay", "fs:default", "os:default", "opener:default", diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 56c8aad..8477677 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,16 +1,20 @@ use sha2::{Digest, Sha512}; -use std::fs::{remove_dir_all}; +use std::fs::remove_dir_all; use std::io::Cursor; use std::{ fs::{File, create_dir_all}, - io::{copy}, + io::copy, path::PathBuf, - process::Command + process::Command, }; use tauri::{AppHandle, Manager}; use tauri_plugin_os::platform; +use tauri_plugin_prevent_default::Flags; use zip::ZipArchive; +#[cfg(target_os = "windows")] +use tauri_plugin_decorum::WebviewWindowExt; + #[cfg(unix)] use std::os::unix::fs::PermissionsExt; @@ -127,19 +131,22 @@ fn load(app: AppHandle) { if let Err(_) = Command::new("open") .arg("Lncvrt Games Launcher.app") .current_dir(&bin_path) - .spawn() { + .spawn() + { eprintln!("Failed to launch game on macOS"); } } else if platform() == "linux" { if let Err(_) = Command::new("./lncvrt-games-launcher") .current_dir(&bin_path) - .spawn() { + .spawn() + { eprintln!("Failed to launch game on macOS"); } } else if platform() == "windows" { if let Err(_) = Command::new(&bin_path.join("lncvrt-games-launcher.exe")) .current_dir(&bin_path) - .spawn() { + .spawn() + { eprintln!("Failed to launch game on macOS"); } } @@ -150,7 +157,44 @@ fn load(app: AppHandle) { #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() + .plugin( + tauri_plugin_prevent_default::Builder::new() + .with_flags( + Flags::FIND + | Flags::CARET_BROWSING + | Flags::DEV_TOOLS + | Flags::DOWNLOADS + | Flags::FOCUS_MOVE + | Flags::RELOAD + | Flags::SOURCE + | Flags::OPEN + | Flags::PRINT + | Flags::CONTEXT_MENU, + ) + .build(), + ) + .plugin(tauri_plugin_window_state::Builder::new().build()) + .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { + let _ = app + .get_webview_window("main") + .expect("no main window") + .set_focus(); + })) + .plugin(tauri_plugin_dialog::init()) + .plugin(tauri_plugin_opener::init()) + .plugin(tauri_plugin_fs::init()) + .plugin(tauri_plugin_decorum::init()) + .plugin(tauri_plugin_os::init()) .setup(|app| { + #[cfg(target_os = "windows")] + { + if let Some(main_window) = app.get_webview_window("main") { + if let Err(e) = main_window.create_overlay_titlebar() { + eprintln!("Failed to create overlay titlebar: {:?}", e); + } + } + } + let app_local_data_dir = match app.path().app_local_data_dir() { Ok(p) => p, Err(_) => return Ok(()), @@ -175,17 +219,6 @@ pub fn run() { Ok(()) }) - .plugin(tauri_plugin_window_state::Builder::new().build()) - .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { - let _ = app - .get_webview_window("main") - .expect("no main window") - .set_focus(); - })) - .plugin(tauri_plugin_dialog::init()) - .plugin(tauri_plugin_opener::init()) - .plugin(tauri_plugin_os::init()) - .plugin(tauri_plugin_fs::init()) .invoke_handler(tauri::generate_handler![download, load]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index 2cd7643..ca33abb 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -15,9 +15,13 @@ { "title": "Lncvrt Games Launcher", "width": 300, - "height": 300, + "height": 332, "resizable": false, - "maximizable": false + "maximizable": false, + "titleBarStyle": "Overlay", + "hiddenTitle": true, + "decorations": false, + "shadow": true } ], "security": { diff --git a/src/App.css b/src/App.css index 151b238..18df353 100644 --- a/src/App.css +++ b/src/App.css @@ -5,7 +5,9 @@ body { font-family: 'Lexend', sans-serif; --col0: rgb(8, 8, 8); + --col1: rgb(16, 16, 16); --col2: rgb(32, 32, 32); + --col3: rgb(48, 48, 48); --col4: rgb(64, 64, 64); --col6: rgb(96, 96, 96); } diff --git a/src/App.tsx b/src/App.tsx index 597d8f3..3e6b856 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -112,13 +112,17 @@ export default function App () { } setState('Starting...') - // invoke('load') + invoke('load') })() }, []) return ( <> -
+