Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix(desktop): set window caption color if Windows version >= 11 (#3939)
Timotej9fb6e59e36da
diff --git a/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.lock b/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.lockindex a08bf3377..e28f8ee94 100644--- a/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.lock+++ b/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.lock@@ -1274,6 +1274,7 @@ dependencies = ["tauri-plugin-window-state","url","windows 0.52.0",+ "winver",][[package]]@@ -4415,6 +4416,15 @@ dependencies = ["windows-sys 0.48.0",]+[[package]]+name = "winver"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9e0e7162b9e282fd75a0a832cce93994bdb21208d848a418cd05a5fdd9b9ab33"+dependencies = [+ "windows 0.48.0",+]+[[package]]name = "wry"version = "0.24.6"diff --git a/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.toml b/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.tomlindex 06d0e466e..7186c111c 100644--- a/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.toml+++ b/packages/hoppscotch-selfhost-desktop/src-tauri/Cargo.toml@@ -41,6 +41,7 @@ windows = { version = "0.52.0", features = ["Win32_Foundation","Win32_UI_Controls",] }+winver = "1"[features]# this feature is used for production builds or when `devPath` points to the filesystemdiff --git a/packages/hoppscotch-selfhost-desktop/src-tauri/src/win/window.rs b/packages/hoppscotch-selfhost-desktop/src-tauri/src/win/window.rsindex bff1408c5..c83202b24 100644--- a/packages/hoppscotch-selfhost-desktop/src-tauri/src/win/window.rs+++ b/packages/hoppscotch-selfhost-desktop/src-tauri/src/win/window.rs@@ -16,6 +16,8 @@ use windows::Win32::Graphics::Dwm::DwmSetWindowAttribute;use windows::Win32::Foundation::HWND;use windows::Win32::Graphics::Dwm::{DWMWA_USE_IMMERSIVE_DARK_MODE};+use winver::WindowsVersion;+fn hex_color_to_colorref(color: HexColor) -> COLORREF {// TODO: Remove this unsafe, This operation doesn't need to be unsafe!unsafe {@@ -42,18 +44,25 @@ fn update_bg_color(hwnd: &HWND, bg_color: HexColor) {ptr::addr_of!(use_dark_mode) as *const c_void,size_of::<BOOL>().try_into().unwrap()).unwrap();+ }- DwmSetWindowAttribute(- HWND(hwnd.0),- DWMWA_CAPTION_COLOR,- ptr::addr_of!(final_color) as *const c_void,- size_of::<COLORREF>().try_into().unwrap()- ).unwrap();+ let version = WindowsVersion::detect().unwrap();+ if version >= WindowsVersion::new(10, 0, 22000) {+ unsafe {+ DwmSetWindowAttribute(+ HWND(hwnd.0),+ DWMWA_CAPTION_COLOR,+ ptr::addr_of!(final_color) as *const c_void,+ size_of::<COLORREF>().try_into().unwrap()+ ).unwrap();+ }+ }- let flags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;- let mask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU | WTNCA_NOMIRRORHELP;- let options = WinThemeAttribute { flag: flags, mask };+ let flags = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;+ let mask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU | WTNCA_NOMIRRORHELP;+ let options = WinThemeAttribute { flag: flags, mask };+ unsafe {SetWindowThemeAttribute(HWND(hwnd.0),WTA_NONCLIENT,