From 358bc8dfa9f560ba652fb022956e1c580968c76b Mon Sep 17 00:00:00 2001 From: Ali-Fadaei Date: Wed, 17 Jun 2026 09:42:02 +0330 Subject: [PATCH 1/2] win32 migrated to 6.3.0 --- .../example/windows/flutter/CMakeLists.txt | 7 ++- .../example/windows/runner/Runner.rc | 10 ++--- bitsdojo_window/pubspec.yaml | 6 +-- bitsdojo_window_windows/lib/src/window.dart | 45 +++++++++++-------- .../lib/src/window_util.dart | 11 +++-- bitsdojo_window_windows/pubspec.yaml | 2 +- 6 files changed, 49 insertions(+), 32 deletions(-) diff --git a/bitsdojo_window/example/windows/flutter/CMakeLists.txt b/bitsdojo_window/example/windows/flutter/CMakeLists.txt index b02c548..86edc67 100644 --- a/bitsdojo_window/example/windows/flutter/CMakeLists.txt +++ b/bitsdojo_window/example/windows/flutter/CMakeLists.txt @@ -9,6 +9,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake) # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") @@ -91,7 +96,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" - windows-x64 $ + ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS diff --git a/bitsdojo_window/example/windows/runner/Runner.rc b/bitsdojo_window/example/windows/runner/Runner.rc index 000b24c..7db7535 100644 --- a/bitsdojo_window/example/windows/runner/Runner.rc +++ b/bitsdojo_window/example/windows/runner/Runner.rc @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" // Version // -#ifdef FLUTTER_BUILD_NUMBER -#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD #else -#define VERSION_AS_NUMBER 1,0,0 +#define VERSION_AS_NUMBER 1,0,0,0 #endif -#ifdef FLUTTER_BUILD_NAME -#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION #else #define VERSION_AS_STRING "1.0.0" #endif diff --git a/bitsdojo_window/pubspec.yaml b/bitsdojo_window/pubspec.yaml index 656675f..cd58ff2 100644 --- a/bitsdojo_window/pubspec.yaml +++ b/bitsdojo_window/pubspec.yaml @@ -25,11 +25,11 @@ dependencies: ^0.1.2 #path: ../bitsdojo_window_platform_interface bitsdojo_window_windows: - ^0.1.6 - #path: ../bitsdojo_window_windows + # ^0.1.6 + path: ../bitsdojo_window_windows bitsdojo_window_macos: ^0.1.4 #path: ../bitsdojo_window_macos bitsdojo_window_linux: ^0.1.4 - #path: ../bitsdojo_window_linux + #path: ../bitsdojo_window_linux \ No newline at end of file diff --git a/bitsdojo_window_windows/lib/src/window.dart b/bitsdojo_window_windows/lib/src/window.dart index cdec859..84af6f1 100644 --- a/bitsdojo_window_windows/lib/src/window.dart +++ b/bitsdojo_window_windows/lib/src/window.dart @@ -21,10 +21,11 @@ bool isValidHandle(int? handle, String operation) { } Rect getScreenRectForWindow(int handle) { - int monitor = MonitorFromWindow(handle, MONITOR_DEFAULTTONEAREST); + final monitor = + MonitorFromWindow(hWndFromInt(handle), MONITOR_DEFAULTTONEAREST); final monitorInfo = calloc()..ref.cbSize = sizeOf(); final result = GetMonitorInfo(monitor, monitorInfo); - if (result == TRUE) { + if (result) { return Rect.fromLTRB( monitorInfo.ref.rcWork.left.toDouble(), monitorInfo.ref.rcWork.top.toDouble(), @@ -55,7 +56,7 @@ class WinWindow extends WinDesktopWindow { Rect get rect { if (!isValidHandle(handle, "get rectangle")) return Rect.zero; final winRect = calloc(); - GetWindowRect(handle!, winRect); + GetWindowRect(hWndFromInt(handle!), winRect); Rect result = winRect.ref.toRect; calloc.free(winRect); return result; @@ -87,8 +88,10 @@ class WinWindow extends WinDesktopWindow { double systemMetric(int metric, {int dpiToUse = 0}) { final windowDpi = dpiToUse != 0 ? dpiToUse : this.dpi; double result = dpiAware - ? GetSystemMetricsForDpi(metric, windowDpi).toDouble() - : GetSystemMetrics(metric).toDouble(); + ? GetSystemMetricsForDpi(SYSTEM_METRICS_INDEX(metric), windowDpi) + .value + .toDouble() + : GetSystemMetrics(SYSTEM_METRICS_INDEX(metric)).toDouble(); return result; } @@ -98,7 +101,7 @@ class WinWindow extends WinDesktopWindow { int get dpi { if (!dpiAware || !isValidHandle(handle, "get dpi")) return 96; - return GetDpiForWindow(handle!); + return GetDpiForWindow(hWndFromInt(handle!)); } double get scaleFactor { @@ -201,8 +204,8 @@ class WinWindow extends WinDesktopWindow { Size sizeToSet = Size(width, height); _sizeSetFromDart = sizeToSet; if (_alignment == null) { - SetWindowPos(handle!, 0, 0, 0, sizeToSet.width.toInt(), - sizeToSet.height.toInt(), SWP_NOMOVE); + SetWindowPos(hWndFromInt(handle!), null, 0, 0, + sizeToSet.width.toInt(), sizeToSet.height.toInt(), SWP_NOMOVE); } else { final sizeOnScreen = getSizeOnScreen((sizeToSet)); final screenRect = getScreenRectForWindow(handle!); @@ -212,7 +215,7 @@ class WinWindow extends WinDesktopWindow { bool get isMaximized { if (!isValidHandle(handle, "get isMaximized")) return false; - return (IsZoomed(handle!) == 1); + return IsZoomed(hWndFromInt(handle!)); } @Deprecated("use isVisible instead") @@ -221,7 +224,7 @@ class WinWindow extends WinDesktopWindow { } bool get isVisible { - return (IsWindowVisible(handle!) == 1); + return IsWindowVisible(hWndFromInt(handle!)); } Offset get position { @@ -231,8 +234,8 @@ class WinWindow extends WinDesktopWindow { set position(Offset newPosition) { if (!isValidHandle(handle, "set position")) return; - SetWindowPos(handle!, 0, newPosition.dx.toInt(), newPosition.dy.toInt(), 0, - 0, SWP_NOSIZE); + SetWindowPos(hWndFromInt(handle!), null, newPosition.dx.toInt(), + newPosition.dy.toInt(), 0, 0, SWP_NOSIZE); } void show() { @@ -244,8 +247,8 @@ class WinWindow extends WinDesktopWindow { void hide() { if (!isValidHandle(handle, "hide")) return; - SetWindowPos( - handle!, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW); + SetWindowPos(hWndFromInt(handle!), null, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW); } @Deprecated("use show()/hide() instead") @@ -259,28 +262,32 @@ class WinWindow extends WinDesktopWindow { void close() { if (!isValidHandle(handle, "close")) return; - PostMessage(handle!, WM_SYSCOMMAND, SC_CLOSE, 0); + PostMessage( + hWndFromInt(handle!), WM_SYSCOMMAND, WPARAM(SC_CLOSE), LPARAM(0)); } void maximize() { if (!isValidHandle(handle, "maximize")) return; - PostMessage(handle!, WM_SYSCOMMAND, SC_MAXIMIZE, 0); + PostMessage( + hWndFromInt(handle!), WM_SYSCOMMAND, WPARAM(SC_MAXIMIZE), LPARAM(0)); } void minimize() { if (!isValidHandle(handle, "minimize")) return; - PostMessage(handle!, WM_SYSCOMMAND, SC_MINIMIZE, 0); + PostMessage( + hWndFromInt(handle!), WM_SYSCOMMAND, WPARAM(SC_MINIMIZE), LPARAM(0)); } void restore() { if (!isValidHandle(handle, "restore")) return; - PostMessage(handle!, WM_SYSCOMMAND, SC_RESTORE, 0); + PostMessage( + hWndFromInt(handle!), WM_SYSCOMMAND, WPARAM(SC_RESTORE), LPARAM(0)); } void maximizeOrRestore() { if (!isValidHandle(handle, "maximizeOrRestore")) return; - if (IsZoomed(handle!) == 1) { + if (IsZoomed(hWndFromInt(handle!))) { this.restore(); } else { this.maximize(); diff --git a/bitsdojo_window_windows/lib/src/window_util.dart b/bitsdojo_window_windows/lib/src/window_util.dart index 569da89..35629a4 100644 --- a/bitsdojo_window_windows/lib/src/window_util.dart +++ b/bitsdojo_window_windows/lib/src/window_util.dart @@ -8,6 +8,8 @@ const BDW_SETWINDOWPOS = 1; const BDW_SETWINDOWTEXT = 2; const BDW_FORCECHILDREFRESH = 3; +HWND hWndFromInt(int hWnd) => HWND(Pointer.fromAddress(hWnd)); + class SWPParam extends Struct { @Int32() external int x, y, cx, cy, uFlags; @@ -22,7 +24,8 @@ void setWindowPos( ..cx = cx ..cy = cy ..uFlags = uFlags; - PostMessage(hWnd, WM_BDW_ACTION, BDW_SETWINDOWPOS, param.address); + PostMessage(hWndFromInt(hWnd), WM_BDW_ACTION, WPARAM(BDW_SETWINDOWPOS), + LPARAM(param.address)); } class SWTParam extends Struct { @@ -32,9 +35,11 @@ class SWTParam extends Struct { void setWindowText(int hWnd, String text) { final param = calloc(); param.ref.text = text.toNativeUtf16(); - PostMessage(hWnd, WM_BDW_ACTION, BDW_SETWINDOWTEXT, param.address); + PostMessage(hWndFromInt(hWnd), WM_BDW_ACTION, WPARAM(BDW_SETWINDOWTEXT), + LPARAM(param.address)); } void forceChildRefresh(int hWnd) { - PostMessage(hWnd, WM_BDW_ACTION, BDW_FORCECHILDREFRESH, 0); + PostMessage(hWndFromInt(hWnd), WM_BDW_ACTION, WPARAM(BDW_FORCECHILDREFRESH), + LPARAM(0)); } diff --git a/bitsdojo_window_windows/pubspec.yaml b/bitsdojo_window_windows/pubspec.yaml index e1e525d..433b73f 100644 --- a/bitsdojo_window_windows/pubspec.yaml +++ b/bitsdojo_window_windows/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: bitsdojo_window_platform_interface: ^0.1.2 #path: ../bitsdojo_window_platform_interface - win32: ^5.1.1 + win32: ^6.3.0 ffi: ^2.0.0 dev_dependencies: From 52b09676b15cf0b69c26d96dade558d3cbf363fe Mon Sep 17 00:00:00 2001 From: Ali-Fadaei Date: Wed, 17 Jun 2026 09:57:33 +0330 Subject: [PATCH 2/2] build_test depricated upload-artifact action bumped to v4 --- .github/workflows/build_test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml index 4a8e7d2..e6fc021 100644 --- a/.github/workflows/build_test.yaml +++ b/.github/workflows/build_test.yaml @@ -77,21 +77,21 @@ jobs: - name: Archive artifacts (Linux) if: matrix.runner == 'ubuntu' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bitsdojo_window_example_${{ matrix.runner }} path: bitsdojo_window/example/build/linux/x64/release/bundle/ - name: Archive artifacts (Windows) if: matrix.runner == 'windows' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bitsdojo_window_example_${{ matrix.runner }} path: bitsdojo_window/example/build/windows/runner/Release/bitsdojo_window_example.exe - name: Archive artifacts (macOS) if: matrix.runner == 'macos' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bitsdojo_window_example_${{ matrix.runner }} path: bitsdojo_window/example/build/macos/Build/Products/Release/bitsdojo_window_example.app