1 /*
2  * Copyright (c) 2024 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 
16 #include "future_callback.h"
17 #include "window_manager_hilog.h"
18 
19 namespace OHOS {
20 namespace Rosen {
21 
OnUpdateSessionRect(const Rect & rect,WindowSizeChangeReason reason,int32_t persistentId)22 WSError FutureCallback::OnUpdateSessionRect(const Rect& rect, WindowSizeChangeReason reason,
23     int32_t persistentId)
24 {
25     TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, rect:%{public}s, reason:%{public}u",
26         persistentId, rect.ToString().c_str(), reason);
27     switch (reason) {
28         case WindowSizeChangeReason::MOVE:
29             moveToFuture_.SetValue(rect);
30             return WSError::WS_OK;
31         case WindowSizeChangeReason::RESIZE:
32             resizeFuture_.SetValue(rect);
33             return WSError::WS_OK;
34         default:
35             TLOGW(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, reason:%{public}u is not move or resize",
36                 persistentId, reason);
37     }
38     return WSError::WS_DO_NOTHING;
39 }
40 
GetResizeAsyncResult(long timeOut)41 Rect FutureCallback::GetResizeAsyncResult(long timeOut)
42 {
43     return resizeFuture_.GetResult(timeOut);
44 }
45 
GetMoveToAsyncResult(long timeOut)46 Rect FutureCallback::GetMoveToAsyncResult(long timeOut)
47 {
48     return moveToFuture_.GetResult(timeOut);
49 }
50 
ResetResizeLock()51 void FutureCallback::ResetResizeLock()
52 {
53     resizeFuture_.ResetLock({});
54 }
55 
ResetMoveToLock()56 void FutureCallback::ResetMoveToLock()
57 {
58     moveToFuture_.ResetLock({});
59 }
60 } // namespace Rosen
61 } // namespace OHOS