Repository: flutter
Issue: WidgetsBindingObserver doesn't report gaining / losing focus on GNOME when changing workspace views
Labels: framework,platform-linux,a: desktop,has reproducible steps,P2,found in release: 3.22,found in release: 3.23,team-linux,triaged-linux

### Steps to reproduce

1. Create a `StatefulWidget` that uses the `WidgetsBindingObserver` class.
2. Launch Flutter app and click on another window, then click back to Flutter app.
3. Move focus to another workspace in GNOME, then move back.

### Expected results

For steps `2.` and `3.`, I am hoping for the same results: logging of `AppLifecycleState.inactive` `AppLifecycleState.resumed` lifecycle changes.


### Actual results

Step `2.` produces the expected result: lifecycle changes are printed out. However, for step `3.` no lifecycle changes are logged, even though the app is gaining and losing visibility.

### Code sample

<details open><summary>Code sample</summary>

```dart
class _MyWidgetState extends State<MyWidget> with WidgetsBindingObserver {
  _MyWidgetState();

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    log(state.toString());
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    log(state.toString());
  }

  @override
  Widget build(BuildContext context) {
    // widgets here ...
  }
```

</details>

### Screenshots or Video

_No response_

### Logs

<details open><summary>Logs</summary>

```console
Launching lib/main.dart on Linux in debug mode...
✓ Built build/linux/x64/debug/bundle/my_app
Connecting to VM Service at ws://127.0.0.1:33213/MoR5spDBCrU=/ws
[log] App data directory: /home/andrew/.local/share/com.example.my_app/
[log] AppLifecycleState.inactive
[log] AppLifecycleState.resumed
Lost connection to device.

Exited.
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.22.2, on openSUSE Tumbleweed 6.9.5-1-default, locale en_US.UTF-8)
    • Flutter version 3.22.2 on channel stable at /home/andrew/.local/lib/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (2 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/andrew/Android/Sdk
    • Platform android-VanillaIceCream, build-tools 34.0.0
    • ANDROID_SDK_ROOT = /home/andrew/Android/Sdk
    • Java binary at: /home/andrew/.local/lib/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = epiphany

[✓] Linux toolchain - develop for Linux desktop
    • clang version 18.1.6
    • cmake version 3.29.4
    • ninja version 1.12.1
    • pkg-config version 2.2.0

[✓] Android Studio (version 2023.3)
    • Android Studio at /home/andrew/.local/lib/android-studio
    • Flutter plugin version 79.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • openSUSE Tumbleweed 6.9.5-1-default
    • Chrome (web)    • chrome • web-javascript • Web 46.1
    ! Device emulator-5554 is offline.

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>