mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
@@ -362,8 +362,6 @@ private:
|
||||
void ConsumeMoveOrDragEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
void ReadyToMoveOrDragWindow(int32_t globalX, int32_t globalY, int32_t pointId, const Rect& rect);
|
||||
void EndMoveOrDragWindow(int32_t posX, int32_t posY, int32_t pointId);
|
||||
void HandleMoveEvent(int32_t posX, int32_t posY, int32_t pointId);
|
||||
void HandleDragEvent(int32_t posX, int32_t posY, int32_t pointId);
|
||||
void ResetMoveOrDragState();
|
||||
bool IsPointerEventConsumed();
|
||||
void AdjustWindowAnimationFlag(bool withAnimation = false);
|
||||
|
||||
@@ -1976,73 +1976,6 @@ void WindowImpl::ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::HandleMoveEvent(int32_t posX, int32_t posY, int32_t pointId)
|
||||
{
|
||||
if (!moveDragProperty_->startMoveFlag_ || (pointId != moveDragProperty_->startPointerId_)) {
|
||||
return;
|
||||
}
|
||||
int32_t targetX = moveDragProperty_->startPointRect_.posX_ + (posX - moveDragProperty_->startPointPosX_);
|
||||
int32_t targetY = moveDragProperty_->startPointRect_.posY_ + (posY - moveDragProperty_->startPointPosY_);
|
||||
auto res = MoveTo(targetX, targetY);
|
||||
if (res != WMError::WM_OK) {
|
||||
WLOGFE("move window: %{public}u failed", GetWindowId());
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::HandleDragEvent(int32_t posX, int32_t posY, int32_t pointId)
|
||||
{
|
||||
if (!moveDragProperty_->startDragFlag_ || (pointId != moveDragProperty_->startPointerId_)) {
|
||||
return;
|
||||
}
|
||||
const auto& startPointPosX = moveDragProperty_->startPointPosX_;
|
||||
const auto& startPointPosY = moveDragProperty_->startPointPosY_;
|
||||
const auto& startPointRect = moveDragProperty_->startPointRect_;
|
||||
const auto& startRectExceptCorner = moveDragProperty_->startRectExceptCorner_;
|
||||
const auto& startRectExceptFrame = moveDragProperty_->startRectExceptFrame_;
|
||||
int32_t diffX = posX - startPointPosX;
|
||||
int32_t diffY = posY - startPointPosY;
|
||||
Rect newRect = startPointRect;
|
||||
|
||||
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 >= 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 <= 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 >= 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_));
|
||||
}
|
||||
newRect.height_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.height_) + diffY);
|
||||
}
|
||||
auto res = Drag(newRect);
|
||||
if (res != WMError::WM_OK) {
|
||||
WLOGFE("drag window: %{public}u failed", GetWindowId());
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::HandleModeChangeHotZones(int32_t posX, int32_t posY)
|
||||
{
|
||||
if (!WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) {
|
||||
|
||||
Reference in New Issue
Block a user