Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(pet): 原生 Wayland 下跳过桌宠位置持久化

fainabi9418db5c9bbd
diff --git a/src-tauri/src/desktop/pet.rs b/src-tauri/src/desktop/pet.rs
index 1b321f44..65990f3d 100644
--- a/src-tauri/src/desktop/pet.rs
+++ b/src-tauri/src/desktop/pet.rs
@@ -18,7 +18,9 @@
//! - `always_on_top` 在 Windows 上 Tauri 原生 API 即可保持置顶(BongoCat 为
//! 额外稳定性用 SetWindowPos 循环轮询,本项目暂不做该平台特定加固)。
//! - 原生 Wayland 会话下 `always_on_top` 与 `set_position` 都不生效,桌宠被主窗口
-//! 遮挡(issue #649)。判定见 `crate::pet_overlay_supported`,前端据此提示用户。
+//! 遮挡(issue #649,上游 tauri-apps/tao#1134 已按「Wayland 不支持」补文档结案)。
+//! 同一后端下 `outer_position()` 恒为 `{x:0,y:0}`,几何持久化因此一并跳过。
+//! 判定见 `crate::pet_overlay_supported`,前端据此提示用户。
use crate::config::{store_dat_file_name, STORE_PET_WINDOW_STATE_KEY};
use serde::{Deserialize, Serialize};
@@ -78,7 +80,14 @@ pub fn get_pet_window_position<R: Runtime>(app: &AppHandle<R>) -> PetWindowPosit
}
/// 保存桌宠窗口位置(用户拖动后由 Moved 事件调用)。
+///
+/// 原生 Wayland 下跳过写入:两个调用点的位置都取自 `outer_position()`,而 GDK 的
+/// Wayland 后端不向客户端报告窗口在屏幕上的坐标,该调用返回 `{x:0,y:0}` 且不报错。
+/// 照写会把上一次在 X11 会话里存下的有效位置覆盖成原点(issue #649)。
pub fn save_pet_window_position<R: Runtime>(app: &AppHandle<R>, position: &PetWindowPosition) {
+ if !crate::pet_overlay_supported_env() {
+ return;
+ }
let store = app
.store(store_dat_file_name())
.expect("Failed to load store for pet window position");