From 735b80c53377bde2c95cf2671b70cc9032747563 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 May 2026 06:50:14 +0000 Subject: [PATCH 1/2] Initial plan From 871bce2aa807a06f71059c3099a98b8426cf5210 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 May 2026 06:52:51 +0000 Subject: [PATCH 2/2] Avoid Linux Wayland current-window native call Agent-Logs-Url: https://github.com/libnativeapi/nativeapi-flutter/sessions/0c7fb074-d8cc-4d7e-b14a-6158ea3c2602 Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com> --- packages/nativeapi/lib/src/window_manager.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/nativeapi/lib/src/window_manager.dart b/packages/nativeapi/lib/src/window_manager.dart index 04e3cd2..eab3417 100644 --- a/packages/nativeapi/lib/src/window_manager.dart +++ b/packages/nativeapi/lib/src/window_manager.dart @@ -1,4 +1,6 @@ import 'dart:ffi' hide Size; +import 'dart:io'; + import 'package:flutter/widgets.dart'; import 'package:nativeapi/src/foundation/cnativeapi_bindings_mixin.dart'; import 'package:nativeapi/src/foundation/event_emitter.dart'; @@ -174,6 +176,11 @@ class WindowManager with EventEmitter, CNativeApiBindingsMixin { /// /// Returns the [Window] instance, or null if no window is active. Window? getCurrent() { + if (_isWaylandSession) { + final windows = getAll(); + return windows.isEmpty ? null : windows.first; + } + final nativeWindow = bindings.native_window_manager_get_current(); if (nativeWindow == nullptr) { return null; @@ -181,6 +188,16 @@ class WindowManager with EventEmitter, CNativeApiBindingsMixin { return Window(nativeWindow); } + bool get _isWaylandSession { + if (!Platform.isLinux) { + return false; + } + + final env = Platform.environment; + return env.containsKey('WAYLAND_DISPLAY') || + env['XDG_SESSION_TYPE'] == 'wayland'; + } + /// Shuts down the window manager and cleans up resources. /// /// This should typically be called when the application is exiting.