aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/next/website/src/content/docs/configuration.mdx2
-rw-r--r--docs/next/website/src/content/docs/ja/windows-beta.mdx4
-rw-r--r--docs/next/website/src/content/docs/windows-beta.mdx4
-rw-r--r--docs/next/website/src/content/docs/zh-cn/windows-beta.mdx4
-rw-r--r--src/client/mod.rs8
-rw-r--r--src/main.rs2
-rw-r--r--src/platform/fallback.rs4
-rw-r--r--src/platform/linux.rs33
-rw-r--r--src/platform/macos.rs4
-rw-r--r--src/platform/windows.rs4
10 files changed, 58 insertions, 11 deletions
diff --git a/docs/next/website/src/content/docs/configuration.mdx b/docs/next/website/src/content/docs/configuration.mdx
index 5ce4c037..e0ee46c5 100644
--- a/docs/next/website/src/content/docs/configuration.mdx
+++ b/docs/next/website/src/content/docs/configuration.mdx
@@ -331,7 +331,7 @@ The agent panel shows all agents across all spaces. `agent_panel_sort` can be `s
Set `mouse_capture = false` if you want your terminal to handle normal clicks, such as command-clicking URLs. With mouse capture enabled, Ctrl-click opens pane links when your terminal sends that modified click to Herdr. This includes macOS; Cmd-click is not reported separately from plain click while Herdr captures mouse input. Use Shift-Ctrl-click on Linux or Shift-Cmd-click on macOS for the terminal-native bypass path.
-`host_cursor` controls whether Herdr uses the outer terminal's native cursor or draws its own cursor as terminal cell content. The default, `auto`, draws Herdr's cursor on Windows to avoid ConPTY cursor flicker during active redraws, and uses the native cursor elsewhere. Set it to `native` to always use the outer terminal cursor, or `drawn` to always use Herdr's drawn cursor.
+`host_cursor` controls whether Herdr uses the outer terminal's native cursor or draws its own cursor as terminal cell content. The default, `auto`, draws Herdr's cursor on native Windows builds and WSL to avoid ConPTY cursor flicker during active redraws, and uses the native cursor elsewhere. Set it to `native` to always use the outer terminal cursor, or `drawn` to always use Herdr's drawn cursor.
Set `right_click_passthrough_modifier = "ctrl"` if you want Ctrl-right-click, hold, and drag gestures inside mouse-reporting pane apps to reach the app instead of opening Herdr's pane menu. The default is empty, which disables this passthrough. Supported modifiers are `ctrl`, `alt`, `cmd`, `super`, `meta`, and `hyper`; `shift` is rejected because many terminals reserve Shift+mouse for their own mouse bypass.
diff --git a/docs/next/website/src/content/docs/ja/windows-beta.mdx b/docs/next/website/src/content/docs/ja/windows-beta.mdx
index f6b45500..4ad4239a 100644
--- a/docs/next/website/src/content/docs/ja/windows-beta.mdx
+++ b/docs/next/website/src/content/docs/ja/windows-beta.mdx
@@ -61,9 +61,9 @@ Kitty graphics は実験的なままで、まだ Windows でのサポートをè¬
### カーソル描画
-Windows のターミナルは ConPTY 経由で Herdr を実行するため、フルスクリーン再描画中にネイティブの端末カーソルがちらついたり、ジャンプしたり、古い位置を一瞬表示したりすることがあります。Herdr のデフォルト `host_cursor = "auto"` は、Windows では Herdr のカーソルを端末セルの内容として描画し、Linux と macOS ではネイティブの端末カーソルを使い続けます。Windows でのトレードオフは、外側ターミナルのネイティブな点滅、形状、カーソル色の代わりに、Herdr 内で安定した非点滅カーソルを表示することです。
+Windows のターミナルは ConPTY 経由で Herdr を実行するため、フルスクリーン再描画中にネイティブの端末カーソルがちらついたり、ジャンプしたり、古い位置を一瞬表示したりすることがあります。Herdr のデフォルト `host_cursor = "auto"` は、ネイティブ Windows ビルドと WSL では Herdr のカーソルを端末セルの内容として描画し、それ以外の Linux と macOS ではネイティブの端末カーソルを使い続けます。Windows でのトレードオフは、外側ターミナルのネイティブな点滅、形状、カーソル色の代わりに、Herdr 内で安定した非点滅カーソルを表示することです。
-Windows で外側ターミナルのカーソルに戻すには、次を設定してください:
+ネイティブ Windows または WSL で外側ターミナルのカーソルに戻すには、次を設定してください:
```toml
[ui]
diff --git a/docs/next/website/src/content/docs/windows-beta.mdx b/docs/next/website/src/content/docs/windows-beta.mdx
index dbfe6964..064f806c 100644
--- a/docs/next/website/src/content/docs/windows-beta.mdx
+++ b/docs/next/website/src/content/docs/windows-beta.mdx
@@ -62,9 +62,9 @@ Kitty graphics remains experimental and is not claimed as Windows-supported yet.
### Cursor rendering
-Windows terminals run Herdr through ConPTY, and native terminal cursors can flicker, jump, or briefly show stale positions during active full-screen redraws. Herdr's default `host_cursor = "auto"` draws Herdr's cursor as terminal cell content on Windows, while Linux and macOS keep using the native terminal cursor. The Windows trade-off is a steady non-blinking cursor inside Herdr instead of the outer terminal's native blink, shape, and cursor color.
+Windows terminals run Herdr through ConPTY, and native terminal cursors can flicker, jump, or briefly show stale positions during active full-screen redraws. Herdr's default `host_cursor = "auto"` draws Herdr's cursor as terminal cell content for native Windows builds and WSL, while other Linux and macOS clients keep using the native terminal cursor. The Windows trade-off is a steady non-blinking cursor inside Herdr instead of the outer terminal's native blink, shape, and cursor color.
-To opt back into the outer terminal cursor on Windows, set:
+To opt back into the outer terminal cursor on native Windows or WSL, set:
```toml
[ui]
diff --git a/docs/next/website/src/content/docs/zh-cn/windows-beta.mdx b/docs/next/website/src/content/docs/zh-cn/windows-beta.mdx
index 971835ca..f1956e35 100644
--- a/docs/next/website/src/content/docs/zh-cn/windows-beta.mdx
+++ b/docs/next/website/src/content/docs/zh-cn/windows-beta.mdx
@@ -61,9 +61,9 @@ Kitty graphics 仍是实验性功能,尚未宣称支持 Windows。除非你专é—
### 光标渲染
-Windows 终端通过 ConPTY 运行 Herdr,在活跃的全屏重绘期间,原生终端光标可能闪烁、跳动,或短暂显示旧位置。Herdr 默认的 `host_cursor = "auto"` 会在 Windows 上把 Herdr 光标绘制为终端单元格内容,而 Linux 和 macOS 继续使用原生终端光标。Windows 上的取舍是:在 Herdr 内得到稳定的不闪烁光标,但不使用外层终端的原生闪烁、形状和光标颜色。
+Windows 终端通过 ConPTY 运行 Herdr,在活跃的全屏重绘期间,原生终端光标可能闪烁、跳动,或短暂显示旧位置。Herdr 默认的 `host_cursor = "auto"` 会在原生 Windows 构建和 WSL 上把 Herdr 光标绘制为终端单元格内容,而其他 Linux 和 macOS 客户端继续使用原生终端光标。Windows 上的取舍是:在 Herdr 内得到稳定的不闪烁光标,但不使用外层终端的原生闪烁、形状和光标颜色。
-要在 Windows 上改回外层终端光标,请设置:
+要在原生 Windows 或 WSL 上改回外层终端光标,请设置:
```toml
[ui]
diff --git a/src/client/mod.rs b/src/client/mod.rs
index bdc67880..90a73ec8 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -453,7 +453,9 @@ fn write_terminal_restore_postlude(
fn should_draw_host_cursor(mode: crate::config::HostCursorModeConfig) -> bool {
match mode {
- crate::config::HostCursorModeConfig::Auto => cfg!(windows),
+ crate::config::HostCursorModeConfig::Auto => {
+ crate::platform::should_draw_host_cursor_by_default()
+ }
crate::config::HostCursorModeConfig::Native => false,
crate::config::HostCursorModeConfig::Drawn => true,
}
@@ -2198,10 +2200,10 @@ mod tests {
}
#[test]
- fn host_cursor_policy_auto_uses_drawn_cursor_on_windows() {
+ fn host_cursor_policy_auto_uses_platform_default() {
assert_eq!(
should_draw_host_cursor(crate::config::HostCursorModeConfig::Auto),
- cfg!(windows)
+ crate::platform::should_draw_host_cursor_by_default()
);
}
diff --git a/src/main.rs b/src/main.rs
index deb332b9..575e23f8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -259,7 +259,7 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration
# mouse_capture = true
# Host cursor policy: "auto", "native", or "drawn".
-# "auto" draws Herdr's own cursor on Windows to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
+# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.
# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.
# host_cursor = "auto"
diff --git a/src/platform/fallback.rs b/src/platform/fallback.rs
index 382ccf5e..6b5700cc 100644
--- a/src/platform/fallback.rs
+++ b/src/platform/fallback.rs
@@ -6,6 +6,10 @@ use super::{ClipboardImage, ForegroundJob, Signal};
/// Unsupported platform stub.
pub fn raise_server_nofile_limit() {}
+pub(crate) fn should_draw_host_cursor_by_default() -> bool {
+ false
+}
+
fn raw_command_argv(command: &str, flag: &str) -> Vec<std::ffi::OsString> {
vec!["/bin/sh".into(), flag.into(), command.into()]
}
diff --git a/src/platform/linux.rs b/src/platform/linux.rs
index be0c97b9..2013873f 100644
--- a/src/platform/linux.rs
+++ b/src/platform/linux.rs
@@ -14,6 +14,7 @@ use super::{
};
const FOREGROUND_MEMBERS_CACHE_TTL: Duration = Duration::from_millis(250);
+const WSL_MARKER_ENV_VARS: &[&str] = &["WSL_DISTRO_NAME", "WSL_INTEROP"];
#[derive(Debug, Clone, PartialEq, Eq)]
struct ProcGroupMember {
@@ -39,6 +40,30 @@ static FOREGROUND_MEMBERS_CACHE: Mutex<ForegroundMembersCache> =
pub fn raise_server_nofile_limit() {}
+pub(crate) fn should_draw_host_cursor_by_default() -> bool {
+ running_inside_wsl()
+}
+
+fn running_inside_wsl() -> bool {
+ proc_file_indicates_wsl("/proc/sys/kernel/osrelease")
+ || proc_file_indicates_wsl("/proc/version")
+ || WSL_MARKER_ENV_VARS
+ .iter()
+ .any(|key| std::env::var_os(key).is_some())
+ || std::path::Path::new("/run/WSL").exists()
+}
+
+fn proc_file_indicates_wsl(path: &str) -> bool {
+ std::fs::read_to_string(path)
+ .map(|text| text_indicates_wsl(&text))
+ .unwrap_or(false)
+}
+
+fn text_indicates_wsl(text: &str) -> bool {
+ let text = text.to_ascii_lowercase();
+ text.contains("microsoft") || text.contains("wsl")
+}
+
fn raw_command_argv(command: &str, flag: &str) -> Vec<std::ffi::OsString> {
vec!["/bin/sh".into(), flag.into(), command.into()]
}
@@ -713,6 +738,14 @@ mod tests {
}
#[test]
+ fn wsl_marker_detection_matches_kernel_release_text() {
+ assert!(text_indicates_wsl("5.15.167.4-microsoft-standard-WSL2"));
+ assert!(text_indicates_wsl("4.4.0-19041-Microsoft"));
+ assert!(!text_indicates_wsl("6.8.0-64-generic"));
+ assert!(!text_indicates_wsl(""));
+ }
+
+ #[test]
fn foreground_members_indexes_by_process_group() {
let by_group = foreground_members(&[
(10, "shell", 10),
diff --git a/src/platform/macos.rs b/src/platform/macos.rs
index f2441f06..70eea7ec 100644
--- a/src/platform/macos.rs
+++ b/src/platform/macos.rs
@@ -16,6 +16,10 @@ const PROC_PGRP_ONLY: u32 = 2;
const SERVER_NOFILE_LIMIT_TARGET: libc::rlim_t = 8192;
const CF_STRING_ENCODING_UTF8: u32 = 0x0800_0100;
+pub(crate) fn should_draw_host_cursor_by_default() -> bool {
+ false
+}
+
fn raw_command_argv(command: &str, flag: &str) -> Vec<std::ffi::OsString> {
vec!["/bin/sh".into(), flag.into(), command.into()]
}
diff --git a/src/platform/windows.rs b/src/platform/windows.rs
index 49a68111..a44ebafd 100644
--- a/src/platform/windows.rs
+++ b/src/platform/windows.rs
@@ -38,6 +38,10 @@ use super::{ClipboardImage, ForegroundJob, Signal};
const STILL_ACTIVE: u32 = 259;
+pub(crate) fn should_draw_host_cursor_by_default() -> bool {
+ true
+}
+
#[derive(Debug, Clone, PartialEq, Eq)]
struct WindowsProcessEntry {
pid: u32,