• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #ifndef OHOS_WINDOW_ADAPTER_H
17 #define OHOS_WINDOW_ADAPTER_H
18 
19 #include <refbase.h>
20 #include <zidl/window_manager_agent_interface.h>
21 
22 #include "window.h"
23 #include "zidl/window_interface.h"
24 #include "singleton_delegator.h"
25 #include "window_property.h"
26 #include "wm_single_instance.h"
27 #include "zidl/window_manager_interface.h"
28 namespace OHOS {
29 namespace Rosen {
30 class WMSDeathRecipient : public IRemoteObject::DeathRecipient {
31 public:
32     virtual void OnRemoteDied(const wptr<IRemoteObject>& wptrDeath) override;
33 };
34 
35 class WindowAdapter {
36 WM_DECLARE_SINGLE_INSTANCE(WindowAdapter);
37 public:
38     virtual WMError CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& windowProperty,
39         std::shared_ptr<RSSurfaceNode> surfaceNode, uint32_t& windowId, const sptr<IRemoteObject>& token);
40     virtual WMError AddWindow(sptr<WindowProperty>& windowProperty);
41     virtual WMError RemoveWindow(uint32_t windowId);
42     virtual WMError DestroyWindow(uint32_t windowId);
43     virtual WMError RequestFocus(uint32_t windowId);
44     virtual WMError GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, AvoidArea& avoidRect);
45     virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId);
46     virtual void NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty,
47         sptr<MoveDragProperty>& moveDragProperty);
48     virtual void ProcessPointDown(uint32_t windowId, bool isPointDown = true);
49     virtual void ProcessPointUp(uint32_t windowId);
50     virtual void MinimizeAllAppWindows(DisplayId displayId);
51     virtual WMError ToggleShownStateForAllAppWindows();
52     virtual WMError SetWindowLayoutMode(WindowLayoutMode mode);
53     virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action);
54     virtual WMError GetSystemConfig(SystemConfig& systemConfig);
55     virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones);
56     virtual WMError UpdateRsTree(uint32_t windowId, bool isAdd);
57     virtual WMError BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken);
58     virtual bool RegisterWindowManagerAgent(WindowManagerAgentType type,
59         const sptr<IWindowManagerAgent>& windowManagerAgent);
60     virtual bool UnregisterWindowManagerAgent(WindowManagerAgentType type,
61         const sptr<IWindowManagerAgent>& windowManagerAgent);
62 
63     virtual WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller);
64     virtual WMError NotifyWindowTransition(sptr<WindowTransitionInfo> from, sptr<WindowTransitionInfo> to);
65     virtual WMError UpdateAvoidAreaListener(uint32_t windowId, bool haveListener);
66     virtual void ClearWindowAdapter();
67 
68     virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos);
69     virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos);
70     virtual void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
71         sptr<RSIWindowAnimationFinishedCallback>& finishCallback);
72     virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale);
73     virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY);
74     virtual void OffWindowZoom();
75     virtual std::shared_ptr<Media::PixelMap> GetSnapshot(int32_t windowId);
76     virtual void NotifyDumpInfoResult(const std::vector<std::string>& info);
77 private:
78     static inline SingletonDelegator<WindowAdapter> delegator;
79     bool InitWMSProxy();
80 
81     std::recursive_mutex mutex_;
82     sptr<IWindowManager> windowManagerServiceProxy_ = nullptr;
83     sptr<WMSDeathRecipient> wmsDeath_ = nullptr;
84     bool isProxyValid_ { false };
85 };
86 } // namespace Rosen
87 } // namespace OHOS
88 #endif // OHOS_WINDOW_ADAPTER_H
89