Hide the desktop window's title bar and default menu
Some checks failed
CI / fmt (pull_request) Successful in 15s
CI / clippy-web (pull_request) Has been cancelled
CI / clippy-desktop (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
CI / audit (pull_request) Has been cancelled
CI / clippy-server (pull_request) Has been cancelled
CI / clippy-native (pull_request) Has been cancelled
Some checks failed
CI / fmt (pull_request) Successful in 15s
CI / clippy-web (pull_request) Has been cancelled
CI / clippy-desktop (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
CI / audit (pull_request) Has been cancelled
CI / clippy-server (pull_request) Has been cancelled
CI / clippy-native (pull_request) Has been cancelled
Extract desktop window setup into its own crates/web/src/desktop.rs module (SRP) with a single config() function, wired into main.rs via LaunchBuilder::desktop().with_cfg(...). Disabling window decorations also clears dioxus-desktop's default native menu bar as a side effect, since it exists to give a decorated window something to hang off of. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
6c1020c3ef
commit
ef37690473
2 changed files with 18 additions and 1 deletions
12
crates/web/src/desktop.rs
Normal file
12
crates/web/src/desktop.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
use dioxus::desktop::{Config, WindowBuilder};
|
||||||
|
|
||||||
|
/// Desktop window configuration: a borderless window with no OS title bar.
|
||||||
|
///
|
||||||
|
/// Dropping decorations also drops dioxus-desktop's default native menu bar
|
||||||
|
/// (Window/Edit/Help) — the crate only keeps that menu around to give a
|
||||||
|
/// decorated window something to hang it off of, and clears it automatically
|
||||||
|
/// once `with_decorations(false)` is set, so there's nothing further to do
|
||||||
|
/// here to get rid of it.
|
||||||
|
pub fn config() -> Config {
|
||||||
|
Config::new().with_window(WindowBuilder::new().with_decorations(false))
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
mod api;
|
mod api;
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
|
#[cfg(feature = "desktop")]
|
||||||
|
mod desktop;
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
mod server;
|
mod server;
|
||||||
|
|
||||||
|
|
@ -14,7 +17,9 @@ fn main() {
|
||||||
// `#[server]` calls) — it would stand up an axum server instead of a
|
// `#[server]` calls) — it would stand up an axum server instead of a
|
||||||
// window. Pick the desktop renderer explicitly in that case.
|
// window. Pick the desktop renderer explicitly in that case.
|
||||||
#[cfg(feature = "desktop")]
|
#[cfg(feature = "desktop")]
|
||||||
dioxus::LaunchBuilder::desktop().launch(app::App);
|
dioxus::LaunchBuilder::desktop()
|
||||||
|
.with_cfg(desktop::config())
|
||||||
|
.launch(app::App);
|
||||||
|
|
||||||
#[cfg(not(feature = "desktop"))]
|
#[cfg(not(feature = "desktop"))]
|
||||||
dioxus::launch(app::App);
|
dioxus::launch(app::App);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue