mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
fix(linux): allow overriding AppImage's forced GDK_BACKEND=x11 via CC_SWITCH_GDK_BACKEND (#4351)
The AppImage GTK hook (linuxdeploy-plugin-gtk.sh) hardcodes `export GDK_BACKEND=x11`, forcing XWayland to avoid a historical Wayland crash (tauri-apps/tauri#8541). On modern Wayland + NVIDIA setups this forced XWayland instead makes the WebKitGTK webview unable to receive pointer events (GTK titlebar clickable, web content completely dead) and black-screens on resize. Read an opt-in CC_SWITCH_GDK_BACKEND var before GTK init (the hook does not touch it) so affected users can switch back to native Wayland without unpacking the AppImage. Default behavior is unchanged when the var is unset. Refs #4350 Co-authored-by: BoneLiu <bone_liu@sina.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,19 @@ fn main() {
|
||||
if std::env::var("WEBKIT_DISABLE_COMPOSITING_MODE").is_err() {
|
||||
std::env::set_var("WEBKIT_DISABLE_COMPOSITING_MODE", "1");
|
||||
}
|
||||
|
||||
// AppImage 的 GTK 启动钩子 (linuxdeploy-plugin-gtk.sh) 会无条件
|
||||
// `export GDK_BACKEND=x11` 强制走 XWayland,以规避历史上的 Wayland 崩溃
|
||||
// (tauri-apps/tauri#8541)。但在较新的 Wayland + NVIDIA 环境下,强制 XWayland
|
||||
// 反而使 WebKitGTK 的 webview 收不到指针事件(标题栏可点、网页内容点不动),
|
||||
// resize 后黑屏;改回原生 Wayland 即可解决,且该崩溃在 WebKitGTK 2.52 上已不复现。
|
||||
// 由于该钩子会覆盖用户预设的 GDK_BACKEND,这里提供一个钩子不会触碰的逃生开关:
|
||||
// 设置 CC_SWITCH_GDK_BACKEND=wayland 即可强制覆盖,默认行为保持不变(零回归)。
|
||||
if let Ok(backend) = std::env::var("CC_SWITCH_GDK_BACKEND") {
|
||||
if !backend.is_empty() {
|
||||
std::env::set_var("GDK_BACKEND", backend);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cc_switch_lib::run();
|
||||
|
||||
Reference in New Issue
Block a user