mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-20 01:13:32 -04:00
update hot zone of corner
Signed-off-by: l00574490 <liuqi149@huawei.com> Change-Id: I4777935afb27ad70647bccf83e36eb8b7ac1cf9d
This commit is contained in:
@@ -188,7 +188,7 @@ enum class OccupiedAreaType : uint32_t {
|
||||
|
||||
enum class ColorSpace : uint32_t {
|
||||
COLOR_SPACE_DEFAULT = 0, // Default color space.
|
||||
COLOR_SPACE_WIDE_GAMUT, // Wide gamut color space. The specific wide color gamut depends on thr screen.
|
||||
COLOR_SPACE_WIDE_GAMUT, // Wide gamut color space. The specific wide color gamut depends on the screen.
|
||||
};
|
||||
|
||||
enum class WindowAnimation : uint32_t {
|
||||
|
||||
@@ -785,8 +785,8 @@ NativeValue* JsWindow::OnSetSystemBarEnable(NativeEngine& engine, NativeCallback
|
||||
{
|
||||
WLOGFI("JsWindow::OnSetSystemBarEnable is called");
|
||||
WMError errCode = WMError::WM_OK;
|
||||
if (info.argc < 1 || info.argc > 2) { // 2: maximum params num
|
||||
WLOGFE("JsWindow params not match!");
|
||||
if (info.argc < 1 || info.argc > 2 || windowToken_ == nullptr) { // 2: maximum params num
|
||||
WLOGFE("JsWindow params not match or window token is nullptr!");
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
std::map<WindowType, SystemBarProperty> systemBarProperties;
|
||||
|
||||
@@ -136,7 +136,12 @@ public:
|
||||
}
|
||||
}
|
||||
// minimum position y
|
||||
dstRect.posY_ = std::max(displayLimitRect.posY_, oriDstRect.posY_);
|
||||
if (oriDstRect.posY_ < displayLimitRect.posY_) {
|
||||
dstRect.posY_ = displayLimitRect.posY_;
|
||||
if (oriDstRect.height_ != lastRect.height_) {
|
||||
dstRect.height_ = lastRect.height_;
|
||||
}
|
||||
}
|
||||
// maximum position y
|
||||
if (dstRect.posY_ > (displayLimitRect.posY_ +
|
||||
static_cast<int32_t>(displayLimitRect.height_ - windowTitleBarH))) {
|
||||
@@ -159,6 +164,17 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsPointInWindowExceptCorner(int32_t pointPosX, int32_t pointPosY, const Rect& rectExceptCorner)
|
||||
{
|
||||
if ((pointPosX > rectExceptCorner.posX_ &&
|
||||
pointPosX < (rectExceptCorner.posX_ + static_cast<int32_t>(rectExceptCorner.width_))) ||
|
||||
(pointPosY > rectExceptCorner.posY_ &&
|
||||
pointPosY < (rectExceptCorner.posY_ + static_cast<int32_t>(rectExceptCorner.height_)))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool IsSwitchCascadeReason(WindowUpdateReason reason)
|
||||
{
|
||||
return (reason >= WindowUpdateReason::NEED_SWITCH_CASCADE_BASE) &&
|
||||
|
||||
@@ -67,9 +67,9 @@ enum class PropertyChangeAction : uint32_t {
|
||||
namespace {
|
||||
constexpr float DEFAULT_SPLIT_RATIO = 0.5;
|
||||
constexpr uint32_t DIVIDER_WIDTH = 8;
|
||||
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 48;
|
||||
constexpr uint32_t WINDOW_FRAME_WIDTH = 4;
|
||||
constexpr uint32_t WINDOW_FRAME_TOP_WIDTH = 1; // the frame width of top position
|
||||
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 37;
|
||||
constexpr uint32_t WINDOW_FRAME_WIDTH = 5;
|
||||
constexpr uint32_t WINDOW_FRAME_CORNER_WIDTH = 16; // the frame width of corner
|
||||
constexpr uint32_t HOTZONE = 20;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_WIDTH = 240;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_HEIGHT = 320;
|
||||
|
||||
@@ -255,6 +255,7 @@ private:
|
||||
bool pointEventStarted_ = false;
|
||||
Rect startPointRect_ = { 0, 0, 0, 0 };
|
||||
Rect startRectExceptFrame_ = { 0, 0, 0, 0 };
|
||||
Rect startRectExceptCorner_ = { 0, 0, 0, 0 };
|
||||
bool keepScreenOn_ = false;
|
||||
std::shared_ptr<PowerMgr::RunningLock> keepScreenLock_;
|
||||
};
|
||||
|
||||
+29
-7
@@ -1137,25 +1137,36 @@ void WindowImpl::HandleDragEvent(int32_t posX, int32_t posY, int32_t pointId)
|
||||
int32_t diffX = posX - startPointPosX_;
|
||||
int32_t diffY = posY - startPointPosY_;
|
||||
Rect newRect = startPointRect_;
|
||||
if (startPointPosX_ <= startRectExceptFrame_.posX_) {
|
||||
|
||||
Rect hotZoneRect;
|
||||
if ((startPointPosX_ > startRectExceptCorner_.posX_ &&
|
||||
(startPointPosX_ < startRectExceptCorner_.posX_ + static_cast<int32_t>(startRectExceptCorner_.width_))) &&
|
||||
(startPointPosY_ > startRectExceptCorner_.posY_ &&
|
||||
(startPointPosY_ < startRectExceptCorner_.posY_ + static_cast<int32_t>(startRectExceptCorner_.height_)))) {
|
||||
hotZoneRect = startRectExceptFrame_; // drag type: left/right/top/bottom
|
||||
} else {
|
||||
hotZoneRect = startRectExceptCorner_; // drag type: left_top/right_top/left_bottom/right_bottom
|
||||
}
|
||||
|
||||
if (startPointPosX_ <= hotZoneRect.posX_) {
|
||||
if (diffX > static_cast<int32_t>(startPointRect_.width_)) {
|
||||
diffX = static_cast<int32_t>(startPointRect_.width_);
|
||||
}
|
||||
newRect.posX_ += diffX;
|
||||
newRect.width_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.width_) - diffX);
|
||||
} else if (startPointPosX_ >= startRectExceptFrame_.posX_ + static_cast<int32_t>(startRectExceptFrame_.width_)) {
|
||||
} else if (startPointPosX_ >= hotZoneRect.posX_ + static_cast<int32_t>(hotZoneRect.width_)) {
|
||||
if (diffX < 0 && (-diffX > static_cast<int32_t>(startPointRect_.width_))) {
|
||||
diffX = -(static_cast<int32_t>(startPointRect_.width_));
|
||||
}
|
||||
newRect.width_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.width_) + diffX);
|
||||
}
|
||||
if (startPointPosY_ <= startRectExceptFrame_.posY_) {
|
||||
if (startPointPosY_ <= hotZoneRect.posY_) {
|
||||
if (diffY > static_cast<int32_t>(startPointRect_.height_)) {
|
||||
diffY = static_cast<int32_t>(startPointRect_.height_);
|
||||
}
|
||||
newRect.posY_ += diffY;
|
||||
newRect.height_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.height_) - diffY);
|
||||
} else if (startPointPosY_ >= startRectExceptFrame_.posY_ + static_cast<int32_t>(startRectExceptFrame_.height_)) {
|
||||
} else if (startPointPosY_ >= hotZoneRect.posY_ + static_cast<int32_t>(hotZoneRect.height_)) {
|
||||
if (diffY < 0 && (-diffY > static_cast<int32_t>(startPointRect_.height_))) {
|
||||
diffY = -(static_cast<int32_t>(startPointRect_.height_));
|
||||
}
|
||||
@@ -1210,16 +1221,27 @@ void WindowImpl::ReadyToMoveOrDragWindow(int32_t globalX, int32_t globalY, int32
|
||||
startRectExceptFrame_.posX_ = startPointRect_.posX_ +
|
||||
static_cast<int32_t>(WINDOW_FRAME_WIDTH * virtualPixelRatio);
|
||||
startRectExceptFrame_.posY_ = startPointRect_.posY_ +
|
||||
static_cast<int32_t>(WINDOW_FRAME_TOP_WIDTH * virtualPixelRatio);
|
||||
static_cast<int32_t>(WINDOW_FRAME_WIDTH * virtualPixelRatio);
|
||||
startRectExceptFrame_.width_ = startPointRect_.width_ -
|
||||
static_cast<uint32_t>((WINDOW_FRAME_WIDTH + WINDOW_FRAME_WIDTH) * virtualPixelRatio);
|
||||
startRectExceptFrame_.height_ = startPointRect_.height_ -
|
||||
static_cast<uint32_t>((WINDOW_FRAME_TOP_WIDTH + WINDOW_FRAME_WIDTH) * virtualPixelRatio);
|
||||
static_cast<uint32_t>((WINDOW_FRAME_WIDTH + WINDOW_FRAME_WIDTH) * virtualPixelRatio);
|
||||
|
||||
startRectExceptCorner_.posX_ = startPointRect_.posX_ +
|
||||
static_cast<int32_t>(WINDOW_FRAME_CORNER_WIDTH * virtualPixelRatio);
|
||||
startRectExceptCorner_.posY_ = startPointRect_.posY_ +
|
||||
static_cast<int32_t>(WINDOW_FRAME_CORNER_WIDTH * virtualPixelRatio);
|
||||
startRectExceptCorner_.width_ = startPointRect_.width_ -
|
||||
static_cast<uint32_t>((WINDOW_FRAME_CORNER_WIDTH + WINDOW_FRAME_CORNER_WIDTH) * virtualPixelRatio);
|
||||
startRectExceptCorner_.height_ = startPointRect_.height_ -
|
||||
static_cast<uint32_t>((WINDOW_FRAME_CORNER_WIDTH + WINDOW_FRAME_CORNER_WIDTH) * virtualPixelRatio);
|
||||
|
||||
if (GetType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
startMoveFlag_ = true;
|
||||
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(property_->GetWindowId(), true);
|
||||
} else if (!WindowHelper::IsPointInTargetRect(startPointPosX_, startPointPosY_, startRectExceptFrame_)) {
|
||||
} else if (!WindowHelper::IsPointInTargetRect(startPointPosX_, startPointPosY_, startRectExceptFrame_) ||
|
||||
(WindowHelper::IsPointInTargetRect(startPointPosX_, startPointPosY_, startRectExceptFrame_) &&
|
||||
(!WindowHelper::IsPointInWindowExceptCorner(startPointPosX_, startPointPosY_, startRectExceptCorner_)))) {
|
||||
startDragFlag_ = true;
|
||||
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(property_->GetWindowId(), true);
|
||||
}
|
||||
|
||||
@@ -146,11 +146,11 @@ void WindowMoveDragTest::CalExpectRects()
|
||||
startRectExceptFrame.posX_ = startPointRect_.posX_ +
|
||||
static_cast<int32_t>(WINDOW_FRAME_WIDTH * virtualPixelRatio_);
|
||||
startRectExceptFrame.posY_ = startPointRect_.posY_ +
|
||||
static_cast<int32_t>(WINDOW_FRAME_TOP_WIDTH * virtualPixelRatio_);
|
||||
static_cast<int32_t>(WINDOW_FRAME_WIDTH * virtualPixelRatio_);
|
||||
startRectExceptFrame.width_ = startPointRect_.width_ -
|
||||
static_cast<uint32_t>((WINDOW_FRAME_WIDTH + WINDOW_FRAME_WIDTH) * virtualPixelRatio_);
|
||||
startRectExceptFrame.height_ = startPointRect_.height_ -
|
||||
static_cast<uint32_t>((WINDOW_FRAME_TOP_WIDTH + WINDOW_FRAME_WIDTH) * virtualPixelRatio_);
|
||||
static_cast<uint32_t>((WINDOW_FRAME_WIDTH + WINDOW_FRAME_WIDTH) * virtualPixelRatio_);
|
||||
|
||||
bool isPointInWindow = WindowHelper::IsPointInTargetRect(startPointX_, startPointY_, startRectExceptFrame);
|
||||
int32_t diffX = pointX_ - startPointX_;
|
||||
|
||||
@@ -172,15 +172,15 @@ void WindowNodeContainer::UpdateSizeChangeReason(sptr<WindowNode>& node, WindowS
|
||||
if (childNode->IsSplitMode()) {
|
||||
childNode->GetWindowToken()->UpdateWindowRect(childNode->GetLayoutRect(), reason);
|
||||
childNode->ResetWindowSizeChangeReason();
|
||||
WLOGFI("Notify split window that the drag action is end, windowId: %{public}d, reason: %{public}d",
|
||||
childNode->GetWindowId(), reason);
|
||||
WLOGFI("Notify split window that the drag action is start or end, windowId: %{public}d, "
|
||||
"reason: %{public}d", childNode->GetWindowId(), reason);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
node->GetWindowToken()->UpdateWindowRect(node->GetLayoutRect(), reason);
|
||||
node->ResetWindowSizeChangeReason();
|
||||
WLOGFI("Notify window that the drag action is end, widnowId: %{public}d, reason: %{public}d",
|
||||
node->GetWindowId(), reason);
|
||||
WLOGFI("Notify window that the drag action is start or end, windowId: %{public}d, "
|
||||
"reason: %{public}d", node->GetWindowId(), reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user