From e6867a2fed632d24e415387dbdf2cd4b4e06e8b2 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sun, 15 Nov 2026 10:33:24 +0800 Subject: [PATCH] fix(drm): load the custom client before is_x11() can read Config, offer DRM only where it is compiled in `IS_X11` now asks `drm_capture_enabled()`, which reads Config, and it is computed in `global_init()`. `core_main()` ran that before `load_custom_client()`, so on a Linux custom client the config loaded from the stock "RustDesk" path before the app name was set and was never reloaded; the root then synced that copy over the client's own settings. Load the custom client first. On Windows and macOS `global_init()` does nothing, so only the Linux startup order changes. The DRM checkbox and the home-page "Enable" cards also showed on installed builds without the drm feature (NixOS, source builds, --no-drm), where the option has no effect. They now also need `is-drm-capture-supported`, a new `main_get_common` key that reports whether drm is compiled in. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF --- flutter/lib/desktop/pages/desktop_home_page.dart | 7 ++++--- flutter/lib/desktop/pages/desktop_setting_page.dart | 6 +++++- src/core_main.rs | 4 +++- src/flutter_ffi.rs | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 0917f9534..cd955efb0 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -549,10 +549,11 @@ class _DesktopHomePageState extends State )); } } - final installed = bind.mainIsInstalled(); - if (installed && mainGetBoolOptionSync(kOptionAllowDrmCapture)) { + final drmSupported = bind.mainIsInstalled() && + bind.mainGetCommonSync(key: 'is-drm-capture-supported') == 'true'; + if (drmSupported && mainGetBoolOptionSync(kOptionAllowDrmCapture)) { // DRM capture reaches the session and the login screen: no warning. - } else if (installed && + } else if (drmSupported && !isOptionFixed(kOptionAllowDrmCapture) && (bind.mainCurrentIsWayland() || bind.mainIsLoginWayland())) { final currentIsWayland = bind.mainCurrentIsWayland(); diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 6d9a1a527..8ca777e48 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -2890,7 +2890,11 @@ class _WaylandCardState extends State { "true"; final children = [ - if (isLinux && bind.mainIsInstalled() && !bind.isOutgoingOnly()) ...[ + if (isLinux && + bind.mainIsInstalled() && + !bind.isOutgoingOnly() && + bind.mainGetCommonSync(key: 'is-drm-capture-supported') == + 'true') ...[ _OptionCheckBox( context, 'Use DRM screen capture', kOptionAllowDrmCapture), Align( diff --git a/src/core_main.rs b/src/core_main.rs index 0f62d1e59..4e9911224 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -43,10 +43,12 @@ fn finish_macos_update(result: hbb_common::ResultType<()>) -> Option Option { + // Before global_init: on Linux its is_x11() can read Config (allow-drm-capture), and Config + // loads from a path named after the custom client's app name. + crate::load_custom_client(); if !crate::common::global_init() { return None; } - crate::load_custom_client(); #[cfg(windows)] if !crate::platform::windows::bootstrap() { // return None to terminate the process diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index d366d39e1..ed2417e8c 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -2780,6 +2780,8 @@ pub fn main_get_common(key: String) -> String { return crate::platform::is_win_10_or_greater().to_string(); #[cfg(not(target_os = "windows"))] return false.to_string(); + } else if key == "is-drm-capture-supported" { + return cfg!(all(target_os = "linux", feature = "drm")).to_string(); } else if key == "transfer-job-id" { return base::fs::get_next_job_id().to_string(); } else if key == "is-remote-modify-enabled-by-control-permissions" {