mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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.
33 lines
856 B
C++
33 lines
856 B
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.
|
|
|
|
#include "flutter/shell/common/display_manager.h"
|
|
|
|
#include "flutter/fml/logging.h"
|
|
#include "flutter/fml/macros.h"
|
|
|
|
namespace flutter {
|
|
|
|
DisplayManager::DisplayManager() = default;
|
|
|
|
DisplayManager::~DisplayManager() = default;
|
|
|
|
double DisplayManager::GetMainDisplayRefreshRate() const {
|
|
std::scoped_lock lock(displays_mutex_);
|
|
if (displays_.empty()) {
|
|
return kUnknownDisplayRefreshRate;
|
|
} else {
|
|
return displays_[0]->GetRefreshRate();
|
|
}
|
|
}
|
|
|
|
void DisplayManager::HandleDisplayUpdates(
|
|
std::vector<std::unique_ptr<Display>> displays) {
|
|
FML_DCHECK(!displays.empty());
|
|
std::scoped_lock lock(displays_mutex_);
|
|
displays_ = std::move(displays);
|
|
}
|
|
|
|
} // namespace flutter
|