/* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ROSEN_WINDOW_IMPL_H #define OHOS_ROSEN_WINDOW_IMPL_H #include #include #include "window.h" #include "window_property.h" namespace OHOS::AbilityRuntime { class Context; } namespace OHOS { namespace Rosen { union ColorParam { #if BIG_ENDIANNESS struct { uint8_t alpha; uint8_t red; uint8_t green; uint8_t blue; } argb; #else struct { uint8_t blue; uint8_t green; uint8_t red; uint8_t alpha; } argb; #endif uint32_t value; }; class WindowImpl : public Window { public: explicit WindowImpl(const sptr& option); ~WindowImpl(); static sptr Find(const std::string& id); static sptr GetTopWindowWithContext(const std::shared_ptr& context = nullptr); static sptr GetTopWindowWithId(uint32_t mainWinId); static std::vector> GetSubWindow(uint32_t parantId); static void UpdateConfigurationForAll(const std::shared_ptr& configuration); virtual std::shared_ptr GetSurfaceNode() const override; virtual Rect GetRect() const override; virtual Rect GetRequestRect() const override; virtual WindowType GetType() const override; virtual WindowMode GetMode() const override; virtual float GetAlpha() const override; virtual WindowState GetWindowState() const override; virtual WMError SetFocusable(bool isFocusable) override; virtual bool GetFocusable() const override; virtual WMError SetTouchable(bool isTouchable) override; virtual bool GetTouchable() const override; virtual const std::string& GetWindowName() const override; virtual uint32_t GetWindowId() const override; virtual uint32_t GetWindowFlags() const override; uint32_t GetRequestModeSupportInfo() const override; bool IsMainHandlerAvailable() const override; virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const override; virtual bool IsFullScreen() const override; virtual bool IsLayoutFullScreen() const override; virtual WMError SetWindowType(WindowType type) override; virtual WMError SetWindowMode(WindowMode mode) override; virtual void SetAlpha(float alpha) override; virtual void SetTransform(const Transform& trans) override; virtual WMError AddWindowFlag(WindowFlag flag) override; virtual WMError RemoveWindowFlag(WindowFlag flag) override; virtual WMError SetWindowFlags(uint32_t flags) override; virtual WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) override; virtual WMError SetLayoutFullScreen(bool status) override; virtual WMError SetFullScreen(bool status) override; virtual const Transform& GetTransform() const override; virtual WMError UpdateSurfaceNodeAfterCustomAnimation(bool isAdd) override; virtual WMError GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea) override; WMError Create(uint32_t parentId, const std::shared_ptr& context = nullptr); virtual WMError Destroy() override; virtual WMError Show(uint32_t reason = 0, bool withAnimation = false) override; virtual WMError Hide(uint32_t reason = 0, bool withAnimation = false) override; virtual WMError MoveTo(int32_t x, int32_t y) override; virtual WMError Resize(uint32_t width, uint32_t height) override; virtual WMError SetKeepScreenOn(bool keepScreenOn) override; virtual bool IsKeepScreenOn() const override; virtual WMError SetTurnScreenOn(bool turnScreenOn) override; virtual bool IsTurnScreenOn() const override; virtual WMError SetBackgroundColor(const std::string& color) override; virtual WMError SetTransparent(bool isTransparent) override; virtual bool IsTransparent() const override; virtual WMError SetBrightness(float brightness) override; virtual float GetBrightness() const override; virtual WMError SetCallingWindow(uint32_t windowId) override; virtual void SetPrivacyMode(bool isPrivacyMode) override; virtual bool IsPrivacyMode() const override; virtual void SetSystemPrivacyMode(bool isSystemPrivacyMode) override; virtual void DisableAppWindowDecor() override; virtual WMError BindDialogTarget(sptr targetToken) override; virtual void SetSnapshotSkip(bool isSkip) override; // window effect virtual WMError SetCornerRadius(float cornerRadius) override; virtual WMError SetShadowRadius(float radius) override; virtual WMError SetShadowColor(std::string color) override; virtual void SetShadowOffsetX(float offsetX) override; virtual void SetShadowOffsetY(float offsetY) override; virtual WMError SetBlur(float radius) override; virtual WMError SetBackdropBlur(float radius) override; virtual WMError SetBackdropBlurStyle(WindowBlurStyle blurStyle) override; virtual bool IsDecorEnable() const override; virtual WMError Maximize() override; virtual WMError Minimize() override; virtual WMError Recover() override; virtual WMError Close() override; virtual void StartMove() override; virtual WMError RequestFocus() const override; virtual bool IsFocused() const override; virtual void SetInputEventConsumer(const std::shared_ptr& inputEventConsumer) override; virtual bool RegisterLifeCycleListener(const sptr& listener) override; virtual bool RegisterWindowChangeListener(const sptr& listener) override; virtual bool UnregisterLifeCycleListener(const sptr& listener) override; virtual bool UnregisterWindowChangeListener(const sptr& listener) override; virtual bool RegisterAvoidAreaChangeListener(sptr& listener) override; virtual bool UnregisterAvoidAreaChangeListener(sptr& listener) override; virtual bool RegisterDragListener(const sptr& listener) override; virtual bool UnregisterDragListener(const sptr& listener) override; virtual bool RegisterDisplayMoveListener(sptr& listener) override; virtual bool UnregisterDisplayMoveListener(sptr& listener) override; virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override; virtual bool RegisterOccupiedAreaChangeListener(const sptr& listener) override; virtual bool UnregisterOccupiedAreaChangeListener(const sptr& listener) override; virtual bool RegisterTouchOutsideListener(const sptr& listener) override; virtual bool UnregisterTouchOutsideListener(const sptr& listener) override; virtual bool RegisterAnimationTransitionController(const sptr& listener) override; virtual bool RegisterScreenshotListener(const sptr& listener) override; virtual bool UnregisterScreenshotListener(const sptr& listener) override; virtual bool RegisterDialogTargetTouchListener(const sptr& listener) override; virtual bool UnregisterDialogTargetTouchListener(const sptr& listener) override; virtual void RegisterDialogDeathRecipientListener(const sptr& listener) override; virtual void UnregisterDialogDeathRecipientListener(const sptr& listener) override; virtual void SetAceAbilityHandler(const sptr& handler) override; virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override; virtual void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; virtual void ConsumePointerEvent(const std::shared_ptr& inputEvent) override; virtual void RequestVsync(const std::shared_ptr& vsyncCallback) override; virtual void UpdateConfiguration(const std::shared_ptr& configuration) override; void NotifyTouchDialogTarget() override; virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine, NativeValue* storage, bool isdistributed, AppExecFwk::Ability* ability) override; virtual std::string GetContentInfo() override; virtual const std::shared_ptr GetContext() const override; virtual Ace::UIContent* GetUIContent() const override; virtual void OnNewWant(const AAFwk::Want& want) override; virtual void SetRequestedOrientation(Orientation) override; virtual Orientation GetRequestedOrientation() override; virtual void SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel) override; virtual WMError SetTouchHotAreas(const std::vector& rects) override; virtual void GetRequestedTouchHotAreas(std::vector& rects) const override; virtual WMError SetAPPWindowLabel(const std::string& label) override; virtual WMError SetAPPWindowIcon(const std::shared_ptr& icon) override; // colorspace, gamut virtual bool IsSupportWideGamut() override; virtual void SetColorSpace(ColorSpace colorSpace) override; virtual ColorSpace GetColorSpace() override; virtual void DumpInfo(const std::vector& params, std::vector& info) override; virtual std::shared_ptr Snapshot() override; virtual WMError NotifyMemoryLevel(int32_t level) const override; virtual bool IsAllowHaveSystemSubWindow() override; private: static std::map>> windowMap_; static std::map>> subWindowMap_; sptr property_; WindowState state_ { WindowState::STATE_INITIAL }; std::string name_; std::unique_ptr uiContent_; }; } // namespace Rosen } // namespace OHOS #endif // OHOS_ROSEN_WINDOW_IMPL_H