Skip to content

fix(linux): prevent startup panic from unrealized capsule GDK window | fix(linux): 修复胶囊窗口因 GDK 未实例化导致的启动崩溃#792

Merged
H-Chris233 merged 2 commits into
Open-Less:betafrom
yuanchenglu:fix/linux-startup-crash-unrealized-capsule-window
Jul 14, 2026
Merged

fix(linux): prevent startup panic from unrealized capsule GDK window | fix(linux): 修复胶囊窗口因 GDK 未实例化导致的启动崩溃#792
H-Chris233 merged 2 commits into
Open-Less:betafrom
yuanchenglu:fix/linux-startup-crash-unrealized-capsule-window

Conversation

@yuanchenglu

@yuanchenglu yuanchenglu commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

User description

Problem

OpenLess crashes on Linux X11 immediately at startup with:

Root Cause

The capsule window is defined in tauri.conf.json with visible: false + transparent: true. On Linux/GTK3, a hidden window never has its underlying GDK window realized. When capsule.set_ignore_cursor_events(true) is called during startup, tao internally calls window.window().unwrap() which returns None for the unrealized window — panic.

This is the same issue reported in:

Fix

Before calling set_ignore_cursor_events, move the window off-screen and call show() to force GDK window realization. The window is then repositioned correctly by the existing position_capsule_bottom_center() and hidden as normal.

The change is Linux-only (#[cfg(target_os = "linux")]) and confined to the capsule setup block; no other call sites are touched.

Testing

Verified on Deepin Linux 23 (X11, DDE/kwin_x11):

  • Before: crashes 100% on startup
  • After: app initializes normally, hotkey listeners register, tray icon appears, capsule shows/hides on speak

References


PR Type

Bug fix


Description

  • Prevent Linux X11 crash when capsule window has visible: false + transparent: true

  • Force GDK window realization via gtk_window.realize() before setting cursor passthrough

  • Avoids window.window().unwrap() panic in tao’s Linux event loop


Diagram Walkthrough

flowchart LR
  A[Capsule window created with visible=false] --> B[gtk_window? Ok]
  B --> C[gtk_window.realize()]
  C --> D[set_ignore_cursor_events true]
  D --> E[Position capsule normally]
  B --> F[Err: skip cursor passthrough]
Loading

File Walkthrough

Relevant files
Bug fix
lib.rs
Force GDK window realization on Linux before input passthrough

openless-all/app/src-tauri/src/lib.rs

  • Added use gtk::prelude::WidgetExt; under #[cfg(target_os = "linux")]
  • Before set_ignore_cursor_events, retrieve GTK window and call
    realize() to force GDK window creation
  • Only execute cursor passthrough if GTK window is obtained successfully
+24/-2   
Dependencies
Cargo.toml
Add gtk crate dependency for Linux build                                 

openless-all/app/src-tauri/Cargo.toml

  • Added gtk = "0.18" dependency for Linux target
+1/-0     

…| fix(linux): 修复胶囊窗口因 GDK 未实例化导致的启动崩溃

On Linux X11, when the capsule window is created with `visible: false` +
`transparent: true` in tauri.conf.json, its underlying GDK window is never
realized. The subsequent call to `capsule.set_ignore_cursor_events(true)`
triggers a panic inside tao's Linux event loop (event_loop.rs:457) because
`window.window().unwrap()` returns `None` for an unrealized GDK window.

The fix follows the same approach as voicebox PR#837 (PhamBit):
force GDK window realization before calling set_ignore_cursor_events, by
first moving the window off-screen and calling show(). The window is then
repositioned correctly by the existing position_capsule_bottom_center()
call and hidden as normal.

Refs:
  - jamiepine/voicebox#837
  - tauri-apps/tao#635

在 Linux X11 上,tauri.conf.json 中定义的 capsule 窗口设置了
visible: false + transparent: true,导致其底层 GDK 窗口从未被实例化。
随后调用 capsule.set_ignore_cursor_events(true) 时,tao 的 Linux 事件循环
(event_loop.rs:457) 因 window.window().unwrap() 返回 None 而 panic 崩溃。

修复方法参考 voicebox PR#837:在设置鼠标穿透前先将窗口移出屏幕并
调用 show() 强制 GDK 实例化,后续由原有的 position_capsule_bottom_center()
重新定位并隐藏。
@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 641da39)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 641da39

@H-Chris233
H-Chris233 merged commit 6140a4b into Open-Less:beta Jul 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants