From 44a1ec667e7a703ca8e479787b47e37cbf7037e9 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Thu, 22 Oct 2026 16:06:28 -0400 Subject: [PATCH] switch to new window_manager from main --- lib/controllers/unified_push.dart | 2 +- lib/main.dart | 12 +-- lib/widgets/appbar.dart | 16 ++-- linux/flutter/generated_plugin_registrant.cc | 8 -- linux/flutter/generated_plugins.cmake | 2 - linux/nix/devshell.nix | 8 +- linux/nix/pkg/default.nix | 12 ++- linux/nix/pkg/hook_pkg_config.nix | 32 +++++++ linux/runner/my_application.cc | 5 -- macos/Flutter/GeneratedPluginRegistrant.swift | 4 - pubspec.lock | 83 ++++++++----------- pubspec.yaml | 7 +- .../flutter/generated_plugin_registrant.cc | 6 -- windows/flutter/generated_plugins.cmake | 2 - 14 files changed, 102 insertions(+), 97 deletions(-) create mode 100644 linux/nix/pkg/hook_pkg_config.nix diff --git a/lib/controllers/unified_push.dart b/lib/controllers/unified_push.dart index 67ef8c2..16f10c5 100644 --- a/lib/controllers/unified_push.dart +++ b/lib/controllers/unified_push.dart @@ -88,7 +88,7 @@ class UnifiedPushController extends AsyncNotifier { if (notification == null || (!isInBackground && - await windowManager.isFocused().onError((_, _) => true) && + (WindowManager.instance.getCurrent()?.isFocused ?? true) && ref.read(SelectedRoomController.provider) == notification.roomId)) { if (isInBackground) exit(0); diff --git a/lib/main.dart b/lib/main.dart index 59fa974..50a4b75 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -83,14 +83,10 @@ void main(List args) async { exit(0); } else { if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) { - await windowManager.ensureInitialized(); - await windowManager.waitUntilReadyToShow( - WindowOptions( - titleBarStyle: TitleBarStyle.hidden, - windowButtonVisibility: false, - ), - ); - await windowManager.setMinimumSize(Size.square(500)); + WindowManager.instance.getCurrent() + ?..titleBarStyle = .hidden + ..isWindowControlButtonsVisible = false + ..minimumSize = Size.square(500).toNative(); } runApp( diff --git a/lib/widgets/appbar.dart b/lib/widgets/appbar.dart index 226da68..a3f2919 100644 --- a/lib/widgets/appbar.dart +++ b/lib/widgets/appbar.dart @@ -23,14 +23,15 @@ final class const Appbar({ @override Widget build(BuildContext context, WidgetRef ref) { - Future maximize() async { - final isMaximized = await windowManager.isMaximized(); + void maximize() { + final window = WindowManager.instance.getCurrent(); + if (window == null) return; - if (isMaximized) { - return windowManager.unmaximize(); + if (window.isMaximized) { + return window.unmaximize(); } - return windowManager.maximize(); + return window.maximize(); } return GestureDetector( @@ -39,7 +40,7 @@ final class const Appbar({ .whenOrNull( data: (settings) => settings.linuxMobileMode ? null - : (_) => windowManager.startDragging(), + : (_) => WindowManager.instance.getCurrent()?.startDragging(), ), child: AppBar( leading: leading == null ? null : InkWell(onTap: onTap, child: leading), @@ -62,7 +63,8 @@ final class const Appbar({ false) IconButton( tooltip: "Minimize window", - onPressed: windowManager.minimize, + onPressed: () => + WindowManager.instance.getCurrent()?.minimize(), icon: const Icon(Icons.minimize), ), if (!Platform.isLinux) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index b92986a..077376d 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -12,9 +12,7 @@ #include #include #include -#include #include -#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) app_links_linux_registrar = @@ -35,13 +33,7 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) pasteboard_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "PasteboardPlugin"); pasteboard_plugin_register_with_registrar(pasteboard_registrar); - g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin"); - screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); - g_autoptr(FlPluginRegistrar) window_manager_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); - window_manager_plugin_register_with_registrar(window_manager_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 553a7ae..66d7f77 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -9,9 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST media_kit_libs_linux media_kit_video pasteboard - screen_retriever_linux url_launcher_linux - window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/linux/nix/devshell.nix b/linux/nix/devshell.nix index 6b2b94d..a47f824 100644 --- a/linux/nix/devshell.nix +++ b/linux/nix/devshell.nix @@ -36,7 +36,13 @@ pkgs.mkShell { }) android.platform-tools ] - ++ lib.optional pkgs.stdenv.isLinux wayland; + ++ lib.optionals pkgs.stdenv.isLinux [ + wayland + # nativeapi includes XInput2.h, which needs these, but xi.pc only lists them privately + libxext + libxfixes + (callPackage ./pkg/hook_pkg_config.nix { }) + ]; env = rec { LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.libclang ]; diff --git a/linux/nix/pkg/default.nix b/linux/nix/pkg/default.nix index 3e13fcb..bb6b2bf 100644 --- a/linux/nix/pkg/default.nix +++ b/linux/nix/pkg/default.nix @@ -3,6 +3,8 @@ callPackage, mpv-unwrapped, libass, + libxext, + libxfixes, libclang, flutter, stdenv, @@ -25,9 +27,14 @@ flutter.buildFlutterApplication { "--dart-define=GIT_COMMIT=${commit}" ]; + nativeBuildInputs = [ (callPackage ./hook_pkg_config.nix { }) ]; + buildInputs = [ mpv-unwrapped libass + # nativeapi includes XInput2.h, which needs these, but xi.pc only lists them privately + libxext + libxfixes ]; env.LIBCLANG_PATH = lib.makeLibraryPath [ libclang ]; @@ -42,9 +49,10 @@ flutter.buildFlutterApplication { m3e_design = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI="; native_toolchain_cmake = "sha256-/drnHZebmTnsCnHgC1xmlAe+U4PSrjw5Sm9axicuTrY="; navigation_rail_m3e = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI="; - unifiedpush_linux = "sha256-aIF/8oabSuuZo7K6qr4r7UBmf57qgoGAXyJ40fdntuQ="; - unifiedpush_platform_interface = "sha256-aIF/8oabSuuZo7K6qr4r7UBmf57qgoGAXyJ40fdntuQ="; + unifiedpush_linux = "sha256-KQKyBPL2ORK9O89C4K3RHGve/lvFaU1vIjSDnj6+bj4="; + unifiedpush_platform_interface = "sha256-KQKyBPL2ORK9O89C4K3RHGve/lvFaU1vIjSDnj6+bj4="; webcrypto = "sha256-HW0NukbddwOYd9iVUFA3L8iy1qggnyOBgcbMj0MTYss="; + window_manager = "sha256-xUd5hG+/V6F+m0ZUL/3XGPACFG/zqI5JM6IaMVvLgx4="; xdg_desktop_portal = "sha256-8GgiXHGv+wy6hJgj/rZxbymMitNVmdDLAnedZm9STSc="; }; diff --git a/linux/nix/pkg/hook_pkg_config.nix b/linux/nix/pkg/hook_pkg_config.nix new file mode 100644 index 0000000..b5219e5 --- /dev/null +++ b/linux/nix/pkg/hook_pkg_config.nix @@ -0,0 +1,32 @@ +{ + stdenvNoCC, + pkg-config, + pkg-config-unwrapped, + makeWrapper, + gtk3, + libx11, + libxi, +}: + +# Build hooks run with a filtered environment that drops PKG_CONFIG_PATH, so +# nativeapi's hook can only find its libraries through a pkg-config on PATH. +stdenvNoCC.mkDerivation { + name = "hook-pkg-config"; + dontUnpack = true; + + nativeBuildInputs = [ + pkg-config + makeWrapper + ]; + + buildInputs = [ + gtk3 + libx11 + libxi + ]; + + installPhase = '' + makeWrapper ${pkg-config-unwrapped}/bin/pkg-config $out/bin/pkg-config \ + --prefix PKG_CONFIG_PATH : "$PKG_CONFIG_PATH" + ''; +} diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc index bf6e5ef..f5795d0 100644 --- a/linux/runner/my_application.cc +++ b/linux/runner/my_application.cc @@ -155,11 +155,6 @@ static void my_application_activate( } #endif - gtk_widget_set_size_request( - GTK_WIDGET(window), - 250, - -1); - if (use_header_bar) { GtkHeaderBar* header_bar = GTK_HEADER_BAR( diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cc20897..f10315f 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -13,11 +13,9 @@ import media_kit_libs_macos_video import media_kit_video import package_info_plus import pasteboard -import screen_retriever_macos import shared_preferences_foundation import url_launcher_macos import wakelock_plus -import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) @@ -28,9 +26,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) - ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) - WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 05ea34c..d3101a9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -217,6 +217,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.3" + cnativeapi: + dependency: transitive + description: + name: cnativeapi + sha256: "251fb93cd7ec205445fa512ee5ddeb0b82b3273d071cfc0784ddffbbdebbf5d3" + url: "https://pub.dev" + source: hosted + version: "0.5.2" code_assets: dependency: "direct main" description: @@ -1041,6 +1049,22 @@ packages: url: "https://github.com/Henry-Hiles/native_toolchain_cmake" source: git version: "0.3.2" + nativeapi: + dependency: transitive + description: + name: nativeapi + sha256: c4625e81f5ce2f4a9044c0ec1bdb38355119ffcf89e24eb20ae9fc5027a01e59 + url: "https://pub.dev" + source: hosted + version: "0.5.2" + nativeapi_flutter: + dependency: transitive + description: + name: nativeapi_flutter + sha256: "4feaa68cb5c4fc3b2eeaee1a25e56e2d092178e1c59516d9db5dd34940dcf36c" + url: "https://pub.dev" + source: hosted + version: "0.5.2" navigation_rail_m3e: dependency: "direct main" description: @@ -1282,46 +1306,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.6" - screen_retriever: - dependency: transitive - description: - name: screen_retriever - sha256: ace919117a7520c13a50a6259e60c4a0d4cbe98809468792a91b5c5adada2aa6 - url: "https://pub.dev" - source: hosted - version: "0.2.2" - screen_retriever_linux: - dependency: transitive - description: - name: screen_retriever_linux - sha256: "7b52006a5ceae1f3d5af7f77188c3290d6e7d8ded16d99809bea84967c65c257" - url: "https://pub.dev" - source: hosted - version: "0.2.2" - screen_retriever_macos: - dependency: transitive - description: - name: screen_retriever_macos - sha256: a1489b99cce597c45a54b9aae1cd94c8d4705353b7e0bb2457a6e4de44e0ad8a - url: "https://pub.dev" - source: hosted - version: "0.2.2" - screen_retriever_platform_interface: - dependency: transitive - description: - name: screen_retriever_platform_interface - sha256: "94a5535277510a63184ca178ce12a1449bc0b38618879aa1c18bf57369c5064a" - url: "https://pub.dev" - source: hosted - version: "0.2.2" - screen_retriever_windows: - dependency: transitive - description: - name: screen_retriever_windows - sha256: dafc6922b0bfbf1d48cf3ccbf519b4fff47bdcb820da1728ea6db675fecc9324 - url: "https://pub.dev" - source: hosted - version: "0.2.2" shared_preferences: dependency: "direct main" description: @@ -1539,8 +1523,8 @@ packages: dependency: "direct overridden" description: path: unifiedpush_linux - ref: "quad/feat/should-write-service-option" - resolved-ref: "7589b07ef4280820e4adea165d3d86b219f6022c" + ref: "quad/nexus" + resolved-ref: "5b31fabcc260c2ff07c4499099ae20591e2c2cb9" url: "https://codeberg.org/Henry-Hiles/flutter-connector" source: git version: "1.0.1" @@ -1548,8 +1532,8 @@ packages: dependency: "direct overridden" description: path: unifiedpush_platform_interface - ref: "quad/feat/should-write-service-option" - resolved-ref: "7589b07ef4280820e4adea165d3d86b219f6022c" + ref: "quad/nexus" + resolved-ref: "5b31fabcc260c2ff07c4499099ae20591e2c2cb9" url: "https://codeberg.org/Henry-Hiles/flutter-connector" source: git version: "4.0.0" @@ -1773,11 +1757,12 @@ packages: window_manager: dependency: "direct main" description: - name: window_manager - sha256: "05c231fd7b23d2380f14c5cc10b7b93d60d4fa4a2fb4e0f032de27e44b5560e9" - url: "https://pub.dev" - source: hosted - version: "0.5.2" + path: "." + ref: HEAD + resolved-ref: "80acd536a1ea1c121c36e32d30e638a295087ed1" + url: "https://github.com/leanflutter/window_manager" + source: git + version: "0.6.0" xdg_desktop_portal: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 4eedbd9..47df5ce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,17 +41,20 @@ dependency_overrides: unifiedpush_linux: git: url: https://codeberg.org/Henry-Hiles/flutter-connector - ref: quad/feat/should-write-service-option + ref: quad/nexus path: unifiedpush_linux unifiedpush_platform_interface: git: url: https://codeberg.org/Henry-Hiles/flutter-connector - ref: quad/feat/should-write-service-option + ref: quad/nexus path: unifiedpush_platform_interface linkify: git: url: https://github.com/appelladev/linkify ref: fix/consecutive-periods-loose-url + window_manager: + git: + url: https://github.com/leanflutter/window_manager dependencies: flutter: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 1d53353..7dc1c3c 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -12,9 +12,7 @@ #include #include #include -#include #include -#include void RegisterPlugins(flutter::PluginRegistry* registry) { AppLinksPluginCApiRegisterWithRegistrar( @@ -29,10 +27,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi")); PasteboardPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PasteboardPlugin")); - ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); - WindowManagerPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 05e3fad..68413e7 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -9,9 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST media_kit_libs_windows_video media_kit_video pasteboard - screen_retriever_windows url_launcher_windows - window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST