1 /*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "drag_controller.h"
16
17 #include <vector>
18
19 #include "display.h"
20 #include "vsync_station.h"
21 #include "window_helper.h"
22 #include "window_inner_manager.h"
23 #include "window_manager_hilog.h"
24 #include "window_manager_service.h"
25 #include "window_node.h"
26 #include "window_node_container.h"
27 #include "window_property.h"
28 #include "wm_common.h"
29 #include "wm_math.h"
30 #include "xcollie/watchdog.h"
31
32 namespace OHOS {
33 namespace Rosen {
34 namespace {
35 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "DragController"};
36 }
37
UpdateDragInfo(uint32_t windowId)38 void DragController::UpdateDragInfo(uint32_t windowId)
39 {
40 PointInfo point;
41 if (!GetHitPoint(windowId, point)) {
42 return;
43 }
44 sptr<WindowNode> dragNode = windowRoot_->GetWindowNode(windowId);
45 if (dragNode == nullptr) {
46 return;
47 }
48 sptr<WindowNode> hitWindowNode = GetHitWindow(dragNode->GetDisplayId(), point);
49 if (hitWindowNode == nullptr) {
50 WLOGFE("Get point failed %{public}d %{public}d", point.x, point.y);
51 return;
52 }
53 auto token = hitWindowNode->GetWindowToken();
54 if (token) {
55 if (hitWindowNode->GetWindowId() == hitWindowId_) {
56 token->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_MOVE);
57 return;
58 }
59 token->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_IN);
60 }
61 sptr<WindowNode> oldHitWindow = windowRoot_->GetWindowNode(hitWindowId_);
62 if (oldHitWindow != nullptr && oldHitWindow->GetWindowToken()) {
63 oldHitWindow->GetWindowToken()->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_OUT);
64 }
65 hitWindowId_ = hitWindowNode->GetWindowId();
66 }
67
StartDrag(uint32_t windowId)68 void DragController::StartDrag(uint32_t windowId)
69 {
70 PointInfo point;
71 if (!GetHitPoint(windowId, point)) {
72 WLOGFE("Get hit point failed");
73 return;
74 }
75 sptr<WindowNode> dragNode = windowRoot_->GetWindowNode(windowId);
76 if (dragNode == nullptr) {
77 return;
78 }
79 sptr<WindowNode> hitWindow = GetHitWindow(dragNode->GetDisplayId(), point);
80 if (hitWindow == nullptr) {
81 WLOGFE("Get point failed %{public}d %{public}d", point.x, point.y);
82 return;
83 }
84 if (hitWindow->GetWindowToken()) {
85 hitWindow->GetWindowToken()->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_IN);
86 }
87 hitWindowId_ = windowId;
88 WLOGI("start Drag");
89 }
90
FinishDrag(uint32_t windowId)91 void DragController::FinishDrag(uint32_t windowId)
92 {
93 sptr<WindowNode> node = windowRoot_->GetWindowNode(windowId);
94 if (node == nullptr) {
95 WLOGFE("get node failed");
96 return;
97 }
98 if (node->GetWindowType() != WindowType::WINDOW_TYPE_DRAGGING_EFFECT) {
99 return;
100 }
101
102 sptr<WindowNode> hitWindow = windowRoot_->GetWindowNode(hitWindowId_);
103 if (hitWindow != nullptr) {
104 auto property = node->GetWindowProperty();
105 PointInfo point = {property->GetWindowRect().posX_ + property->GetHitOffset().x,
106 property->GetWindowRect().posY_ + property->GetHitOffset().y};
107 if (hitWindow->GetWindowToken()) {
108 hitWindow->GetWindowToken()->UpdateWindowDragInfo(point, DragEvent::DRAG_EVENT_END);
109 }
110 }
111 WLOGI("end drag");
112 }
113
GetHitWindow(DisplayId id,PointInfo point)114 sptr<WindowNode> DragController::GetHitWindow(DisplayId id, PointInfo point)
115 {
116 // Need get display by point
117 if (id == DISPLAY_ID_INVALID) {
118 WLOGFE("Get invalid display");
119 return nullptr;
120 }
121 sptr<WindowNodeContainer> container = windowRoot_->GetOrCreateWindowNodeContainer(id);
122 if (container == nullptr) {
123 WLOGFE("get container failed %{public}" PRIu64"", id);
124 return nullptr;
125 }
126
127 std::vector<sptr<WindowNode>> windowNodes;
128 container->TraverseContainer(windowNodes);
129 for (auto windowNode : windowNodes) {
130 if (windowNode->GetWindowType() >= WindowType::WINDOW_TYPE_PANEL) {
131 continue;
132 }
133 if (WindowHelper::IsPointInTargetRect(point.x, point.y, windowNode->GetWindowRect())) {
134 return windowNode;
135 }
136 }
137 return nullptr;
138 }
139
GetHitPoint(uint32_t windowId,PointInfo & point)140 bool DragController::GetHitPoint(uint32_t windowId, PointInfo& point)
141 {
142 sptr<WindowNode> windowNode = windowRoot_->GetWindowNode(windowId);
143 if (windowNode == nullptr || windowNode->GetWindowType() != WindowType::WINDOW_TYPE_DRAGGING_EFFECT) {
144 WLOGFE("Get hit point failed");
145 return false;
146 }
147 sptr<WindowProperty> property = windowNode->GetWindowProperty();
148 point.x = property->GetWindowRect().posX_ + property->GetHitOffset().x;
149 point.y = property->GetWindowRect().posY_ + property->GetHitOffset().y;
150 return true;
151 }
152
OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const153 void DragInputEventListener::OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const
154 {
155 if (keyEvent == nullptr) {
156 WLOGFE("KeyEvent is nullptr");
157 return;
158 }
159 uint32_t windowId = static_cast<uint32_t>(keyEvent->GetAgentWindowId());
160 WLOGFD("[WMS] Receive keyEvent, windowId: %{public}u", windowId);
161 keyEvent->MarkProcessed();
162 }
163
OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const164 void DragInputEventListener::OnInputEvent(std::shared_ptr<MMI::AxisEvent> axisEvent) const
165 {
166 if (axisEvent == nullptr) {
167 WLOGFE("AxisEvent is nullptr");
168 return;
169 };
170 WLOGFD("[WMS] Receive axisEvent, windowId: %{public}u", axisEvent->GetAgentWindowId());
171 axisEvent->MarkProcessed();
172 }
173
OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const174 void DragInputEventListener::OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const
175 {
176 if (pointerEvent == nullptr) {
177 WLOGFE("PointerEvent is nullptr");
178 return;
179 }
180 uint32_t windowId = static_cast<uint32_t>(pointerEvent->GetAgentWindowId());
181 WLOGFD("[WMS] Receive pointerEvent, windowId: %{public}u", windowId);
182
183 WindowInnerManager::GetInstance().ConsumePointerEvent(pointerEvent);
184 }
185
SetInputEventConsumer()186 void MoveDragController::SetInputEventConsumer()
187 {
188 if (!inputListener_ || !inputEventHandler_) {
189 WLOGFE("InputListener or inputEventHandler is nullptr");
190 return;
191 }
192 MMI::InputManager::GetInstance()->SetWindowInputEventConsumer(inputListener_, inputEventHandler_);
193 }
194
Init()195 bool MoveDragController::Init()
196 {
197 // create handler for input event
198 inputEventHandler_ = std::make_shared<AppExecFwk::EventHandler>(
199 AppExecFwk::EventRunner::Create(INNER_WM_INPUT_THREAD_NAME));
200 if (inputEventHandler_ == nullptr) {
201 return false;
202 }
203 int ret = HiviewDFX::Watchdog::GetInstance().AddThread(INNER_WM_INPUT_THREAD_NAME, inputEventHandler_);
204 if (ret != 0) {
205 WLOGFE("Add watchdog thread failed");
206 }
207 inputListener_ = std::make_shared<DragInputEventListener>(DragInputEventListener());
208 SetInputEventConsumer();
209 VsyncStation::GetInstance().SetIsMainHandlerAvailable(false);
210 VsyncStation::GetInstance().SetVsyncEventHandler(inputEventHandler_);
211 return true;
212 }
213
Stop()214 void MoveDragController::Stop()
215 {
216 if (inputEventHandler_ != nullptr) {
217 inputEventHandler_.reset();
218 }
219 }
220
HandleReadyToMoveOrDrag(uint32_t windowId,sptr<WindowProperty> & windowProperty,sptr<MoveDragProperty> & moveDragProperty)221 void MoveDragController::HandleReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty,
222 sptr<MoveDragProperty>& moveDragProperty)
223 {
224 SetActiveWindowId(windowId);
225 SetWindowProperty(windowProperty);
226 SetDragProperty(moveDragProperty);
227 }
228
HandleEndUpMovingOrDragging(uint32_t windowId)229 void MoveDragController::HandleEndUpMovingOrDragging(uint32_t windowId)
230 {
231 if (activeWindowId_ != windowId) {
232 WLOGFE("end up moving or dragging failed, windowId: %{public}u", windowId);
233 return;
234 }
235 ResetMoveOrDragState();
236 }
237
HandleWindowRemovedOrDestroyed(uint32_t windowId)238 void MoveDragController::HandleWindowRemovedOrDestroyed(uint32_t windowId)
239 {
240 if (GetMoveDragProperty() == nullptr) {
241 return;
242 }
243 if (!(GetMoveDragProperty()->startMoveFlag_ || GetMoveDragProperty()->startDragFlag_)) {
244 return;
245 }
246 VsyncStation::GetInstance().RemoveCallback();
247 ResetMoveOrDragState();
248 }
249
ConvertPointerPosToDisplayGroupPos(DisplayId displayId,int32_t & posX,int32_t & posY)250 void MoveDragController::ConvertPointerPosToDisplayGroupPos(DisplayId displayId, int32_t& posX, int32_t& posY)
251 {
252 auto displayRect = DisplayGroupInfo::GetInstance().GetDisplayRect(displayId);
253 posX += displayRect.posX_;
254 posY += displayRect.posY_;
255 }
256
HandleDisplayLimitRectChange(const std::map<DisplayId,Rect> & limitRectMap)257 void MoveDragController::HandleDisplayLimitRectChange(const std::map<DisplayId, Rect>& limitRectMap)
258 {
259 limitRectMap_.clear();
260 for (auto& elem : limitRectMap) {
261 limitRectMap_.insert(elem);
262 }
263 }
264
ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)265 void MoveDragController::ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
266 {
267 if (pointerEvent == nullptr) {
268 WLOGFE("pointerEvent is nullptr or is handling pointer event");
269 return;
270 }
271 if (pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_MOVE) {
272 moveEvent_ = pointerEvent;
273 VsyncStation::GetInstance().RequestVsync(vsyncCallback_);
274 } else {
275 WLOGFD("[WMS] Dispatch non-move event, action: %{public}d", pointerEvent->GetPointerAction());
276 HandlePointerEvent(pointerEvent);
277 pointerEvent->MarkProcessed();
278 }
279 }
280
OnReceiveVsync(int64_t timeStamp)281 void MoveDragController::OnReceiveVsync(int64_t timeStamp)
282 {
283 if (moveEvent_ == nullptr) {
284 WLOGFE("moveEvent is nullptr");
285 return;
286 }
287 WLOGFD("[OnReceiveVsync] receive move event, action: %{public}d", moveEvent_->GetPointerAction());
288 HandlePointerEvent(moveEvent_);
289 moveEvent_->MarkProcessed();
290 }
291
GetHotZoneRect()292 Rect MoveDragController::GetHotZoneRect()
293 {
294 auto startPointPosX = moveDragProperty_->startPointPosX_;
295 auto startPointPosY = moveDragProperty_->startPointPosY_;
296 ConvertPointerPosToDisplayGroupPos(moveDragProperty_->targetDisplayId_, startPointPosX, startPointPosY);
297
298 Rect hotZoneRect;
299 const auto& startRectExceptCorner = moveDragProperty_->startRectExceptCorner_;
300 const auto& startRectExceptFrame = moveDragProperty_->startRectExceptFrame_;
301 if ((startPointPosX > startRectExceptCorner.posX_ &&
302 (startPointPosX < startRectExceptCorner.posX_ +
303 static_cast<int32_t>(startRectExceptCorner.width_))) &&
304 (startPointPosY > startRectExceptCorner.posY_ &&
305 (startPointPosY < startRectExceptCorner.posY_ +
306 static_cast<int32_t>(startRectExceptCorner.height_)))) {
307 hotZoneRect = startRectExceptFrame; // drag type: left/right/top/bottom
308 } else {
309 hotZoneRect = startRectExceptCorner; // drag type: left_top/right_top/left_bottom/right_bottom
310 }
311 return hotZoneRect;
312 }
313
CheckWindowRect(DisplayId displayId,float vpr,const Rect & rect)314 bool MoveDragController::CheckWindowRect(DisplayId displayId, float vpr, const Rect& rect)
315 {
316 uint32_t titleBarHeight = static_cast<uint32_t>(WINDOW_TITLE_BAR_HEIGHT * vpr);
317 auto iter = limitRectMap_.find(displayId);
318 Rect limitRect;
319 if (iter != limitRectMap_.end()) {
320 limitRect = iter->second;
321 }
322 if (WindowHelper::IsEmptyRect(limitRect) || MathHelper::NearZero(vpr)) {
323 return true; // If limitRect is empty, we can't use limitRect to check window rect
324 }
325
326 if ((rect.posX_ > static_cast<int32_t>(limitRect.posX_ + limitRect.width_ - titleBarHeight)) ||
327 (rect.posX_ + static_cast<int32_t>(rect.width_) <
328 static_cast<int32_t>(limitRect.posX_ + titleBarHeight)) ||
329 (rect.posY_ < limitRect.posY_) ||
330 (rect.posY_ > static_cast<int32_t>(limitRect.posY_ + limitRect.height_ - titleBarHeight))) {
331 WLOGFD("[WMS] Invalid window rect, id: %{public}u, rect: [%{public}d, %{public}d, %{public}d, %{public}d]",
332 windowProperty_->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_);
333 return false;
334 }
335 return true;
336 }
337
CalculateNewWindowRect(Rect & newRect,DisplayId displayId,int32_t posX,int32_t posY)338 void MoveDragController::CalculateNewWindowRect(Rect& newRect, DisplayId displayId, int32_t posX, int32_t posY)
339 {
340 auto startPointPosX = moveDragProperty_->startPointPosX_;
341 auto startPointPosY = moveDragProperty_->startPointPosY_;
342 ConvertPointerPosToDisplayGroupPos(moveDragProperty_->targetDisplayId_, startPointPosX, startPointPosY);
343 const auto& startPointRect = moveDragProperty_->startPointRect_;
344 Rect hotZoneRect = GetHotZoneRect();
345 int32_t diffX = posX - startPointPosX;
346 int32_t diffY = posY - startPointPosY;
347
348 float vpr = DisplayGroupInfo::GetInstance().GetDisplayVirtualPixelRatio(displayId);
349 if (MathHelper::NearZero(vpr)) {
350 return;
351 }
352 uint32_t minWidth = static_cast<uint32_t>(MIN_FLOATING_WIDTH * vpr);
353 uint32_t minHeight = static_cast<uint32_t>(MIN_FLOATING_HEIGHT * vpr);
354 if (startPointPosX <= hotZoneRect.posX_) {
355 if (diffX > static_cast<int32_t>(startPointRect.width_ - minWidth)) {
356 diffX = static_cast<int32_t>(startPointRect.width_ - minWidth);
357 }
358 newRect.posX_ += diffX;
359 newRect.width_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.width_) - diffX);
360 } else if (startPointPosX >= hotZoneRect.posX_ + static_cast<int32_t>(hotZoneRect.width_)) {
361 if (diffX < 0 && (-diffX > static_cast<int32_t>(startPointRect.width_ - minWidth))) {
362 diffX = -(static_cast<int32_t>(startPointRect.width_ - minWidth));
363 }
364 newRect.width_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.width_) + diffX);
365 }
366 if (startPointPosY <= hotZoneRect.posY_) {
367 if (diffY > static_cast<int32_t>(startPointRect.height_ - minHeight)) {
368 diffY = static_cast<int32_t>(startPointRect.height_ - minHeight);
369 }
370 newRect.posY_ += diffY;
371 newRect.height_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.height_) - diffY);
372 } else if (startPointPosY >= hotZoneRect.posY_ + static_cast<int32_t>(hotZoneRect.height_)) {
373 if (diffY < 0 && (-diffY > static_cast<int32_t>(startPointRect.height_ - minHeight))) {
374 diffY = -(static_cast<int32_t>(startPointRect.height_ - minHeight));
375 }
376 newRect.height_ = static_cast<uint32_t>(static_cast<int32_t>(newRect.height_) + diffY);
377 }
378 }
379
HandleDragEvent(DisplayId displayId,int32_t posX,int32_t posY,int32_t pointId,int32_t sourceType)380 void MoveDragController::HandleDragEvent(DisplayId displayId, int32_t posX, int32_t posY,
381 int32_t pointId, int32_t sourceType)
382 {
383 if (moveDragProperty_ == nullptr || !moveDragProperty_->startDragFlag_ ||
384 (pointId != moveDragProperty_->startPointerId_) || (sourceType != moveDragProperty_->sourceType_)) {
385 return;
386 }
387
388 Rect newRect = moveDragProperty_->startPointRect_;
389 CalculateNewWindowRect(newRect, displayId, posX, posY);
390
391 if (!CheckWindowRect(displayId, DisplayGroupInfo::GetInstance().GetDisplayVirtualPixelRatio(displayId), newRect)) {
392 return;
393 }
394
395 WLOGFD("[WMS] HandleDragEvent, id: %{public}u, newRect: [%{public}d, %{public}d, %{public}d, %{public}d]",
396 windowProperty_->GetWindowId(), newRect.posX_, newRect.posY_, newRect.width_, newRect.height_);
397 windowProperty_->SetRequestRect(newRect);
398 windowProperty_->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
399 windowProperty_->SetDragType(moveDragProperty_->dragType_);
400 WindowManagerService::GetInstance().UpdateProperty(windowProperty_, PropertyChangeAction::ACTION_UPDATE_RECT, true);
401 }
402
HandleMoveEvent(DisplayId displayId,int32_t posX,int32_t posY,int32_t pointId,int32_t sourceType)403 void MoveDragController::HandleMoveEvent(DisplayId displayId, int32_t posX, int32_t posY,
404 int32_t pointId, int32_t sourceType)
405 {
406 if (moveDragProperty_ == nullptr) {
407 return;
408 }
409 if (!moveDragProperty_->startMoveFlag_ ||
410 (pointId != moveDragProperty_->startPointerId_) ||
411 (sourceType != moveDragProperty_->sourceType_)) {
412 return;
413 }
414 auto startPointPosX = moveDragProperty_->startPointPosX_;
415 auto startPointPosY = moveDragProperty_->startPointPosY_;
416 ConvertPointerPosToDisplayGroupPos(moveDragProperty_->targetDisplayId_, startPointPosX, startPointPosY);
417 int32_t targetX = moveDragProperty_->startPointRect_.posX_ + (posX - startPointPosX);
418 int32_t targetY = moveDragProperty_->startPointRect_.posY_ + (posY - startPointPosY);
419
420 const Rect& oriRect = moveDragProperty_->startPointRect_;
421 Rect newRect = { targetX, targetY, oriRect.width_, oriRect.height_ };
422 if (limitRectMap_.find(displayId) != limitRectMap_.end()) {
423 newRect.posY_ = std::max(newRect.posY_, limitRectMap_[displayId].posY_);
424 }
425 WLOGFD("[WMS] HandleMoveEvent, id: %{public}u, newRect: [%{public}d, %{public}d, %{public}d, %{public}d]",
426 windowProperty_->GetWindowId(), newRect.posX_, newRect.posY_, newRect.width_, newRect.height_);
427 windowProperty_->SetRequestRect(newRect);
428 windowProperty_->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
429 WindowManagerService::GetInstance().UpdateProperty(windowProperty_, PropertyChangeAction::ACTION_UPDATE_RECT, true);
430 }
431
HandlePointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)432 void MoveDragController::HandlePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
433 {
434 if (windowProperty_) {
435 windowProperty_->UpdatePointerEvent(pointerEvent);
436 }
437 MMI::PointerEvent::PointerItem pointerItem;
438 int32_t pointId = pointerEvent->GetPointerId();
439 int32_t sourceType = pointerEvent->GetSourceType();
440 if (!pointerEvent->GetPointerItem(pointId, pointerItem) ||
441 (sourceType == MMI::PointerEvent::SOURCE_TYPE_MOUSE &&
442 pointerEvent->GetButtonId() != MMI::PointerEvent::MOUSE_BUTTON_LEFT)) {
443 WLOGFW("invalid pointerEvent");
444 return;
445 }
446
447 int32_t pointPosX = pointerItem.GetDisplayX();
448 int32_t pointPosY = pointerItem.GetDisplayY();
449 int32_t action = pointerEvent->GetPointerAction();
450 int32_t targetDisplayId = pointerEvent->GetTargetDisplayId();
451 ConvertPointerPosToDisplayGroupPos(targetDisplayId, pointPosX, pointPosY);
452 switch (action) {
453 case MMI::PointerEvent::POINTER_ACTION_DOWN:
454 case MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN: {
455 if (pointId == moveDragProperty_->startPointerId_ && sourceType == moveDragProperty_->sourceType_) {
456 moveDragProperty_->startMoveFlag_ = false;
457 moveDragProperty_->startDragFlag_ = false;
458 }
459 WLOGFD("[Server Point Down]: windowId: %{public}u, pointId: %{public}d, sourceType: %{public}d, "
460 "hasPointStarted: %{public}d, startMove: %{public}d, startDrag: %{public}d, targetDisplayId: "
461 "%{public}d, pointPos: [%{public}d, %{public}d]", activeWindowId_, pointId, sourceType,
462 moveDragProperty_->pointEventStarted_, moveDragProperty_->startMoveFlag_,
463 moveDragProperty_->startDragFlag_, targetDisplayId, pointPosX, pointPosY);
464 break;
465 }
466 // ready to move or drag
467 case MMI::PointerEvent::POINTER_ACTION_MOVE: {
468 HandleMoveEvent(targetDisplayId, pointPosX, pointPosY, pointId, sourceType);
469 HandleDragEvent(targetDisplayId, pointPosX, pointPosY, pointId, sourceType);
470 break;
471 }
472 // End move or drag
473 case MMI::PointerEvent::POINTER_ACTION_UP:
474 case MMI::PointerEvent::POINTER_ACTION_BUTTON_UP:
475 case MMI::PointerEvent::POINTER_ACTION_CANCEL: {
476 WindowManagerService::GetInstance().NotifyWindowClientPointUp(activeWindowId_, pointerEvent);
477 WLOGFD("[Server Point Up/Cancel]: windowId: %{public}u, action: %{public}d, sourceType: %{public}d",
478 activeWindowId_, action, sourceType);
479 break;
480 }
481 default:
482 break;
483 }
484 }
485
SetDragProperty(const sptr<MoveDragProperty> & moveDragProperty)486 void MoveDragController::SetDragProperty(const sptr<MoveDragProperty>& moveDragProperty)
487 {
488 moveDragProperty_->CopyFrom(moveDragProperty);
489 }
490
SetWindowProperty(const sptr<WindowProperty> & windowProperty)491 void MoveDragController::SetWindowProperty(const sptr<WindowProperty>& windowProperty)
492 {
493 windowProperty_->CopyFrom(windowProperty);
494 }
495
GetMoveDragProperty() const496 const sptr<MoveDragProperty>& MoveDragController::GetMoveDragProperty() const
497 {
498 return moveDragProperty_;
499 }
500
GetWindowProperty() const501 const sptr<WindowProperty>& MoveDragController::GetWindowProperty() const
502 {
503 return windowProperty_;
504 }
505
ResetMoveOrDragState()506 void MoveDragController::ResetMoveOrDragState()
507 {
508 activeWindowId_ = INVALID_WINDOW_ID;
509 auto moveDragProperty = new MoveDragProperty();
510 SetDragProperty(moveDragProperty);
511 }
512
SetActiveWindowId(uint32_t activeWindowId)513 void MoveDragController::SetActiveWindowId(uint32_t activeWindowId)
514 {
515 activeWindowId_ = activeWindowId;
516 }
517
GetActiveWindowId() const518 uint32_t MoveDragController::GetActiveWindowId() const
519 {
520 return activeWindowId_;
521 }
522 }
523 }
524