Dan Field ea5131772d Add a Display API to dart:ui that reports the physical size, DPR, and refresh rate of the main display (flutter/engine#41685)
Fixes https://github.com/flutter/flutter/issues/123307 - for Android, iOS, and Web, for the main display only (https://github.com/flutter/flutter/issues/125938 tracks supporting multiple displays, https://github.com/flutter/flutter/issues/125939 for desktop).

Desktop will need to be implemented for this, but given priority for a couple of our customers targetting foldable devices on Android I'm inclined to get this in before desktop can be finished.

The main concern for this right now is that on some Android foldable devices, setting a preferred orientation will cause letterboxing and the `MediaQuery` will _never_ get the full screen size when unfolded. This causes apps to think the screen is smaller than it is, as they've mainly been using `MediaQueryData.size` to figure this out. Android's recommendation is to not set a preferred orientation, and if you must to use the new method introduced in `ViewUtil.java` to calculate the maximal window size.
2023-05-06 18:28:22 +00:00

52 lines
1.5 KiB
C++

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_RUNTIME_PLATFORM_DATA_H_
#define FLUTTER_RUNTIME_PLATFORM_DATA_H_
#include <memory>
#include <string>
#include <vector>
#include "flutter/lib/ui/window/viewport_metrics.h"
#include "flutter/shell/common/display.h"
namespace flutter {
//------------------------------------------------------------------------------
/// The struct of platform-specific data used for initializing
/// ui.PlatformDispatcher.
///
/// The framework may request data from ui.PlatformDispatcher before the
/// platform is properly configured. When creating the Shell, the engine sets
/// this struct to default values until the platform is ready to send the real
/// data.
///
/// See also:
///
/// * flutter::Shell::Create, which takes a platform_data to initialize the
/// ui.PlatformDispatcher attached to it.
struct PlatformData {
PlatformData();
~PlatformData();
ViewportMetrics viewport_metrics;
std::string language_code;
std::string country_code;
std::string script_code;
std::string variant_code;
std::vector<std::string> locale_data;
std::string user_settings_data = "{}";
std::string lifecycle_state;
bool semantics_enabled = false;
bool assistive_technology_enabled = false;
int32_t accessibility_feature_flags_ = 0;
std::vector<DisplayData> displays;
};
} // namespace flutter
#endif // FLUTTER_RUNTIME_PLATFORM_DATA_H_