Skip to content

Handle WindowManager.getCurrent() safely on Linux Wayland#7

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-current-window-error-linux
Draft

Handle WindowManager.getCurrent() safely on Linux Wayland#7
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-current-window-error-linux

Conversation

Copy link
Copy Markdown

Copilot AI commented May 24, 2026

On Linux Wayland/XWayland sessions, calling WindowManager.getCurrent() can hit a GTK/GDK assertion path (gdk_device_get_window_at_position_double) and emit critical errors when resolving the current window.

  • Problem summary

    • getCurrent() relied on a native “current focused window” lookup that is not reliable under Wayland session semantics in this environment.
  • What changed

    • Added Linux Wayland session detection in WindowManager (WAYLAND_DISPLAY / XDG_SESSION_TYPE=wayland).
    • Updated getCurrent() to use a safe fallback on Wayland:
      • return the first managed window from getAll() (or null if none),
      • skip the native native_window_manager_get_current() call in this path.
    • Kept existing behavior unchanged for non-Linux or non-Wayland sessions.
  • Resulting behavior

    • Avoids the problematic native focus-query path on Linux Wayland while preserving API shape (Window?) and existing behavior elsewhere.
final windowManager = WindowManager.instance;
final window = windowManager.getCurrent(); // Wayland: resolved via managed-window fallback

Copilot AI linked an issue May 24, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix error when getting current window in Flutter on Linux Handle WindowManager.getCurrent() safely on Linux Wayland May 24, 2026
Copilot AI requested a review from lijy91 May 24, 2026 06:53
Copilot finished work on behalf of lijy91 May 24, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux] [Error] Failed when get current window.

2 participants