Skip to content

Commit

Permalink
[windows] Returns the correct width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed May 29, 2022
1 parent ca76336 commit 1027a8a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
8 changes: 8 additions & 0 deletions example/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
screen_retriever
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -15,3 +18,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
18 changes: 9 additions & 9 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
crypto:
dependency: transitive
description:
Expand All @@ -70,7 +70,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -99,7 +99,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
version: "0.6.4"
matcher:
dependency: transitive
description:
Expand All @@ -113,7 +113,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -127,7 +127,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
preference_list:
dependency: "direct main"
description:
Expand All @@ -153,7 +153,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -188,7 +188,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
version: "0.4.9"
typed_data:
dependency: transitive
description:
Expand All @@ -209,7 +209,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.20.0"
8 changes: 8 additions & 0 deletions example/windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
screen_retriever
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -15,3 +18,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
18 changes: 10 additions & 8 deletions windows/screen_retriever_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,22 @@ flutter::EncodableMap MonitorToEncodableMap(HMONITOR monitor) {

double scale_factor = dpi / kBaseDpi;

double visibleWidth = (info.rcWork.right - info.rcWork.left);
double visibleHeight = (info.rcWork.bottom - info.rcWork.top);
double visibleWidth =
round((info.rcWork.right - info.rcWork.left) / scale_factor);
double visibleHeight =
round((info.rcWork.bottom - info.rcWork.top) / scale_factor);

double visibleX = (info.rcWork.left);
double visibleY = (info.rcWork.top);
double visibleX = round((info.rcWork.left) / scale_factor);
double visibleY = round((info.rcWork.top) / scale_factor);

flutter::EncodableMap size = flutter::EncodableMap();
flutter::EncodableMap visibleSize = flutter::EncodableMap();
flutter::EncodableMap visiblePosition = flutter::EncodableMap();

size[flutter::EncodableValue("width")] =
flutter::EncodableValue(static_cast<double>(info.rcMonitor.right));
size[flutter::EncodableValue("height")] =
flutter::EncodableValue(static_cast<double>(info.rcMonitor.bottom));
size[flutter::EncodableValue("width")] = flutter::EncodableValue(
static_cast<double>(round(info.rcMonitor.right / scale_factor)));
size[flutter::EncodableValue("height")] = flutter::EncodableValue(
static_cast<double>(round(info.rcMonitor.bottom / scale_factor)));

visibleSize[flutter::EncodableValue("width")] =
flutter::EncodableValue(visibleWidth);
Expand Down

0 comments on commit 1027a8a

Please sign in to comment.