diff --git a/README.md b/README.md index a26b703e7..880dd46e7 100644 --- a/README.md +++ b/README.md @@ -15,29 +15,17 @@ QBZ is a free and open source (FOSS) high-fidelity streaming client for Linux with native playback. It is a real desktop application, not a web wrapper, so it can use DAC passthrough, switch sample rates per track, and deliver bit-perfect audio. -## 1.1.8 Highlights - -- DAC Setup Wizard for guided PipeWire bit-perfect configuration -- Immersive Player overhaul with tabbed panels and visualizer -- Genre filtering with 3-level hierarchy -- Playlist suggestions based on artist similarity -- Remote control API (LAN + PWA) -- Configurable key bindings -- New languages: German and French, plus expanded Spanish coverage - -See `docs/release-1.1.8/CHANGELOG_HIGHLIGHTS.md` for details. - ## Legal / Branding - This application uses the Qobuz API but is not certified by Qobuz. -- Qobuz™ is a trademark of Qobuz. QBZ is not affiliated with, endorsed by, or certified by Qobuz. +- Qobuz is a trademark of Qobuz. QBZ is not affiliated with, endorsed by, or certified by Qobuz. - The offline library is a temporary playback cache for listening without an internet connection while you have a valid subscription. You do not receive a license to keep or redistribute the content. If your subscription becomes invalid, QBZ will remove all cached content after 3 days. - Credentials may be stored in your system keyring if you have a keyring configured. - Qobuz Terms of Service: https://www.qobuz.com/us-en/legal/terms ## Why QBZ -Browsers cap audio output around 48 kHz, while Qobuz™ streams up to 192 kHz. QBZ uses a native playback pipeline with direct device control, exclusive mode, and no forced resampling so your system and DAC receive the original resolution, with caching and system integrations that wrappers cannot provide. +Browsers cap audio output around 48 kHz, while Qobuz streams up to 192 kHz. QBZ uses a native playback pipeline with direct device control, exclusive mode, and no forced resampling so your system and DAC receive the original resolution, with caching and system integrations that wrappers cannot provide. ## Installation @@ -83,7 +71,7 @@ flatpak install ./QBZ.flatpak Due to Flatpak sandbox restrictions, **PipeWire backend cannot guarantee bit-perfect playback**. The sandbox prevents QBZ from controlling the PipeWire daemon's sample rate configuration. **For bit-perfect audio in Flatpak:** -- Use **ALSA Direct backend** in Settings → Audio → Audio Backend +- Use **ALSA Direct backend** in Settings > Audio > Audio Backend - Select your DAC from the device list - Enable DAC Passthrough @@ -126,7 +114,7 @@ Download the `.deb` from [Releases](https://github.com/vicrodh/qbz/releases). sudo apt install ./qbz_*.deb ``` -> **Requires glibc 2.38+** (Ubuntu 24.04+, Debian 13+, Mint 22+). Older releases like Ubuntu 22.04 or Pop!_OS 22.04 ship glibc 2.35 and won't work — use Flatpak, Snap, or AppImage instead. +> **Requires glibc 2.38+** (Ubuntu 24.04+, Debian 13+, Mint 22+). Older releases like Ubuntu 22.04 or Pop!_OS 22.04 ship glibc 2.35 and won't work -- use Flatpak, Snap, or AppImage instead. ### RPM (Fedora/openSUSE/RHEL-based) @@ -140,89 +128,163 @@ sudo dnf install ./qbz-*.rpm > **Note:** Pre-built binaries include all API integrations (Last.fm, Discogs, Spotify, Apple Music, Tidal, Deezer) ready to use. If you build from source, you'll need to provide your own API keys. -## Screenshots - -Coming soon. - ## Features -### Streaming and Playback -- Qobuz™ authentication and full catalog search (albums, tracks, artists, playlists). -- Native decoding for FLAC, MP3, AAC, and ALAC with real-time playback state updates. -- Quality selection with automatic fallback across Qobuz™ tiers. -- Audio device enumeration and per-device output selection. -- Exclusive mode and DAC passthrough for bit-perfect playback. -- Preserve original sample rates end-to-end where supported. -- Gapless-ready playback pipeline with precise position tracking. +### Audio and Playback +- **Bit-perfect playback** with DAC passthrough and per-track sample rate switching (44.1 kHz to 192 kHz). +- **Four audio backends:** PipeWire, ALSA, ALSA Direct (hw: bypass), and PulseAudio. +- **DAC Setup Wizard** for guided bit-perfect configuration. +- Native decoding for FLAC, MP3, AAC, ALAC, WavPack, Ogg Vorbis, and Opus via Symphonia. +- Quality selection with automatic fallback across Qobuz tiers. +- Per-device output selection with exclusive mode. +- Gapless playback with precise position tracking. +- **Loudness normalization** (EBU R128) with ReplayGain support. +- Two-level audio cache: L1 in-memory (400 MB) with L2 disk spillover (800 MB) and next-track prefetching. ### Queue and Library -- Queue management with shuffle, repeat, and history navigation. -- In-memory audio cache with LRU eviction and next-track prefetching. -- Favorites and playlists from your Qobuz™ account. -- Local library backend: directory scanning, metadata extraction, CUE sheet parsing, and SQLite indexing. +- Queue management with shuffle, repeat (track/queue/off), and history navigation. +- Favorites and playlists from your Qobuz account. +- **Local library:** directory scanning, metadata extraction with lofty, CUE sheet parsing, and SQLite indexing. - Grid and list views with search, A-Z index, and grouping by artist or album. -- Multi-disc album grouping with disc headers in album views. +- Multi-disc album grouping with disc headers. - Local artwork detection (folder and embedded) with Discogs fallback. -- **Tag editor for local library:** Edit metadata (title, artist, album, genre, year) with sidecar storage that preserves original files. +- **Tag editor:** edit metadata (title, artist, album, genre, year) with sidecar storage that preserves original files. +- **Virtualized lists** for smooth scrolling across large libraries. ### Playlist Import -- Import public playlists from Spotify, Apple Music, Tidal, and Deezer into your Qobuz™ library. +- Import public playlists from Spotify, Apple Music, Tidal, and Deezer into your Qobuz library. - Automatic track matching with fuzzy search. - Batch import with progress tracking. ### Network Casting -- Chromecast device discovery and streaming. -- DLNA/UPnP device discovery and streaming (AVTransport SOAP). +- **Chromecast** device discovery and streaming. +- **DLNA/UPnP** device discovery and streaming (AVTransport SOAP). - Unified cast picker with protocol selection. - Seamless playback handoff to network devices. ### Integrations -- MPRIS media controls and media key support on Linux. +- **MPRIS** media controls and media key support. +- **Last.fm** scrobbling and now-playing updates. +- **ListenBrainz** scrobbling with offline queue and listen history sync. +- **MusicBrainz** artist enrichment, musician credits, recording relationships, and album personnel. +- **Discogs** artwork fetching for local library. - Desktop notifications for track changes. -- Last.fm scrobbling and now-playing updates. -- **MusicBrainz integration:** Artist enrichment, musician credits, recording relationships, and detailed album personnel. -- **ListenBrainz integration:** Scrobbling with listen history sync. -- Discogs artwork fetching for local library. -- Shareable Qobuz™ URLs and universal SongLink links (Odesli). +- Shareable Qobuz URLs and universal SongLink links (Odesli). + +### Immersive Player +- Full-screen expanded player with tabbed panel system. +- **14 visualization panels:** spectrum analyzer, oscilloscope, spectrogram, energy bands, Lissajous curves, transient pulse, vinyl animation, coverflow, and more. +- **Synchronized lyrics** with line-by-line display and mini view. +- Queue, track info, playback history, and suggestions panels. ### Interface -- Now playing, queue panel, and full-screen playback views. +- 26 built-in themes (Dark, OLED, Nord, Dracula, Tokyo Night, Catppuccin Mocha, Breeze, Adwaita, and more). +- **Auto-theme:** generate themes dynamically from your DE color scheme, wallpaper, or a custom image (experimental). +- **Native KDE title bar** on Plasma Wayland via KWin window rules. - Focus mode for distraction-free listening. - Mini player mode. -- **Musician pages:** Explore performers, composers, and producers with their discography and roles. -- **Label pages:** Browse record label catalogs. -- **Album credits:** View detailed personnel and recording credits from MusicBrainz. -- **Track info modal:** Detailed track metadata, recording info, and file details. -- **Artist network sidebar:** Explore related artists and collaborators. -- Keyboard shortcuts for common actions. -- English and Spanish localization. +- **Musician pages:** explore performers, composers, and producers with their discography and roles. +- **Label pages:** browse record label catalogs. +- **Album credits:** detailed personnel and recording credits from MusicBrainz. +- **Image lightbox** with full-screen artwork viewing. +- **Custom artist images:** right-click any artist to set a custom image. +- Configurable keyboard shortcuts. +- UI zoom from 80% to 200%. +- 5 font choices including system font. +- **4 languages:** English, Spanish, German, and French. + +### Recommendations and Discovery +- **Home page** with personalized sections: recent albums, continue listening, top artists, favorites, and weekly suggestions. +- Genre filtering with 3-level hierarchy. +- **Artist similarity engine** using vector embeddings for radio and suggestions. +- Playlist suggestions based on artist similarity. +- Dynamic suggestions with seed-based recommendations. + +### Offline Support +- Offline mode detection with automatic reconnection. +- Offline playback cache for previously streamed content. +- ListenBrainz and Last.fm offline queuing with automatic sync. + +### Remote Control +- Built-in HTTP API for LAN remote control. +- Self-signed TLS with auto-generated certificates. ### Settings - Audio device selection and quality preferences. - API keys configuration for self-hosted builds. -- Theme and appearance options. -- **Update notifications:** Check for new releases with What's New changelogs. - -### Performance -- Low CPU usage in idle and playback with adaptive audio thread scheduling. - -## Open Source - -QBZ is MIT-licensed and fully open source. No telemetry, no lock-in, and no hidden services. Just a clean, transparent player built for Linux audio fans. - -## Inspiration - -QBZ draws inspiration from the broader Linux audio community that values open tools and high-fidelity playback. +- Theme and appearance options with live preview. +- System tray with minimize-to-tray and configurable behavior. +- **Update notifications** with What's New changelogs. +- Graphics composition settings for GPU/Wayland troubleshooting. ## Tech Stack -- **Desktop:** Rust + Tauri 2 -- **Frontend:** SvelteKit 5 + TypeScript + Vite -- **Audio:** rodio + symphonia -- **Networking:** reqwest -- **Local library:** walkdir + lofty + rusqlite -- **Integrations:** souvlaki (MPRIS), notify-rust, SongLink (Odesli) -- **UX:** svelte-i18n, lucide-svelte +| Layer | Technology | +|-------|-----------| +| **Desktop shell** | Rust + Tauri 2.0 | +| **Frontend** | SvelteKit + Svelte 5 (runes) + TypeScript + Vite | +| **Audio decoding** | Symphonia (all codecs) via vendored rodio | +| **Audio backends** | PipeWire, ALSA (via alsa-rs), ALSA Direct (hw:), PulseAudio | +| **Networking** | reqwest (rustls-tls), axum (local API server) | +| **Database** | rusqlite (bundled SQLite, WAL mode) | +| **Local library** | walkdir + lofty (metadata) + image (thumbnails) | +| **Desktop integration** | souvlaki (MPRIS), notify-rust, keyring | +| **Casting** | rust_cast (Chromecast), rupnp (DLNA/UPnP), mdns-sd (AirPlay) | +| **Internationalization** | svelte-i18n (4 locales) | +| **Icons** | lucide-svelte | + +### Multi-Crate Architecture + +The Rust backend is organized into independent crates for modularity: + +``` +crates/ + qbz-models/ Shared domain types (Track, Album, Artist, etc.) + qbz-audio/ Audio backends, loudness analysis, device management + qbz-player/ Playback engine, streaming, queue control + qbz-qobuz/ Qobuz API client and authentication + qbz-core/ Orchestrator coordinating player, audio, and API + qbz-library/ Local library scanning, metadata, thumbnails + qbz-integrations/ Last.fm, ListenBrainz, MusicBrainz, Discogs + qbz-cache/ L1 memory + L2 disk audio caching + qbz-cast/ Chromecast, DLNA/UPnP, AirPlay casting +``` + +## Project Structure + +``` +qbz/ +├── src/ Frontend (SvelteKit + Svelte 5) +│ ├── lib/ +│ │ ├── components/ 120+ Svelte components +│ │ │ ├── views/ 20+ view components (Home, Search, Settings, etc.) +│ │ │ └── immersive/ Immersive player panels and visualizers +│ │ ├── stores/ 40+ state stores (Svelte 5 runes) +│ │ ├── services/ Backend integration services +│ │ ├── i18n/locales/ en, es, de, fr translations +│ │ ├── app/ Bootstrap and initialization +│ │ └── utils/ Helpers (zoom, keyboard, sanitize, etc.) +│ └── routes/ SvelteKit routes (main + miniplayer) +├── src-tauri/ +│ ├── src/ +│ │ ├── auto_theme/ Dynamic theme generation from DE/wallpaper +│ │ ├── audio/ Audio backend re-exports +│ │ ├── config/ 13 settings modules +│ │ ├── commands_v2.rs V2 command handlers (active API surface) +│ │ ├── core_bridge.rs Bridge to multi-crate architecture +│ │ └── ... 30+ feature modules +│ ├── vendor/ +│ │ ├── rodio/ Vendored audio playback (f32 pipeline) +│ │ └── cpal/ Vendored audio device library +│ └── Cargo.toml +├── crates/ 9 independent Rust crates (see above) +├── packaging/ +│ ├── aur/ Arch Linux PKGBUILD +│ └── flatpak/ Flatpak manifest and metainfo +├── scripts/ Build, dev, and CI helper scripts +├── .github/workflows/ CI/CD (Linux x86_64, aarch64, Flatpak, AUR) +└── snapcraft.yaml Snap package definition +``` ## Building from Source @@ -231,22 +293,41 @@ QBZ draws inspiration from the broader Linux audio community that values open to - Rust (latest stable) - Node.js 20+ - Linux with audio support (PipeWire, ALSA, or PulseAudio) -- System dependencies: `webkit2gtk-4.1`, `gtk3`, `alsa-lib` -### Setup +### System Dependencies + +**Debian/Ubuntu:** +```bash +sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev \ + libappindicator3-dev librsvg2-dev libssl-dev pkg-config +``` + +**Fedora:** +```bash +sudo dnf install webkit2gtk4.1-devel gtk3-devel alsa-lib-devel \ + libappindicator-gtk3-devel librsvg2-devel openssl-devel pkg-config +``` + +**Arch Linux:** +```bash +sudo pacman -S webkit2gtk-4.1 gtk3 alsa-lib libappindicator-gtk3 \ + librsvg openssl pkg-config +``` + +### Build ```bash # Clone the repository git clone https://github.com/vicrodh/qbz.git cd qbz -# Install dependencies +# Install frontend dependencies npm install # Run in development mode npm run tauri dev -# Build for production +# Build for production (generates DEB, RPM, and AppImage) npm run tauri build ``` @@ -346,36 +427,6 @@ mv ~/.local/share/qbz-nix ~/.local/share/qbz If you run both development and production builds, they now share the same data directories. -## Project Structure - -``` -qbz/ -├── src/ # Frontend (SvelteKit) -├── src-tauri/ -│ └── src/ -│ ├── api/ # Qobuz™ API client -│ ├── player/ # Audio playback engine -│ ├── queue/ # Queue management -│ ├── cache/ # Audio cache and prefetch -│ ├── cast/ # Chromecast & DLNA casting -│ ├── library/ # Local library backend -│ ├── lastfm/ # Last.fm integration -│ ├── listenbrainz/ # ListenBrainz integration -│ ├── musicbrainz/ # MusicBrainz integration -│ ├── discogs/ # Discogs integration -│ ├── playlist_import/ # Spotify/Tidal import -│ ├── share/ # SongLink / share utilities -│ ├── media_controls/ # MPRIS integration -│ ├── updates/ # Release updates checker -│ └── commands/ # Tauri IPC commands -├── packaging/ -│ ├── aur/ # Arch Linux PKGBUILD -│ └── flatpak/ # Flatpak manifest -├── docs/ -│ └── release-1.1.8/ # Release notes -└── static/ # Static assets and logo -``` - ## Known Issues ### Audio Playback @@ -387,7 +438,7 @@ qbz/ - Future: Byte-level seeking will be implemented in a future release to fix this **First Sample Rate Change** -- The first large sample rate change (e.g., 88.2kHz → 44.1kHz) may have a brief delay as the hardware stabilizes +- The first large sample rate change (e.g., 88.2kHz to 44.1kHz) may have a brief delay as the hardware stabilizes - Subsequent changes of the same type are smooth - This is normal hardware behavior and not a bug @@ -406,7 +457,7 @@ qbz/ ### Graphics and Rendering -QBZ uses WebKit for rendering. Some hardware/driver combinations may cause crashes or poor performance. Settings are available in **Settings → Appearance → Composition**. +QBZ uses WebKit for rendering. Some hardware/driver combinations may cause crashes or poor performance. Settings are available in **Settings > Appearance > Composition**. #### Quick Recovery @@ -441,7 +492,7 @@ Set these before launching QBZ to override settings: ```bash QBZ_FORCE_X11=1 qbz ``` -Or enable "Force X11 backend" in Settings → Appearance → Composition. +Or enable "Force X11 backend" in Settings > Appearance > Composition. **Intel Arc GPU (EGL crashes, "Could not create default EGL display")** ```bash @@ -460,7 +511,7 @@ QBZ_HARDWARE_ACCEL=0 qbz **XWayland scaling issues (blurry UI)** -After enabling Force X11, configure scaling in Settings → Appearance → Composition: +After enabling Force X11, configure scaling in Settings > Appearance > Composition: - **GDK_SCALE**: Integer scaling (1, 2) - **GDK_DPI_SCALE**: Fractional scaling (0.5, 1, 1.5, 2) @@ -472,6 +523,10 @@ After enabling Force X11, configure scaling in Settings → Appearance → Compo All settings require a restart to take effect. +## Open Source + +QBZ is MIT-licensed and fully open source. No telemetry, no lock-in, and no hidden services. Just a clean, transparent player built for Linux audio fans. + ## Contributing Contributions are welcome. Please read `CONTRIBUTING.md` before submitting issues or pull requests. diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index ef3991300..c3001b75a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -160,6 +160,176 @@ pub fn update_media_controls_metadata( media_controls.set_metadata(&track_info); } +/// Add a KWin window rule that forces server-side decorations (SSD) for QBZ. +/// +/// GTK3 on Wayland hardcodes CLIENT_SIDE in the xdg-decoration protocol, +/// so KWin scripting alone can't override it. Window rules operate at a +/// deeper level (applied during window setup, before protocol negotiation) +/// and can force KWin to draw native SSD. +/// +/// The rule is written to ~/.config/kwinrulesrc and persists across sessions. +/// It's removed when the user disables system title bar. +fn setup_kwin_window_rule() -> Result<(), String> { + let config_path = dirs::config_dir() + .ok_or_else(|| "Could not determine config directory".to_string())? + .join("kwinrulesrc"); + + // Read existing rules to find next available slot and check for existing QBZ rule + let existing = std::fs::read_to_string(&config_path).unwrap_or_default(); + let mut existing_count: u32 = 0; + let mut qbz_rule_group: Option = None; + + for line in existing.lines() { + // Parse [General] count=N + if line.starts_with("count=") { + if let Ok(n) = line.trim_start_matches("count=").parse::() { + existing_count = n; + } + } + // Check if we already have a QBZ rule + if line.contains("Description=QBZ Native Title Bar") { + // Find the group number from context — we'll just scan backwards + // Simpler: track current group + } + } + + // Parse INI to find existing QBZ rule group + let mut current_group: Option = None; + for line in existing.lines() { + let trimmed = line.trim(); + if trimmed.starts_with('[') && trimmed.ends_with(']') { + let inner = &trimmed[1..trimmed.len() - 1]; + current_group = inner.parse::().ok(); + } + if trimmed == "Description=QBZ Native Title Bar" { + qbz_rule_group = current_group; + } + } + + let rule_num = if let Some(num) = qbz_rule_group { + log::info!("KWin window rule for QBZ already exists (group {}), updating", num); + num + } else { + existing_count + 1 + }; + + // Write the rule using kwriteconfig6 + let group = rule_num.to_string(); + let rules: &[(&str, &str)] = &[ + ("Description", "QBZ Native Title Bar"), + ("noborder", "false"), + ("noborderrule", "2"), // 2 = Force + ("wmclass", "qbz"), + ("wmclasscomplete", "false"), + ("wmclassmatch", "1"), // 1 = Exact match + ("types", "1"), // 1 = Normal windows + ]; + + for (key, value) in rules { + let output = std::process::Command::new("kwriteconfig6") + .args(["--file", "kwinrulesrc", "--group", &group, "--key", key, value]) + .output() + .map_err(|e| format!("kwriteconfig6 failed: {}", e))?; + + if !output.status.success() { + return Err(format!( + "kwriteconfig6 --key {} failed: {}", + key, + String::from_utf8_lossy(&output.stderr) + )); + } + } + + // Update the count in [General] if we added a new rule + if qbz_rule_group.is_none() { + let new_count = (existing_count + 1).to_string(); + let output = std::process::Command::new("kwriteconfig6") + .args(["--file", "kwinrulesrc", "--group", "General", "--key", "count", &new_count]) + .output() + .map_err(|e| format!("kwriteconfig6 count update failed: {}", e))?; + + if !output.status.success() { + return Err(format!( + "kwriteconfig6 count failed: {}", + String::from_utf8_lossy(&output.stderr) + )); + } + } + + // Tell KWin to reload rules + let output = std::process::Command::new("qdbus6") + .args(["org.kde.KWin", "/KWin", "org.kde.KWin.reconfigure"]) + .output() + .map_err(|e| format!("qdbus6 reconfigure failed: {}", e))?; + + if !output.status.success() { + log::warn!( + "KWin reconfigure failed (non-fatal): {}", + String::from_utf8_lossy(&output.stderr) + ); + } + + log::info!("KWin window rule set for native title bar (group {})", rule_num); + Ok(()) +} + +/// Remove the KWin window rule for QBZ when system title bar is disabled. +#[allow(dead_code)] +fn remove_kwin_window_rule() { + // Find and remove QBZ rule from kwinrulesrc + let config_path = match dirs::config_dir() { + Some(p) => p.join("kwinrulesrc"), + None => return, + }; + + let existing = match std::fs::read_to_string(&config_path) { + Ok(s) => s, + Err(_) => return, + }; + + // Find the QBZ rule group number + let mut current_group: Option = None; + let mut qbz_group: Option = None; + + for line in existing.lines() { + let trimmed = line.trim(); + if trimmed.starts_with('[') && trimmed.ends_with(']') { + current_group = Some(trimmed[1..trimmed.len() - 1].to_string()); + } + if trimmed == "Description=QBZ Native Title Bar" { + qbz_group = current_group.clone(); + } + } + + if let Some(group) = qbz_group { + // Delete the group using kwriteconfig6 + let _ = std::process::Command::new("kwriteconfig6") + .args(["--file", "kwinrulesrc", "--group", &group, "--delete-group"]) + .output(); + + // Decrement count + let mut count: u32 = 0; + for line in existing.lines() { + if line.starts_with("count=") { + count = line.trim_start_matches("count=").parse().unwrap_or(0); + } + } + if count > 0 { + let new_count = (count - 1).to_string(); + let _ = std::process::Command::new("kwriteconfig6") + .args(["--file", "kwinrulesrc", "--group", "General", "--key", "count", &new_count]) + .output(); + } + + // Reconfigure KWin + let _ = std::process::Command::new("qdbus6") + .args(["org.kde.KWin", "/KWin", "org.kde.KWin.reconfigure"]) + .output(); + + log::info!("KWin window rule for QBZ removed"); + } +} + pub fn run() { // Load .env file if present (for development) // Silently ignore if not found (production builds use compile-time env vars) @@ -402,13 +572,37 @@ pub fn run() { .manage(runtime::RuntimeManagerState::new()) .manage(user_data_paths) .setup(move |app| { - // Create main window programmatically so we can set the correct - // decoration state at creation time. On Linux/Wayland, windows - // created with decorations:false cannot reliably switch to - // decorations:true at runtime (WM buttons don't work). By - // creating the window with the right value from the start, the - // WM sees the correct state when the window is first mapped. - log::info!("Creating main window (decorations={})", use_system_titlebar); + // On KDE Plasma + Wayland, GTK3 always uses client-side decorations + // (CSD) regardless of GTK_CSD env var, because it hardcodes + // CLIENT_SIDE in the xdg-decoration protocol. This means + // decorations(true) shows a GTK/Breeze-GTK title bar, not the + // native KDE Breeze one. + // + // Workaround: create the window with decorations=false (no GTK CSD), + // then load a KWin script via D-Bus that forces KWin to draw its own + // server-side decorations (SSD) for QBZ. This gives a single, native + // KDE title bar identical to Dolphin/Konsole. + let is_kde_wayland = std::env::var("GDK_BACKEND") + .map(|v| v == "wayland") + .unwrap_or(false) + && auto_theme::system::detect_desktop_environment() + == auto_theme::system::DesktopEnvironment::KdePlasma; + + let use_kwin_ssd = use_system_titlebar && is_kde_wayland; + + // On KDE Wayland: always decorations=false, KWin script adds SSD + // On other DEs: use decorations directly (GTK CSD is acceptable) + let gtk_decorations = if use_kwin_ssd { + false + } else { + use_system_titlebar + }; + + log::info!( + "Creating main window (decorations={}, kwin_ssd={})", + gtk_decorations, + use_kwin_ssd + ); tauri::WebviewWindowBuilder::new( app, "main", @@ -417,7 +611,7 @@ pub fn run() { .title("QBZ") .inner_size(1280.0, 800.0) .min_inner_size(800.0, 600.0) - .decorations(use_system_titlebar) + .decorations(gtk_decorations) .transparent(true) .resizable(true) .zoom_hotkeys_enabled(true) @@ -427,6 +621,15 @@ pub fn run() { e })?; + // Add KWin window rule to force server-side decorations for QBZ + if use_kwin_ssd { + std::thread::spawn(|| { + if let Err(e) = setup_kwin_window_rule() { + log::warn!("Failed to set KWin window rule: {}", e); + } + }); + } + // Initialize system tray icon (only if enabled) if enable_tray { if let Err(e) = tray::init_tray(app.handle()) {