fix(linux): prevent startup panic from unrealized capsule GDK window | fix(linux): 修复胶囊窗口因 GDK 未实例化导致的启动崩溃#792
Open
yuanchenglu wants to merge 1 commit into
Conversation
…| 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() 重新定位并隐藏。
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Problem
OpenLess crashes on Linux X11 immediately at startup with:
Root Cause
The capsule window is defined in
tauri.conf.jsonwithvisible: false+transparent: true. On Linux/GTK3, a hidden window never has its underlying GDK window realized. Whencapsule.set_ignore_cursor_events(true)is called during startup, tao internally callswindow.window().unwrap()which returnsNonefor the unrealized window — panic.This is the same issue reported in:
Fix
Before calling
set_ignore_cursor_events, move the window off-screen and callshow()to force GDK window realization. The window is then repositioned correctly by the existingposition_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):
References
PR Type
Bug fix
Description
Fix Linux startup crash due to unrealized GDK capsule window.
Force GDK window realization before calling set_ignore_cursor_events.
Diagram Walkthrough
File Walkthrough
lib.rs
Fix Linux capsule GDK realization crashopenless-all/app/src-tauri/src/lib.rs
setting ignore cursor events.
reposition.