native_core 1.0.0
native_core: ^1.0.0 copied to clipboard
Zero-dependency desktop window, display, and single-instance lifecycle primitives for Flutter across Linux, macOS, and Windows.
1.0.0 #
Initial stable release of native_core — a unified, zero-dependency desktop window, display, and single-instance application lifecycle package for Flutter across Linux (GTK3 / GDK3 on Wayland & X11), macOS (AppKit 13.0+), and Windows (Win32).
Architecture & Platform Highlights #
- Zero External Dependencies: Depends solely on the Flutter SDK (
flutter), isolating each desktop OS inside dedicatedWindowPlatformAdapterandDisplayPlatformAdapterimplementations (platform/linux/,platform/macos/,platform/windows/) with one-time cached FFI symbol and Objective-C selector tables plus optionalNativeCoreDiagnostics.onErrorreporting. - Configurable Single-Instance Coordination (
Application.instance.ensureSingleInstance):- Supports
InstanceMode.singleInstance(default) andInstanceMode.multiInstance, forwarding CLI arguments and working directory viaSecondInstancePayload. - Windows: Uses a session-scoped Named Mutex (
CreateMutexW+WaitForSingleObject(0)for atomic crash recovery viaWAIT_ABANDONED),AllowSetForegroundWindowforeground-lock handoff, and a Hot Restart-safeWM_COPYDATAIPC host window. - Linux & macOS: Uses a user-scoped Unix Domain Socket constrained below the 104-byte
sockaddr_un.sun_pathlimit with automaticSIGKILLstale-socket recovery and client inactivity timeout protection.
- Supports
- Linux (
libgtk-3.so.0,libgdk-3.so.0,libgobject-2.0.so.0,libgio-2.0.so.0):- Filters
gtk_window_list_toplevels()strictly for liveGTK_WINDOW_TOPLEVEL(0) windows (selectPrimaryLinuxToplevel), skippingGTK_WINDOW_POPUP(1) tooltips and menus. - Tracks
delete-eventanddestroyGObject signal handler IDs (LinuxSignalLifecycle), disconnecting active handlers viag_signal_handler_disconnectstrictly before closingNativeCallabletrampolines (including partial attach rollback). - Restores hidden/minimized windows via
gtk_widget_show+gtk_window_deiconify+gtk_window_present_with_time(with X11gdk_x11_get_server_timeresolution), hidesGtkHeaderBardirectly (hideLinuxNativeTitleBar), and synthesizesGDK_BUTTON_RELEASEafter native grabs.
- Filters
- macOS (
/usr/lib/libobjc.A.dylib,AppKit,CoreGraphics):- Universal Binary (
arm64/x86_64objc_msgSend_stret) window andNSScreengeometry with Cocoa bottom-left to desktop top-left coordinate normalization. - Resolves hidden (
orderOut:) primary windows viaNSApplication.windowsfallback, activates apps across macOS 13 Ventura through macOS 27+ via bothactivateandactivateIgnoringOtherApps:, enablesNSWindowStyleMaskFullSizeContentView(1 << 15), and interceptswindowShouldClose:/windowDidMove:withclass_replaceMethodHot Restart safety.
- Universal Binary (
- Windows (
user32.dll,comctl32.dll,dwmapi.dll,gdi32.dll,shcore.dll,kernel32.dll):- Self-contained
SetWindowSubclasscustom frameless mode (WM_NCCALCSIZEmaximizedrcWorkclamping, DWM shadow & rounded corners, 8-directionWM_NCHITTESTresize preserving Fitts's Law maximized top-right clicks,WM_GETMINMAXINFOminimumSize,WM_ERASEBKGNDWHITE_BRUSHflash suppression without live DXGI resize strobe flicker,WM_WINDOWPOSCHANGINGfirst-frame coordination with stockflutter_window.cpp, and pre-DefSubclassProcWM_DESTROYteardown). - Enumerates physical monitors with per-monitor work areas and DPI
scaleFactorviaEnumDisplayMonitors+GetMonitorInfoW+GetDpiForMonitor(with scopedNativeCallableteardown), and bypasses Foreground Lock on tray restore viaAttachThreadInputand safe Z-order lift fallback.
- Self-contained