mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
add desktop and keyguard orientaion
Signed-off-by: xiaojianfeng <xiaojianfeng3@huawei.com> Change-Id: I18317cfc343ad5e29dab60746ba9cf103946c338
This commit is contained in:
@@ -88,6 +88,12 @@ public:
|
||||
|| type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
|
||||
}
|
||||
|
||||
static inline bool IsRotatableWindow(WindowType type, WindowMode mode)
|
||||
{
|
||||
return WindowHelper::IsMainFullScreenWindow(type, mode) || type == WindowType::WINDOW_TYPE_KEYGUARD ||
|
||||
type == WindowType::WINDOW_TYPE_DESKTOP;
|
||||
}
|
||||
|
||||
static inline bool IsFullScreenWindow(WindowMode mode)
|
||||
{
|
||||
return mode == WindowMode::WINDOW_MODE_FULLSCREEN;
|
||||
@@ -120,15 +126,6 @@ public:
|
||||
return r.width_ > r.height_;
|
||||
}
|
||||
|
||||
static inline bool HasOverlap(const Rect& r1, const Rect& r2)
|
||||
{
|
||||
int32_t r1XEnd = r1.posX_ + r1.width_;
|
||||
int32_t r1YEnd = r1.posY_ + r1.height_;
|
||||
int32_t r2XEnd = r2.posX_ + r2.width_;
|
||||
int32_t r2YEnd = r2.posY_ + r2.height_;
|
||||
return !(r1XEnd < r2.posX_ || r1.posX_ > r2XEnd || r1YEnd < r2.posY_ || r1.posY_ > r2YEnd);
|
||||
}
|
||||
|
||||
static Rect GetOverlap(const Rect& rect1, const Rect& rect2, const int offsetX, const int offsetY)
|
||||
{
|
||||
int32_t x_begin = std::max(rect1.posX_, rect2.posX_);
|
||||
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
WMError DestroyWindowInner(sptr<WindowNode>& node);
|
||||
void UpdateFocusWindowWithWindowRemoved(const sptr<WindowNode>& node,
|
||||
const sptr<WindowNodeContainer>& container) const;
|
||||
void UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& node,
|
||||
sptr<WindowNode> UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& node,
|
||||
const sptr<WindowNodeContainer>& container) const;
|
||||
void UpdateBrightnessWithWindowRemoved(uint32_t windowId, const sptr<WindowNodeContainer>& container) const;
|
||||
std::string GenAllWindowsLogInfo() const;
|
||||
|
||||
@@ -868,7 +868,7 @@ WMError WindowController::UpdateProperty(sptr<WindowProperty>& property, Propert
|
||||
}
|
||||
case PropertyChangeAction::ACTION_UPDATE_ORIENTATION: {
|
||||
node->SetRequestedOrientation(property->GetRequestedOrientation());
|
||||
if (WindowHelper::IsMainFullScreenWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
if (WindowHelper::IsRotatableWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
DisplayManagerServiceInner::GetInstance().
|
||||
SetOrientationFromWindow(node->GetDisplayId(), property->GetRequestedOrientation());
|
||||
}
|
||||
|
||||
@@ -454,8 +454,24 @@ void WindowNodeContainer::RecoverScreenDefaultOrientationIfNeed(DisplayId displa
|
||||
{
|
||||
if (displayGroupController_->displayGroupWindowTree_[displayId][WindowRootNodeType::APP_WINDOW_NODE]->empty()) {
|
||||
WLOGFI("appWindowNode_ child is empty in display %{public}" PRIu64"", displayId);
|
||||
DisplayManagerServiceInner::GetInstance().
|
||||
SetOrientationFromWindow(displayId, Orientation::UNSPECIFIED);
|
||||
auto aboveWindows =
|
||||
*displayGroupController_->displayGroupWindowTree_[displayId][WindowRootNodeType::ABOVE_WINDOW_NODE];
|
||||
for (auto iter = aboveWindows.begin(); iter != aboveWindows.end(); iter++) {
|
||||
auto windowMode = (*iter)->GetWindowMode();
|
||||
if (WindowHelper::IsFullScreenWindow(windowMode) || WindowHelper::IsSplitWindowMode(windowMode)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto belowWindows =
|
||||
*displayGroupController_->displayGroupWindowTree_[displayId][WindowRootNodeType::BELOW_WINDOW_NODE];
|
||||
Orientation targetOrientation = Orientation::UNSPECIFIED;
|
||||
for (auto iter = belowWindows.begin(); iter != belowWindows.end(); iter++) {
|
||||
if ((*iter)->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP) {
|
||||
targetOrientation = (*iter)->GetRequestedOrientation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
DisplayManagerServiceInner::GetInstance().SetOrientationFromWindow(displayId, targetOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -869,7 +885,7 @@ void WindowNodeContainer::NotifyIfKeyboardRegionChanged(const sptr<WindowNode>&
|
||||
callingWindowMode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) {
|
||||
const Rect keyRect = node->GetWindowRect();
|
||||
const Rect callingRect = callingWindow->GetWindowRect();
|
||||
if (!WindowHelper::HasOverlap(callingRect, keyRect)) {
|
||||
if (WindowHelper::IsEmptyRect(WindowHelper::GetOverlap(callingRect, keyRect, 0, 0))) {
|
||||
WLOGFD("no overlap between two windows");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -443,8 +443,7 @@ WMError WindowRoot::PostProcessAddWindowNode(sptr<WindowNode>& node, sptr<Window
|
||||
WLOGFI("windowId:%{public}u, name:%{public}s, orientation:%{public}u, type:%{public}u, isMainWindow:%{public}d",
|
||||
node->GetWindowId(), node->GetWindowName().c_str(), static_cast<uint32_t>(node->GetRequestedOrientation()),
|
||||
node->GetWindowType(), WindowHelper::IsMainWindow(node->GetWindowType()));
|
||||
if (WindowHelper::IsMainWindow(node->GetWindowType()) &&
|
||||
node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
if (WindowHelper::IsRotatableWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
DisplayManagerServiceInner::GetInstance().
|
||||
SetOrientationFromWindow(node->GetDisplayId(), node->GetRequestedOrientation());
|
||||
}
|
||||
@@ -536,7 +535,7 @@ WMError WindowRoot::RemoveWindowNode(uint32_t windowId)
|
||||
}
|
||||
container->DropShowWhenLockedWindowIfNeeded(node);
|
||||
UpdateFocusWindowWithWindowRemoved(node, container);
|
||||
UpdateActiveWindowWithWindowRemoved(node, container);
|
||||
auto nextOrientationWindow = UpdateActiveWindowWithWindowRemoved(node, container);
|
||||
UpdateBrightnessWithWindowRemoved(windowId, container);
|
||||
WMError res = container->RemoveWindowNode(node);
|
||||
if (res == WMError::WM_OK) {
|
||||
@@ -548,6 +547,14 @@ WMError WindowRoot::RemoveWindowNode(uint32_t windowId)
|
||||
}
|
||||
HandleKeepScreenOn(windowId, false);
|
||||
}
|
||||
while (nextOrientationWindow != nullptr && !WindowHelper::IsMainWindow(nextOrientationWindow->GetWindowType())) {
|
||||
nextOrientationWindow = nextOrientationWindow->parent_;
|
||||
}
|
||||
if (nextOrientationWindow != nullptr && WindowHelper::IsRotatableWindow(
|
||||
nextOrientationWindow->GetWindowType(), nextOrientationWindow->GetWindowMode())) {
|
||||
DisplayManagerServiceInner::GetInstance().SetOrientationFromWindow(nextOrientationWindow->GetDisplayId(),
|
||||
nextOrientationWindow->GetRequestedOrientation());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -654,7 +661,12 @@ WMError WindowRoot::SetWindowMode(sptr<WindowNode>& node, WindowMode dstMode)
|
||||
WLOGFE("set window mode failed, window container could not be found");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
return container->SetWindowMode(node, dstMode);
|
||||
auto res = container->SetWindowMode(node, dstMode);
|
||||
if (WindowHelper::IsRotatableWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
DisplayManagerServiceInner::GetInstance().
|
||||
SetOrientationFromWindow(node->GetDisplayId(), node->GetRequestedOrientation());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
WMError WindowRoot::DestroyWindow(uint32_t windowId, bool onlySelf)
|
||||
@@ -786,12 +798,12 @@ void WindowRoot::UpdateFocusWindowWithWindowRemoved(const sptr<WindowNode>& node
|
||||
}
|
||||
}
|
||||
|
||||
void WindowRoot::UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& node,
|
||||
sptr<WindowNode> WindowRoot::UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& node,
|
||||
const sptr<WindowNodeContainer>& container) const
|
||||
{
|
||||
if (node == nullptr || container == nullptr) {
|
||||
WLOGFE("window is invalid");
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t windowId = node->GetWindowId();
|
||||
uint32_t activeWindowId = container->GetActiveWindow();
|
||||
@@ -803,7 +815,7 @@ void WindowRoot::UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& nod
|
||||
return node->GetWindowId() == activeWindowId;
|
||||
});
|
||||
if (iter == node->children_.end()) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (!node->children_.empty()) {
|
||||
@@ -814,7 +826,7 @@ void WindowRoot::UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& nod
|
||||
}
|
||||
} else {
|
||||
if (windowId != activeWindowId) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
auto nextActiveWindow = container->GetNextActiveWindow(windowId);
|
||||
@@ -822,6 +834,7 @@ void WindowRoot::UpdateActiveWindowWithWindowRemoved(const sptr<WindowNode>& nod
|
||||
WLOGFI("adjust active window, next active window id: %{public}u", nextActiveWindow->GetWindowId());
|
||||
container->SetActiveWindow(nextActiveWindow->GetWindowId(), true);
|
||||
}
|
||||
return nextActiveWindow;
|
||||
}
|
||||
|
||||
void WindowRoot::UpdateBrightnessWithWindowRemoved(uint32_t windowId, const sptr<WindowNodeContainer>& container) const
|
||||
@@ -884,8 +897,8 @@ WMError WindowRoot::RequestActiveWindow(uint32_t windowId)
|
||||
WLOGFI("windowId:%{public}u, name:%{public}s, orientation:%{public}u, type:%{public}u, isMainWindow:%{public}d",
|
||||
windowId, node->GetWindowName().c_str(), static_cast<uint32_t>(node->GetRequestedOrientation()),
|
||||
node->GetWindowType(), WindowHelper::IsMainWindow(node->GetWindowType()));
|
||||
if (res == WMError::WM_OK && WindowHelper::IsMainWindow(node->GetWindowType()) &&
|
||||
node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
if (res == WMError::WM_OK &&
|
||||
WindowHelper::IsRotatableWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
DisplayManagerServiceInner::GetInstance().
|
||||
SetOrientationFromWindow(node->GetDisplayId(), node->GetRequestedOrientation());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user