native_core 1.0.1
native_core: ^1.0.1 copied to clipboard
Zero-dependency desktop window, display, and single-instance lifecycle primitives for Flutter across Linux, macOS, and Windows.
1.0.1 #
OS-isolated window lifecycle, macOS Dock/close-button responsiveness, and Linux Wayland presentation & GDK3 pointer event fixes (with zero modifications to the Windows adapter).
macOS (platform/macos/) #
- Immediate Close-to-Tray Response on Traffic-Light
[X]Click: Wake Flutter's macOSCFRunLoop/ Dart microtask queue (Timer.run+ensureVisualUpdate/scheduleFrame) immediately insideNativeCoreWindowDelegate.windowShouldClose:when a close request is cancelled, so hiding the window no longer waits for the pointer to leave AppKit's red close button. - Automatic Dock Running Indicator Policy (
Regular↔Accessory): WhenMacOSWindowAdapter.hide()hides the last visible app window while an activeNSStatusItem(NSStatusBarWindowwithisVisible == true) is present, automatically switchNSApplicationtoAccessory (1)so the Dock dot disappears while the menu bar icon stays alive; restoreRegular (0)before activation onshow(),focus(), or native reopen (NSWindowDidBecomeKeyNotification). - Clean Dock Quit /
Cmd+QTermination: Stop forwardingWidgetsBindingObserver.didRequestAppExittoWindowCloseRequestedEventon macOS and Linux (preserving WindowsWM_CLOSEforwarding intact), and automatically release single-instance Unix sockets viaNSApplicationWillTerminateNotification(MacOSAppLifecycleObserver) andApplication.quit().
Linux (platform/linux/) #
- Wayland Unmapped Presentation & Mutter
"<App>" is readyFix: Remove rawgdk_window_showandgdk_window_focuscalls fromLinuxWindowAdapter._presentWindow, and resolve X11 vs Wayland presentation viaresolveLinuxPresentActionso unmapped Wayland startup/restore usesgtk_window_deiconify+gtk_widget_showwithout firing prematuregtk_window_present_with_time(0). - GTK3 Pre-Map Geometry, Native Centering, Maximized State, and Close Wakeup: Apply
gtk_window_set_default_size+gdk_window_resizebefore map insetSize()/bounds =, delegateWindow.center()togtk_window_set_position(GTK_WIN_POS_CENTER), checkGDK_WINDOW_STATE_MAXIMIZEDalongsidegtk_window_is_maximized, and wake Flutter's event loop whendelete-eventcancels close. - Synthesized
GDK_BUTTON_RELEASEPointer Device Binding: Bindgdk_event_set_deviceandgdk_event_get_devicefromlibgdk-3.so.0and attach the defaultGdkSeatpointer device insidereleaseLinuxMouseButtonAfterGrabbefore dispatchinggtk_widget_event, eliminatingGdk-CRITICAL: gdk_device_get_axis: assertion 'GDK_IS_DEVICE (device)' failedwarnings after interactive caption-bar window dragging on Wayland and X11.
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