mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
modify drag area
Change-Id: I95af39217bfc7b29f535a244d55c210a06a786df Signed-off-by: l00574490 <liuqi149@huawei.com>
This commit is contained in:
@@ -111,12 +111,12 @@ public:
|
||||
return dstRect;
|
||||
}
|
||||
|
||||
static bool IsPointInWindow(int32_t pointPosX, int32_t pointPosY, Rect pointRect)
|
||||
static bool IsPointInTargetRect(int32_t pointPosX, int32_t pointPosY, const Rect& targetRect)
|
||||
{
|
||||
if ((pointPosX > pointRect.posX_) &&
|
||||
(pointPosX < (pointRect.posX_ + static_cast<int32_t>(pointRect.width_))) &&
|
||||
(pointPosY > pointRect.posY_) &&
|
||||
(pointPosY < (pointRect.posY_ + static_cast<int32_t>(pointRect.height_)))) {
|
||||
if ((pointPosX > targetRect.posX_) &&
|
||||
(pointPosX < (targetRect.posX_ + static_cast<int32_t>(targetRect.width_))) &&
|
||||
(pointPosY > targetRect.posY_) &&
|
||||
(pointPosY < (targetRect.posY_ + static_cast<int32_t>(targetRect.height_)))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace {
|
||||
constexpr uint32_t DIVIDER_WIDTH = 8;
|
||||
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 48;
|
||||
constexpr uint32_t WINDOW_FRAME_WIDTH = 4;
|
||||
constexpr uint32_t HOTZONE = 40;
|
||||
constexpr uint32_t DIV_HOTZONE = 20;
|
||||
constexpr uint32_t WINDOW_FRAME_TOP_WIDTH = 1; // the frame width of top position
|
||||
constexpr uint32_t HOTZONE = 20;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_WIDTH = 240;
|
||||
constexpr uint32_t MIN_VERTICAL_FLOATING_HEIGHT = 426;
|
||||
constexpr uint32_t MIN_VERTICAL_SPLIT_HEIGHT = 426;
|
||||
|
||||
@@ -208,6 +208,7 @@ private:
|
||||
bool startMoveFlag_ = false;
|
||||
bool pointEventStarted_ = false;
|
||||
Rect startPointRect_ = { 0, 0, 0, 0 };
|
||||
Rect startRectExceptFrame_ = { 0, 0, 0, 0 };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+24
-5
@@ -995,25 +995,25 @@ 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_ <= startPointRect_.posX_) {
|
||||
if (startPointPosX_ <= startRectExceptFrame_.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_ >= startPointRect_.posX_ + static_cast<int32_t>(startPointRect_.width_)) {
|
||||
} else if (startPointPosX_ >= startRectExceptFrame_.posX_ + static_cast<int32_t>(startRectExceptFrame_.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_ <= startPointRect_.posY_) {
|
||||
if (startPointPosY_ <= startRectExceptFrame_.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_ >= startPointRect_.posY_ + static_cast<int32_t>(startPointRect_.height_)) {
|
||||
} else if (startPointPosY_ >= startRectExceptFrame_.posY_ + static_cast<int32_t>(startRectExceptFrame_.height_)) {
|
||||
if (diffY < 0 && (-diffY > static_cast<int32_t>(startPointRect_.height_))) {
|
||||
diffY = -(static_cast<int32_t>(startPointRect_.height_));
|
||||
}
|
||||
@@ -1046,9 +1046,28 @@ void WindowImpl::ReadyToMoveOrDragWindow(int32_t globalX, int32_t globalY, int32
|
||||
startPointPosY_ = globalY;
|
||||
startPointerId_ = pointId;
|
||||
pointEventStarted_ = true;
|
||||
|
||||
// calculate window inner rect except frame
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(property_->GetDisplayId());
|
||||
if (display == nullptr) {
|
||||
WLOGFE("get display failed displayId:%{public}" PRIu64", window id:%{public}u", property_->GetDisplayId(),
|
||||
property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
float virtualPixelRatio = display->GetVirtualPixelRatio();
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
if (GetType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
startMoveFlag_ = true;
|
||||
} else if (!WindowHelper::IsPointInWindow(startPointPosX_, startPointPosY_, startPointRect_)) {
|
||||
} else if (!WindowHelper::IsPointInTargetRect(startPointPosX_, startPointPosY_, startRectExceptFrame_)) {
|
||||
startDragFlag_ = true;
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -88,7 +88,7 @@ void DragController::FinishDrag(uint32_t windowId)
|
||||
if (node->GetWindowType() != WindowType::WINDOW_TYPE_DRAGGING_EFFECT) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sptr<WindowNode> hitWindow = windowRoot_->GetWindowNode(hitWindowId_);
|
||||
if (hitWindow != nullptr) {
|
||||
auto property = node->GetWindowProperty();
|
||||
@@ -118,7 +118,7 @@ sptr<WindowNode> DragController::GetHitWindow(DisplayId id, PointInfo point)
|
||||
if (windowNode->GetWindowType() >= WindowType::WINDOW_TYPE_DRAGGING_EFFECT) {
|
||||
continue;
|
||||
}
|
||||
if (WindowHelper::IsPointInWindow(point.x, point.y, windowNode->GetLayoutRect())) {
|
||||
if (WindowHelper::IsPointInTargetRect(point.x, point.y, windowNode->GetLayoutRect())) {
|
||||
return windowNode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,15 +241,14 @@ void WindowLayoutPolicy::CalcAndSetNodeHotZone(Rect layoutOutRect, sptr<WindowNo
|
||||
Rect rect = layoutOutRect;
|
||||
float virtualPixelRatio = GetVirtualPixelRatio();
|
||||
uint32_t hotZone = static_cast<uint32_t>(HOTZONE * virtualPixelRatio);
|
||||
uint32_t divHotZone = static_cast<uint32_t>(DIV_HOTZONE * virtualPixelRatio);
|
||||
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
if (rect.width_ < rect.height_) {
|
||||
rect.posX_ -= divHotZone;
|
||||
rect.width_ += (divHotZone + divHotZone);
|
||||
rect.posX_ -= hotZone;
|
||||
rect.width_ += (hotZone + hotZone);
|
||||
} else {
|
||||
rect.posY_ -= divHotZone;
|
||||
rect.height_ += (divHotZone + divHotZone);
|
||||
rect.posY_ -= hotZone;
|
||||
rect.height_ += (hotZone + hotZone);
|
||||
}
|
||||
} else if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
rect.posX_ -= hotZone;
|
||||
|
||||
Reference in New Issue
Block a user