• 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 "wm_single_instance.h"
25 #include "singleton_delegator.h"
26 #include "window_property.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);
40     virtual WMError AddWindow(sptr<WindowProperty>& windowProperty);
41     virtual WMError RemoveWindow(uint32_t windowId);
42     virtual WMError DestroyWindow(uint32_t windowId);
43     virtual WMError SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId);
44     virtual WMError RequestFocus(uint32_t windowId);
45     virtual WMError GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, std::vector<Rect>& avoidRect);
46     virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level);
47     virtual WMError SetAlpha(uint32_t windowId, float alpha);
48     virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId);
49     virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag = false);
50     virtual void ProcessPointUp(uint32_t windowId);
51     virtual void MinimizeAllAppWindows(DisplayId displayId);
52     virtual WMError MaxmizeWindow(uint32_t windowId);
53     virtual WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode);
54     virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action);
55 
56     virtual void RegisterWindowManagerAgent(WindowManagerAgentType type,
57         const sptr<IWindowManagerAgent>& windowManagerAgent);
58     virtual void UnregisterWindowManagerAgent(WindowManagerAgentType type,
59         const sptr<IWindowManagerAgent>& windowManagerAgent);
60 
61     virtual void ClearWindowAdapter();
62 private:
63     static inline SingletonDelegator<WindowAdapter> delegator;
64     bool InitWMSProxy();
65 
66     std::recursive_mutex mutex_;
67     sptr<IWindowManager> windowManagerServiceProxy_ = nullptr;
68     sptr<WMSDeathRecipient> wmsDeath_ = nullptr;
69     bool isProxyValid_ { false };
70 };
71 } // namespace Rosen
72 } // namespace OHOS
73 #endif // OHOS_WINDOW_ADAPTER_H
74