switch to new window_manager from main

This commit is contained in:
Henry Hiles 2026-10-22 16:06:28 -04:00
commit 44a1ec667e
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
14 changed files with 102 additions and 97 deletions

View file

@ -88,7 +88,7 @@ class UnifiedPushController extends AsyncNotifier<String?> {
if (notification == null || if (notification == null ||
(!isInBackground && (!isInBackground &&
await windowManager.isFocused().onError((_, _) => true) && (WindowManager.instance.getCurrent()?.isFocused ?? true) &&
ref.read(SelectedRoomController.provider) == ref.read(SelectedRoomController.provider) ==
notification.roomId)) { notification.roomId)) {
if (isInBackground) exit(0); if (isInBackground) exit(0);

View file

@ -83,14 +83,10 @@ void main(List<String> args) async {
exit(0); exit(0);
} else { } else {
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) { if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
await windowManager.ensureInitialized(); WindowManager.instance.getCurrent()
await windowManager.waitUntilReadyToShow( ?..titleBarStyle = .hidden
WindowOptions( ..isWindowControlButtonsVisible = false
titleBarStyle: TitleBarStyle.hidden, ..minimumSize = Size.square(500).toNative();
windowButtonVisibility: false,
),
);
await windowManager.setMinimumSize(Size.square(500));
} }
runApp( runApp(

View file

@ -23,14 +23,15 @@ final class const Appbar({
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
Future<void> maximize() async { void maximize() {
final isMaximized = await windowManager.isMaximized(); final window = WindowManager.instance.getCurrent();
if (window == null) return;
if (isMaximized) { if (window.isMaximized) {
return windowManager.unmaximize(); return window.unmaximize();
} }
return windowManager.maximize(); return window.maximize();
} }
return GestureDetector( return GestureDetector(
@ -39,7 +40,7 @@ final class const Appbar({
.whenOrNull( .whenOrNull(
data: (settings) => settings.linuxMobileMode data: (settings) => settings.linuxMobileMode
? null ? null
: (_) => windowManager.startDragging(), : (_) => WindowManager.instance.getCurrent()?.startDragging(),
), ),
child: AppBar( child: AppBar(
leading: leading == null ? null : InkWell(onTap: onTap, child: leading), leading: leading == null ? null : InkWell(onTap: onTap, child: leading),
@ -62,7 +63,8 @@ final class const Appbar({
false) false)
IconButton( IconButton(
tooltip: "Minimize window", tooltip: "Minimize window",
onPressed: windowManager.minimize, onPressed: () =>
WindowManager.instance.getCurrent()?.minimize(),
icon: const Icon(Icons.minimize), icon: const Icon(Icons.minimize),
), ),
if (!Platform.isLinux) if (!Platform.isLinux)

View file

@ -12,9 +12,7 @@
#include <media_kit_libs_linux/media_kit_libs_linux_plugin.h> #include <media_kit_libs_linux/media_kit_libs_linux_plugin.h>
#include <media_kit_video/media_kit_video_plugin.h> #include <media_kit_video/media_kit_video_plugin.h>
#include <pasteboard/pasteboard_plugin.h> #include <pasteboard/pasteboard_plugin.h>
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) app_links_linux_registrar = g_autoptr(FlPluginRegistrar) app_links_linux_registrar =
@ -35,13 +33,7 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) pasteboard_registrar = g_autoptr(FlPluginRegistrar) pasteboard_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "PasteboardPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "PasteboardPlugin");
pasteboard_plugin_register_with_registrar(pasteboard_registrar); 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 = g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 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);
} }

View file

@ -9,9 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
media_kit_libs_linux media_kit_libs_linux
media_kit_video media_kit_video
pasteboard pasteboard
screen_retriever_linux
url_launcher_linux url_launcher_linux
window_manager
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST

View file

@ -36,7 +36,13 @@ pkgs.mkShell {
}) })
android.platform-tools 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 { env = rec {
LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.libclang ]; LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.libclang ];

View file

@ -3,6 +3,8 @@
callPackage, callPackage,
mpv-unwrapped, mpv-unwrapped,
libass, libass,
libxext,
libxfixes,
libclang, libclang,
flutter, flutter,
stdenv, stdenv,
@ -25,9 +27,14 @@ flutter.buildFlutterApplication {
"--dart-define=GIT_COMMIT=${commit}" "--dart-define=GIT_COMMIT=${commit}"
]; ];
nativeBuildInputs = [ (callPackage ./hook_pkg_config.nix { }) ];
buildInputs = [ buildInputs = [
mpv-unwrapped mpv-unwrapped
libass libass
# nativeapi includes XInput2.h, which needs these, but xi.pc only lists them privately
libxext
libxfixes
]; ];
env.LIBCLANG_PATH = lib.makeLibraryPath [ libclang ]; env.LIBCLANG_PATH = lib.makeLibraryPath [ libclang ];
@ -42,9 +49,10 @@ flutter.buildFlutterApplication {
m3e_design = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI="; m3e_design = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI=";
native_toolchain_cmake = "sha256-/drnHZebmTnsCnHgC1xmlAe+U4PSrjw5Sm9axicuTrY="; native_toolchain_cmake = "sha256-/drnHZebmTnsCnHgC1xmlAe+U4PSrjw5Sm9axicuTrY=";
navigation_rail_m3e = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI="; navigation_rail_m3e = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI=";
unifiedpush_linux = "sha256-aIF/8oabSuuZo7K6qr4r7UBmf57qgoGAXyJ40fdntuQ="; unifiedpush_linux = "sha256-KQKyBPL2ORK9O89C4K3RHGve/lvFaU1vIjSDnj6+bj4=";
unifiedpush_platform_interface = "sha256-aIF/8oabSuuZo7K6qr4r7UBmf57qgoGAXyJ40fdntuQ="; unifiedpush_platform_interface = "sha256-KQKyBPL2ORK9O89C4K3RHGve/lvFaU1vIjSDnj6+bj4=";
webcrypto = "sha256-HW0NukbddwOYd9iVUFA3L8iy1qggnyOBgcbMj0MTYss="; webcrypto = "sha256-HW0NukbddwOYd9iVUFA3L8iy1qggnyOBgcbMj0MTYss=";
window_manager = "sha256-xUd5hG+/V6F+m0ZUL/3XGPACFG/zqI5JM6IaMVvLgx4=";
xdg_desktop_portal = "sha256-8GgiXHGv+wy6hJgj/rZxbymMitNVmdDLAnedZm9STSc="; xdg_desktop_portal = "sha256-8GgiXHGv+wy6hJgj/rZxbymMitNVmdDLAnedZm9STSc=";
}; };

View file

@ -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"
'';
}

View file

@ -155,11 +155,6 @@ static void my_application_activate(
} }
#endif #endif
gtk_widget_set_size_request(
GTK_WIDGET(window),
250,
-1);
if (use_header_bar) { if (use_header_bar) {
GtkHeaderBar* header_bar = GtkHeaderBar* header_bar =
GTK_HEADER_BAR( GTK_HEADER_BAR(

View file

@ -13,11 +13,9 @@ import media_kit_libs_macos_video
import media_kit_video import media_kit_video
import package_info_plus import package_info_plus
import pasteboard import pasteboard
import screen_retriever_macos
import shared_preferences_foundation import shared_preferences_foundation
import url_launcher_macos import url_launcher_macos
import wakelock_plus import wakelock_plus
import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
@ -28,9 +26,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin")) MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
} }

View file

@ -217,6 +217,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.3" version: "1.1.3"
cnativeapi:
dependency: transitive
description:
name: cnativeapi
sha256: "251fb93cd7ec205445fa512ee5ddeb0b82b3273d071cfc0784ddffbbdebbf5d3"
url: "https://pub.dev"
source: hosted
version: "0.5.2"
code_assets: code_assets:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1041,6 +1049,22 @@ packages:
url: "https://github.com/Henry-Hiles/native_toolchain_cmake" url: "https://github.com/Henry-Hiles/native_toolchain_cmake"
source: git source: git
version: "0.3.2" 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: navigation_rail_m3e:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1282,46 +1306,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.6" 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: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1539,8 +1523,8 @@ packages:
dependency: "direct overridden" dependency: "direct overridden"
description: description:
path: unifiedpush_linux path: unifiedpush_linux
ref: "quad/feat/should-write-service-option" ref: "quad/nexus"
resolved-ref: "7589b07ef4280820e4adea165d3d86b219f6022c" resolved-ref: "5b31fabcc260c2ff07c4499099ae20591e2c2cb9"
url: "https://codeberg.org/Henry-Hiles/flutter-connector" url: "https://codeberg.org/Henry-Hiles/flutter-connector"
source: git source: git
version: "1.0.1" version: "1.0.1"
@ -1548,8 +1532,8 @@ packages:
dependency: "direct overridden" dependency: "direct overridden"
description: description:
path: unifiedpush_platform_interface path: unifiedpush_platform_interface
ref: "quad/feat/should-write-service-option" ref: "quad/nexus"
resolved-ref: "7589b07ef4280820e4adea165d3d86b219f6022c" resolved-ref: "5b31fabcc260c2ff07c4499099ae20591e2c2cb9"
url: "https://codeberg.org/Henry-Hiles/flutter-connector" url: "https://codeberg.org/Henry-Hiles/flutter-connector"
source: git source: git
version: "4.0.0" version: "4.0.0"
@ -1773,11 +1757,12 @@ packages:
window_manager: window_manager:
dependency: "direct main" dependency: "direct main"
description: description:
name: window_manager path: "."
sha256: "05c231fd7b23d2380f14c5cc10b7b93d60d4fa4a2fb4e0f032de27e44b5560e9" ref: HEAD
url: "https://pub.dev" resolved-ref: "80acd536a1ea1c121c36e32d30e638a295087ed1"
source: hosted url: "https://github.com/leanflutter/window_manager"
version: "0.5.2" source: git
version: "0.6.0"
xdg_desktop_portal: xdg_desktop_portal:
dependency: "direct main" dependency: "direct main"
description: description:

View file

@ -41,17 +41,20 @@ dependency_overrides:
unifiedpush_linux: unifiedpush_linux:
git: git:
url: https://codeberg.org/Henry-Hiles/flutter-connector url: https://codeberg.org/Henry-Hiles/flutter-connector
ref: quad/feat/should-write-service-option ref: quad/nexus
path: unifiedpush_linux path: unifiedpush_linux
unifiedpush_platform_interface: unifiedpush_platform_interface:
git: git:
url: https://codeberg.org/Henry-Hiles/flutter-connector url: https://codeberg.org/Henry-Hiles/flutter-connector
ref: quad/feat/should-write-service-option ref: quad/nexus
path: unifiedpush_platform_interface path: unifiedpush_platform_interface
linkify: linkify:
git: git:
url: https://github.com/appelladev/linkify url: https://github.com/appelladev/linkify
ref: fix/consecutive-periods-loose-url ref: fix/consecutive-periods-loose-url
window_manager:
git:
url: https://github.com/leanflutter/window_manager
dependencies: dependencies:
flutter: flutter:

View file

@ -12,9 +12,7 @@
#include <media_kit_libs_windows_video/media_kit_libs_windows_video_plugin_c_api.h> #include <media_kit_libs_windows_video/media_kit_libs_windows_video_plugin_c_api.h>
#include <media_kit_video/media_kit_video_plugin_c_api.h> #include <media_kit_video/media_kit_video_plugin_c_api.h>
#include <pasteboard/pasteboard_plugin.h> #include <pasteboard/pasteboard_plugin.h>
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
#include <window_manager/window_manager_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
AppLinksPluginCApiRegisterWithRegistrar( AppLinksPluginCApiRegisterWithRegistrar(
@ -29,10 +27,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi")); registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi"));
PasteboardPluginRegisterWithRegistrar( PasteboardPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PasteboardPlugin")); registry->GetRegistrarForPlugin("PasteboardPlugin"));
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar( UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows")); registry->GetRegistrarForPlugin("UrlLauncherWindows"));
WindowManagerPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
} }

View file

@ -9,9 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
media_kit_libs_windows_video media_kit_libs_windows_video
media_kit_video media_kit_video
pasteboard pasteboard
screen_retriever_windows
url_launcher_windows url_launcher_windows
window_manager
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST