fix(overlay): parse HANDY_NO_GTK_LAYER_SHELL as boolean (#1269)
The previous check used `env::var(...).is_ok()`, which only tested for the variable's presence and ignored its value. Setting the variable to `0` or `false` counter-intuitively still disabled gtk-layer-shell. Introduce `env_flag_enabled` helper that treats `0`, `false`, `no`, `off`, and the empty string as falsy (case-insensitive).
This commit is contained in:
parent
966ff99756
commit
11311bee0e
1 changed files with 17 additions and 3 deletions
|
|
@ -66,13 +66,27 @@ fn update_gtk_layer_shell_anchors(overlay_window: &tauri::webview::WebviewWindow
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true when the environment variable is set to a truthy value
|
||||||
|
/// (e.g. "1", "true", "yes", "on").
|
||||||
|
/// "0", "false", "no", "off" and empty string are treated as falsy (case-insensitive).
|
||||||
|
/// Returns false when the variable is not set.
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn env_flag_enabled(name: &str) -> bool {
|
||||||
|
match env::var(name) {
|
||||||
|
Ok(v) => !matches!(
|
||||||
|
v.trim().to_ascii_lowercase().as_str(),
|
||||||
|
"" | "0" | "false" | "no" | "off"
|
||||||
|
),
|
||||||
|
Err(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Initializes GTK layer shell for Linux overlay window
|
/// Initializes GTK layer shell for Linux overlay window
|
||||||
/// Returns true if layer shell was successfully initialized, false otherwise
|
/// Returns true if layer shell was successfully initialized, false otherwise
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn init_gtk_layer_shell(overlay_window: &tauri::webview::WebviewWindow) -> bool {
|
fn init_gtk_layer_shell(overlay_window: &tauri::webview::WebviewWindow) -> bool {
|
||||||
|
if env_flag_enabled("HANDY_NO_GTK_LAYER_SHELL") {
|
||||||
if env::var("HANDY_NO_GTK_LAYER_SHELL").is_ok() {
|
debug!("Skipping GTK layer shell init (HANDY_NO_GTK_LAYER_SHELL is enabled)");
|
||||||
debug!("Skipping GTK layer shell init (HANDY_NO_GTK_LAYER_SHELL is set)");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue