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 #ifndef OHOS_ROSEN_WINDOW_DISPLAY_CHANGE_ADAPTER_H
17 #define OHOS_ROSEN_WINDOW_DISPLAY_CHANGE_ADAPTER_H
18 
19 #include <refbase.h>
20 #include "display_manager.h"
21 #include "window_manager.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 class WindowDisplayChangeAdapter : public DisplayManager::IDisplayListener, public IDisplayInfoChangedListener {
26 public:
27     WindowDisplayChangeAdapter(const sptr<IRemoteObject>& token, const sptr<IDisplayInfoChangedListener>& listener);
28     ~WindowDisplayChangeAdapter();
29 
30 public:
31     void OnCreate(DisplayId displayId) override;
32     void OnDestroy(DisplayId displayId) override;
33     void OnChange(DisplayId displayId) override;
34 
35     void OnDisplayInfoChange(const sptr<IRemoteObject>& token,
36         DisplayId displayId, float density, DisplayOrientation orientation) override;
37 
38 public:
39     const sptr<IDisplayInfoChangedListener> GetListener() const;
40 
41 private:
42     const sptr<IRemoteObject> token_ { nullptr };
43     const sptr<IDisplayInfoChangedListener> displayInfoChangeListener_ { nullptr };
44     DisplayId displayId_ { 0 };
45     float density_ { 0.0f };
46     DisplayOrientation orientation_ { DisplayOrientation::UNKNOWN };
47 };
48 } // namespace Rosen
49 } // namespace OHOS
50 
51 #endif // OHOS_ROSEN_WINDOW_DISPLAY_CHANGE_ADAPTER_H
52