mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
refactor: enhance compositor detection logic (#5007)
* refactor: enhance compositor detection logic * docs: UPDATELOG.md
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
- 改进 Linux 托盘支持并添加 `--no-tray` 选项
|
- 改进 Linux 托盘支持并添加 `--no-tray` 选项
|
||||||
- Linux 现在在新生成的配置中默认将 TUN 栈恢复为 mixed 模式
|
- Linux 现在在新生成的配置中默认将 TUN 栈恢复为 mixed 模式
|
||||||
- 为代理延迟测试的 URL 设置增加了保护以及添加了安全的备用 URL
|
- 为代理延迟测试的 URL 设置增加了保护以及添加了安全的备用 URL
|
||||||
|
- 更新了 Wayland 合成器检测逻辑,从而在 Hyprland 会话中保留原生 Wayland 后端
|
||||||
|
|
||||||
### 🐞 修复问题
|
### 🐞 修复问题
|
||||||
|
|
||||||
|
|||||||
@@ -250,17 +250,35 @@ pub fn run() {
|
|||||||
let desktop_env = std::env::var("XDG_CURRENT_DESKTOP")
|
let desktop_env = std::env::var("XDG_CURRENT_DESKTOP")
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_uppercase();
|
.to_uppercase();
|
||||||
|
let session_desktop = std::env::var("XDG_SESSION_DESKTOP")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_uppercase();
|
||||||
|
let desktop_session = std::env::var("DESKTOP_SESSION")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_uppercase();
|
||||||
let is_kde_desktop = desktop_env.contains("KDE");
|
let is_kde_desktop = desktop_env.contains("KDE");
|
||||||
let is_plasma_desktop = desktop_env.contains("PLASMA");
|
let is_plasma_desktop = desktop_env.contains("PLASMA");
|
||||||
|
let is_hyprland_desktop = desktop_env.contains("HYPR")
|
||||||
|
|| session_desktop.contains("HYPR")
|
||||||
|
|| desktop_session.contains("HYPR");
|
||||||
|
|
||||||
let is_wayland_session = std::env::var("XDG_SESSION_TYPE")
|
let is_wayland_session = std::env::var("XDG_SESSION_TYPE")
|
||||||
.map(|value| value.eq_ignore_ascii_case("wayland"))
|
.map(|value| value.eq_ignore_ascii_case("wayland"))
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
|| std::env::var("WAYLAND_DISPLAY").is_ok();
|
|| std::env::var("WAYLAND_DISPLAY").is_ok();
|
||||||
let prefer_native_wayland = is_wayland_session && (is_kde_desktop || is_plasma_desktop);
|
let prefer_native_wayland =
|
||||||
|
is_wayland_session && (is_kde_desktop || is_plasma_desktop || is_hyprland_desktop);
|
||||||
let dmabuf_override = std::env::var("WEBKIT_DISABLE_DMABUF_RENDERER");
|
let dmabuf_override = std::env::var("WEBKIT_DISABLE_DMABUF_RENDERER");
|
||||||
|
|
||||||
if prefer_native_wayland {
|
if prefer_native_wayland {
|
||||||
|
let compositor_label = if is_hyprland_desktop {
|
||||||
|
"Hyprland"
|
||||||
|
} else if is_plasma_desktop {
|
||||||
|
"KDE Plasma"
|
||||||
|
} else {
|
||||||
|
"KDE"
|
||||||
|
};
|
||||||
|
|
||||||
if matches!(dmabuf_override.as_deref(), Ok("1")) {
|
if matches!(dmabuf_override.as_deref(), Ok("1")) {
|
||||||
unsafe {
|
unsafe {
|
||||||
std::env::remove_var("WEBKIT_DISABLE_DMABUF_RENDERER");
|
std::env::remove_var("WEBKIT_DISABLE_DMABUF_RENDERER");
|
||||||
@@ -269,14 +287,16 @@ pub fn run() {
|
|||||||
info,
|
info,
|
||||||
Type::Setup,
|
Type::Setup,
|
||||||
true,
|
true,
|
||||||
"Wayland + KDE detected: Re-enabled WebKit DMABUF renderer to avoid Cairo surface failures."
|
"Wayland + {} detected: Re-enabled WebKit DMABUF renderer to avoid Cairo surface failures.",
|
||||||
|
compositor_label
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
logging!(
|
logging!(
|
||||||
info,
|
info,
|
||||||
Type::Setup,
|
Type::Setup,
|
||||||
true,
|
true,
|
||||||
"Wayland + KDE detected: Using native Wayland backend for reliable rendering."
|
"Wayland + {} detected: Using native Wayland backend for reliable rendering.",
|
||||||
|
compositor_label
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user