mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
fix some problems
Signed-off-by: xpeng <pengxin33@huawei.com> Change-Id: Ib12e476f8a7ad8ec86df0f1b591ab5edd93dc253
This commit is contained in:
@@ -48,13 +48,14 @@ public:
|
||||
void SetCurvedScreenBoundary(std::vector<int> curvedScreenBoundary);
|
||||
private:
|
||||
Rect CalcCutoutBoundingRect(std::string svgPath);
|
||||
void CheckBoudingRectBoundary(DisplayId displayId, Rect& boundingRect);
|
||||
void CalcBuiltInDisplayWaterfallRects();
|
||||
void CalcBuiltInDisplayWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight, uint32_t displayWidth);
|
||||
void TransferBoundingRectsByRotation(DisplayId displayId, std::vector<Rect>& boudingRects);
|
||||
|
||||
// Raw data
|
||||
std::map<DisplayId, std::vector<std::string>> svgPaths_;
|
||||
bool isWaterfallDisplay_ = true;
|
||||
bool isWaterfallDisplay_ = false;
|
||||
std::vector<int> curvedScreenBoundary_; // Order: left top right bottom
|
||||
bool isWaterfallAreaLayoutEnable_ = true;
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ void DisplayCutoutController::SetIsWaterfallDisplay(bool isWaterfallDisplay)
|
||||
|
||||
void DisplayCutoutController::SetCurvedScreenBoundary(std::vector<int> curvedScreenBoundary)
|
||||
{
|
||||
while (curvedScreenBoundary.size() < 4) { // 4 directions.
|
||||
curvedScreenBoundary.emplace_back(0);
|
||||
}
|
||||
WLOGFI("Set curvedScreenBoundary");
|
||||
curvedScreenBoundary_ = curvedScreenBoundary;
|
||||
}
|
||||
@@ -57,6 +60,7 @@ void DisplayCutoutController::SetCutoutSvgPath(DisplayId displayId, const std::s
|
||||
svgPaths_[displayId] = pathVec;
|
||||
}
|
||||
Rect boundingRect = CalcCutoutBoundingRect(svgPath);
|
||||
CheckBoudingRectBoundary(displayId, boundingRect);
|
||||
if (boundingRects_.count(displayId) == 1) {
|
||||
boundingRects_[displayId].emplace_back(boundingRect);
|
||||
} else {
|
||||
@@ -82,6 +86,25 @@ sptr<CutoutInfo> DisplayCutoutController::GetCutoutInfo(DisplayId displayId)
|
||||
return cutoutInfo;
|
||||
}
|
||||
|
||||
void DisplayCutoutController::CheckBoudingRectBoundary(DisplayId displayId, Rect& boundingRect)
|
||||
{
|
||||
sptr<SupportedScreenModes> modes =
|
||||
DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId(displayId);
|
||||
if (modes == nullptr) {
|
||||
WLOGFE("DisplayId is invalid");
|
||||
return;
|
||||
}
|
||||
uint32_t displayHeight = modes->height_;
|
||||
uint32_t displayWidth = modes->width_;
|
||||
if (boundingRect.posX_ < 0 || boundingRect.posY_ < 0 ||
|
||||
boundingRect.width_ + boundingRect.posX_ > displayWidth ||
|
||||
boundingRect.height_ + boundingRect.posY_ > displayHeight) {
|
||||
WLOGFE("boundingRect boundary is invalid");
|
||||
boundingRect = {.posX_ = 0, .posY_ = 0, .width_ = 0, .height_ = 0};
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Rect DisplayCutoutController::CalcCutoutBoundingRect(std::string svgPath)
|
||||
{
|
||||
Rect emptyRect = {0, 0, 0, 0};
|
||||
@@ -125,7 +148,10 @@ void DisplayCutoutController::CalcBuiltInDisplayWaterfallRects()
|
||||
uint32_t top = curvedScreenBoundary_[1];
|
||||
uint32_t right = curvedScreenBoundary_[2];
|
||||
uint32_t bottom = curvedScreenBoundary_[3];
|
||||
|
||||
if (left == 0 && top == 0 && right == 0 && bottom == 0) {
|
||||
waterfallDisplayAreaRects_ = emptyRects;
|
||||
return;
|
||||
}
|
||||
sptr<SupportedScreenModes> modes =
|
||||
DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId(
|
||||
DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId());
|
||||
|
||||
@@ -165,7 +165,7 @@ void DisplayManagerConfig::ReadEnableConfigInfo(const xmlNodePtr& currNode)
|
||||
std::string nodeName = reinterpret_cast<const char *>(currNode->name);
|
||||
if (!xmlStrcmp(enable, reinterpret_cast<const xmlChar*>("true"))) {
|
||||
enableConfig_[nodeName] = true;
|
||||
} else if (!xmlStrcmp(enable, reinterpret_cast<const xmlChar*>("false"))) {
|
||||
} else {
|
||||
enableConfig_[nodeName] = false;
|
||||
}
|
||||
xmlFree(enable);
|
||||
|
||||
+35
-25
@@ -103,6 +103,40 @@ declare namespace display {
|
||||
STATE_ON_SUSPEND,
|
||||
}
|
||||
|
||||
/**
|
||||
* Rectangle
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 7
|
||||
*/
|
||||
interface Rect {
|
||||
left: number;
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Curved area rects of the waterfall display.
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 9
|
||||
*/
|
||||
interface WaterfallDisplayAreaRects {
|
||||
readonly left: Rect;
|
||||
readonly right: Rect;
|
||||
readonly top: Rect;
|
||||
readonly bottom: Rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* cutout information of the display.
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 9
|
||||
*/
|
||||
interface CutoutInfo {
|
||||
readonly boundingRects: Array<Rect>;
|
||||
readonly waterfallDisplayAreaRects: WaterfallDisplayAreaRects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines properties of the display. They cannot be updated automatically.
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
@@ -178,7 +212,7 @@ declare namespace display {
|
||||
* Obtain the cutout info of the display.
|
||||
* @devices tv, phone, tablet, wearable
|
||||
*/
|
||||
getCutoutInfo(callback: AsyncCallback<void>): void;
|
||||
getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void;
|
||||
|
||||
/**
|
||||
* Obtain the cutout info of the display.
|
||||
@@ -186,30 +220,6 @@ declare namespace display {
|
||||
*/
|
||||
getCutoutInfo(): Promise<CutoutInfo>;
|
||||
}
|
||||
|
||||
/**
|
||||
* cutout information of the display.
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 9
|
||||
*/
|
||||
interface CutoutInfo {
|
||||
BoundingRects: Array<Rect>;
|
||||
waterfallDisplayAreaRects: WaterfallDisplayAreaRects;
|
||||
}
|
||||
|
||||
interface WaterfallDisplayAreaRects {
|
||||
left: Rect;
|
||||
right: Rect;
|
||||
top: Rect;
|
||||
bottom: Rect;
|
||||
}
|
||||
|
||||
interface Rect {
|
||||
left: number;
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
}
|
||||
|
||||
export default display;
|
||||
@@ -21,19 +21,19 @@
|
||||
<defaultDeviceRotationOffset>0</defaultDeviceRotationOffset>
|
||||
<!--Cutout area Rect. This is temporary config. To delete when Rs cutout area interface is ready.-->
|
||||
<cutoutArea>10 10 100 20</cutoutArea>
|
||||
<!-- Svg path for cutout, use empty string if there is not cutout on the screen -->
|
||||
<!-- format: string -->
|
||||
<!-- default value is an empty string -->
|
||||
<!-- sample: M 205,5 L 795,5 L 595,295 L 5,295 L 205,5 z -->
|
||||
<!-- mandatory: no -->
|
||||
<defaultDisplayCutoutPath>M 100,100 m -75,0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0 z</defaultDisplayCutoutPath>
|
||||
<!-- default value: empty string -->
|
||||
<!-- sample: M 100,100 m -75,0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0 z -->
|
||||
<defaultDisplayCutoutPath></defaultDisplayCutoutPath>
|
||||
<!-- Indicates the boundary of the curved screen, each value corresponds to the px from each edge -->
|
||||
<!-- format: number(left) number(top) number(right) number(bottom) -->
|
||||
<!-- default value: 0 0 0 0 -->
|
||||
<!-- sample: 150 150 0 0 -->
|
||||
<!-- mandatory: no -->
|
||||
<curvedScreenBoundary>0 0 0 0</curvedScreenBoundary>
|
||||
<!-- Indicates whether the built-in display is a waterfall display -->
|
||||
<!-- format: boolean -->
|
||||
<!-- default value: false -->
|
||||
<!-- sample: false -->
|
||||
<!-- mandatory: no -->
|
||||
<isWaterfallDisplay>false</isWaterfallDisplay>
|
||||
<isWaterfallDisplay enable="false"></isWaterfallDisplay>
|
||||
</Configs>
|
||||
|
||||
Reference in New Issue
Block a user