• 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, bool isFromInnerkits);
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 WMError 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 SetWindowGravity(uint32_t windowId, WindowGravity gravity, uint32_t percent);
55     virtual WMError GetSystemConfig(SystemConfig& systemConfig);
56     virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones);
57     virtual WMError UpdateRsTree(uint32_t windowId, bool isAdd);
58     virtual WMError BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken);
59     virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
60         const sptr<IWindowManagerAgent>& windowManagerAgent);
61     virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
62         const sptr<IWindowManagerAgent>& windowManagerAgent);
63 
64     virtual WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller);
65     virtual WMError NotifyWindowTransition(sptr<WindowTransitionInfo> from, sptr<WindowTransitionInfo> to);
66     virtual WMError UpdateAvoidAreaListener(uint32_t windowId, bool haveListener);
67     virtual void ClearWindowAdapter();
68 
69     virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos);
70     virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos);
71     virtual void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
72         sptr<RSIWindowAnimationFinishedCallback>& finishCallback);
73     virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale);
74     virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY);
75     virtual void OffWindowZoom();
76     virtual WmErrorCode RaiseToAppTop(uint32_t windowId);
77     virtual std::shared_ptr<Media::PixelMap> GetSnapshot(int32_t windowId);
78     virtual WMError SetGestureNavigaionEnabled(bool enable);
79     virtual void DispatchKeyEvent(uint32_t windowId, std::shared_ptr<MMI::KeyEvent> event);
80     virtual void NotifyDumpInfoResult(const std::vector<std::string>& info);
81     virtual WMError GetWindowAnimationTargets(std::vector<uint32_t> missionIds,
82         std::vector<sptr<RSWindowAnimationTarget>>& targets);
83     virtual void SetMaximizeMode(MaximizeMode maximizeMode);
84     virtual MaximizeMode GetMaximizeMode();
85     virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo);
86     virtual WMError UpdateSessionAvoidAreaListener(int32_t& persistentId, bool haveListener);
87 private:
88     static inline SingletonDelegator<WindowAdapter> delegator;
89     bool InitWMSProxy();
90     bool InitSSMProxy();
91 
92     std::recursive_mutex mutex_;
93     sptr<IWindowManager> windowManagerServiceProxy_ = nullptr;
94     sptr<WMSDeathRecipient> wmsDeath_ = nullptr;
95     bool isProxyValid_ { false };
96 };
97 } // namespace Rosen
98 } // namespace OHOS
99 #endif // OHOS_WINDOW_ADAPTER_H
100