Skip to content

Commit

Permalink
chore: Get the correct screen ID on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Aug 18, 2024
1 parent 47ca9a0 commit 27e917a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Display {
_$DisplayFromJson(json);

/// Unique identifier associated with the display.
final num id;
final String id;

/// The name of the display.
final String? name;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,22 @@ flutter::EncodableMap MonitorToEncodableMap(HMONITOR monitor) {

flutter::EncodableMap display = flutter::EncodableMap();

display[flutter::EncodableValue("id")] = flutter::EncodableValue(0);
display[flutter::EncodableValue("id")] = flutter::EncodableValue("");
DISPLAY_DEVICE displayDevice;
displayDevice.cb = sizeof(DISPLAY_DEVICE);
int deviceIndex = 0;
while (EnumDisplayDevices(info.szDevice, deviceIndex, &displayDevice, 0)) {
if (displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE &&
(displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
std::wstring deviceName(displayDevice.DeviceName);
if (deviceName.find(info.szDevice) == 0) {
display[flutter::EncodableValue("id")] = flutter::EncodableValue(
converter.to_bytes(displayDevice.DeviceID).c_str());
}
}
deviceIndex++;
}

display[flutter::EncodableValue("name")] =
flutter::EncodableValue(converter.to_bytes(display_name).c_str());
display[flutter::EncodableValue("size")] = flutter::EncodableValue(size);
Expand Down

0 comments on commit 27e917a

Please sign in to comment.