1 /* 2 * Copyright (c) 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 ARK_DISPLAY_MANAGER_ADAPTER_H 17 #define ARK_DISPLAY_MANAGER_ADAPTER_H 18 #pragma once 19 20 #include "ohos_adapter/include/ark_display_adapter_vector.h" 21 22 #include "base/include/ark_web_base_ref_counted.h" 23 #include "base/include/ark_web_types.h" 24 25 namespace OHOS::ArkWeb { 26 27 /*--ark web(source=webcore)--*/ 28 class ArkDisplayListenerAdapter : public virtual ArkWebBaseRefCounted { 29 public: 30 /*--ark web()--*/ 31 virtual void OnCreate(uint64_t displayId) = 0; 32 33 /*--ark web()--*/ 34 virtual void OnDestroy(uint64_t displayId) = 0; 35 36 /*--ark web()--*/ 37 virtual void OnChange(uint64_t displayId) = 0; 38 }; 39 40 /*--ark web(source=webcore)--*/ 41 class ArkFoldStatusListenerAdapter : public virtual ArkWebBaseRefCounted { 42 public: 43 /** 44 * @Description: Folding state change. 45 * @Input: foldstatus:folding status,value range id 0-5 46 * 0 represents an unknown screen state, 47 * 1 represents fully expanded, 48 * 2 stands for using the home screen, 49 * 3 stands for the use of the secondary screen, 50 * 4 represents simultaneous use, 51 * @Since: 14001 52 */ 53 /*--ark web()--*/ 54 virtual void OnFoldStatusChanged(uint32_t foldstatus) = 0; 55 }; 56 57 /*--ark web(source=webview)--*/ 58 class ArkDisplayAdapter : public virtual ArkWebBaseRefCounted { 59 public: 60 /*--ark web()--*/ 61 virtual uint64_t GetId() = 0; 62 63 /*--ark web()--*/ 64 virtual int32_t GetWidth() = 0; 65 66 /*--ark web()--*/ 67 virtual int32_t GetHeight() = 0; 68 69 /*--ark web()--*/ 70 virtual float GetVirtualPixelRatio() = 0; 71 72 /*--ark web()--*/ 73 virtual uint32_t GetRotation() = 0; 74 75 /*--ark web()--*/ 76 virtual uint32_t GetOrientation() = 0; 77 78 /*--ark web()--*/ 79 virtual int32_t GetDpi() = 0; 80 81 /*--ark web()--*/ 82 virtual uint32_t GetDisplayOrientation() = 0; 83 84 /** 85 * @Description: Get folding status. 86 * @Return: folding status,value range id 0-5 87 * 0 represents an unknown screen state, 88 * 1 represents fully expanded, 89 * 2 stands for using the home screen, 90 * 3 stands for the use of the secondary screen, 91 * 4 represents simultaneous use, 92 * @Since: 14001 93 */ 94 /*--ark web()--*/ 95 virtual uint32_t GetFoldStatus() = 0; 96 97 /** 98 * @Description: Does the device support folding. 99 * @Return: Does it support folding. 100 * @Since: 14001 101 */ 102 /*--ark web()--*/ 103 virtual bool IsFoldable() = 0; 104 105 /** 106 * @Description: Get display name. 107 * @Return: Display name. 108 */ 109 /*--ark web()--*/ 110 virtual ArkWebString GetName() = 0; 111 112 /** 113 * @Description: Get display available width. 114 * @Return: Display available width. 115 */ 116 /*--ark web()--*/ 117 virtual int32_t GetAvailableWidth() = 0; 118 119 /** 120 * @Description: Get display available height. 121 * @Return: Display available height. 122 */ 123 /*--ark web()--*/ 124 virtual int32_t GetAvailableHeight() = 0; 125 126 /** 127 * @Description: Get display alive status. 128 * @Return: Display alive status. 129 */ 130 /*--ark web()--*/ 131 virtual bool GetAliveStatus() = 0; 132 133 /** 134 * @Description: Get display state. 135 * @Return: Display state. 136 */ 137 /*--ark web()--*/ 138 virtual uint32_t GetDisplayState() = 0; 139 140 /** 141 * @Description: Get density DPI. 142 * @Return: Density DPI. 143 */ 144 /*--ark web()--*/ 145 virtual int32_t GetDensityDpi() = 0; 146 147 /** 148 * @Description: Get display position X. 149 * @Return: Position X. 150 */ 151 /*--ark web()--*/ 152 virtual int32_t GetX() = 0; 153 154 /** 155 * @Description: Get display position Y. 156 * @Return: Position Y. 157 */ 158 /*--ark web()--*/ 159 virtual int32_t GetY() = 0; 160 161 /** 162 * @Description: Get display source mode. 163 * @Return: Display source mode. 164 */ 165 /*--ark web()--*/ 166 virtual uint32_t GetDisplaySourceMode() = 0; 167 168 /** 169 * @Description: Get display physical width. 170 * @Return: Display physical width. 171 */ 172 /*--ark web()--*/ 173 virtual int32_t GetPhysicalWidth() = 0; 174 175 /** 176 * @Description: Get display physical Height. 177 * @Return: Display physical height. 178 */ 179 /*--ark web()--*/ 180 virtual int32_t GetPhysicalHeight() = 0; 181 182 /** 183 * @Description: Get default virtual pixel ratio. 184 * @Return: Default virtual pixel ratio. 185 */ 186 /*--ark web()--*/ 187 virtual float GetDefaultVirtualPixelRatio() = 0; 188 }; 189 190 /*--ark web(source=webview)--*/ 191 class ArkDisplayManagerAdapter : public virtual ArkWebBaseRefCounted { 192 public: 193 /*--ark web()--*/ 194 virtual uint64_t GetDefaultDisplayId() = 0; 195 196 /*--ark web()--*/ 197 virtual ArkWebRefPtr<ArkDisplayAdapter> GetDefaultDisplay() = 0; 198 199 /*--ark web()--*/ 200 virtual uint32_t RegisterDisplayListener(ArkWebRefPtr<ArkDisplayListenerAdapter> listener) = 0; 201 202 /*--ark web()--*/ 203 virtual bool UnregisterDisplayListener(uint32_t id) = 0; 204 205 /*--ark web()--*/ 206 virtual bool IsDefaultPortrait() = 0; 207 208 /** 209 * @Description: Regist Fold Status Listener. 210 * @Input: ArkFoldStatusListenerAdapter object. 211 * @Return:folding status,value range id 0-5 212 * 0 represents an unknown screen state, 213 * 1 represents fully expanded, 214 * 2 stands for using the home screen, 215 * 3 stands for the use of the secondary screen, 216 * 4 represents simultaneous use, 217 * @Since: 14001 218 */ 219 /*--ark web()--*/ 220 virtual uint32_t RegisterFoldStatusListener(ArkWebRefPtr<ArkFoldStatusListenerAdapter> listener) = 0; 221 222 /** 223 * @Description: Unregist Fold Status Listener. 224 * @Input: Listener ID. 225 * @Return: return is or not success. 226 * @Since: 14001 227 */ 228 /*--ark web()--*/ 229 virtual bool UnregisterFoldStatusListener(uint32_t id) = 0; 230 231 /** 232 * @Description: Get primary display. 233 * @Return: Primary display. 234 */ 235 /*--ark web()--*/ 236 virtual ArkWebRefPtr<ArkDisplayAdapter> GetPrimaryDisplay() = 0; 237 238 /** 239 * @Description: Get all displays list. 240 * @Return: All displays list. 241 */ 242 /*--ark web()--*/ 243 virtual ArkDisplayAdapterVector GetAllDisplays() = 0; 244 }; 245 246 } // namespace OHOS::ArkWeb 247 248 #endif // ARK_DISPLAY_MANAGER_ADAPTER_H 249