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 ||
(!isInBackground &&
await windowManager.isFocused().onError((_, _) => true) &&
(WindowManager.instance.getCurrent()?.isFocused ?? true) &&
ref.read(SelectedRoomController.provider) ==
notification.roomId)) {
if (isInBackground) exit(0);

View file

@ -83,14 +83,10 @@ void main(List<String> 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(

View file

@ -23,14 +23,15 @@ final class const Appbar({
@override
Widget build(BuildContext context, WidgetRef ref) {
Future<void> 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)

View file

@ -12,9 +12,7 @@
#include <media_kit_libs_linux/media_kit_libs_linux_plugin.h>
#include <media_kit_video/media_kit_video_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 <window_manager/window_manager_plugin.h>
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);
}

View file

@ -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

View file

@ -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 ];

View file

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

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
gtk_widget_set_size_request(
GTK_WIDGET(window),
250,
-1);
if (use_header_bar) {
GtkHeaderBar* header_bar =
GTK_HEADER_BAR(

View file

@ -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"))
}

View file

@ -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:

View file

@ -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:

View file

@ -12,9 +12,7 @@
#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 <pasteboard/pasteboard_plugin.h>
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h>
#include <window_manager/window_manager_plugin.h>
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"));
}

View file

@ -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