预览需求框架

Change-Id: Iaef647093233559417fa77bb6acfcbcd0f4219c8
Signed-off-by: zhengjiangliang <zhengjiangliang@huawei.com>
This commit is contained in:
zhengjiangliang 2022-08-16 08:52:29 +08:00
parent d739de5582
commit 664b9448d1
43 changed files with 1877 additions and 666 deletions

View File

@ -16,41 +16,47 @@ import("//build/ohos.gni")
ohos_shared_library("previewer_shared") {
libs = []
sources = [
# js_window.cpp
"src/window.cpp",
"src/parcel.cpp",
sources = [
# js
"../../../../commonlibrary/c_utils/base/src/refbase.cpp",
"../interfaces/kits/napi/window_runtime/window_napi/js_window.cpp",
"../../../ability/ability_runtime/frameworks/native/runtime/js_runtime_utils.cpp",
"../interfaces/kits/napi/window_runtime/window_napi/js_window.cpp",
"../interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp",
"../wm/src/window_option.cpp",
# js_window_stage.cpp
"../interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp",
"../utils/src/window_property.cpp",
"../utils/src/window_transition_info.cpp",
"../utils/src/wm_math.cpp",
"../wm/src/input_transfer_station.cpp",
"../wm/src/vsync_station.cpp",
"../wm/src/window.cpp",
"../wm/src/window_input_channel.cpp",
"../wm/src/window_option.cpp",
"src/window_impl.cpp",
"src/window_scene.cpp",
"mock/ui/rs_node.cpp",
"mock/ui/rs_surface_node.cpp",
"mock/napi_remote_object.cpp",
"mock/js_window_register_manager.cpp",
"mock/pixel_map_napi.cpp",
"mock/window_manager.cpp",
"mock/accesstoken_kit.cpp",
"mock/ipc_skeleton.cpp",
# mock
"mock/js_transition_controller.cpp",
"mock/js_window_register_manager.cpp",
"mock/parcel.cpp",
"mock/pixel_map_napi.cpp",
"mock/ui/rs_node.cpp",
]
include_dirs = [
"./", #避免冲突的mock目录
"mock/", #mock目录
"src/", #window.h parcel.h window_scene.h
"mock/ui/", #rs_node.h rs_vector4.h
"../../../../commonlibrary/c_utils/base/include/", #refbase.h
"../../../ability/ability_runtime/interfaces/inner_api/runtime/include/", # js_runtime_utils.h
"../interfaces/kits/napi/window_runtime/window_napi/", #js_window_utils.h
"../interfaces/innerkits/wm/", #wm_common.h window_option.h
"../interfaces/innerkits/dm/", #dm_common.h
"../interfaces/kits/napi/window_runtime/window_stage_napi/", #js_window_stage.h
"./", # 避免冲突的mock目录
"mock/", # mock目录
"mock/ui/",
"mock/transaction/",
"include/",
"../wm/include/",
"../wm/include/zidl/",
"../utils/include/",
"../interfaces/innerkits/wm/",
"../interfaces/innerkits/dm/",
"../interfaces/kits/napi/window_runtime/window_napi/",
"../interfaces/kits/napi/window_runtime/window_stage_napi/",
"../../../ability/ability_runtime/interfaces/inner_api/runtime/include/",
"../../../../commonlibrary/c_utils/base/include/",
]
deps = [

View File

@ -0,0 +1,195 @@
/*
* 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 <map>
#include <ability_context.h>
#include <ui_content.h>
#include "window.h"
#include "window_property.h"
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<WindowOption>& option);
~WindowImpl();
static sptr<Window> Find(const std::string& id);
static sptr<Window> GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context>& context = nullptr);
static sptr<Window> GetTopWindowWithId(uint32_t mainWinId);
static std::vector<sptr<Window>> GetSubWindow(uint32_t parantId);
static void UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration);
virtual std::shared_ptr<RSSurfaceNode> 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(const std::string& parentName,
const std::shared_ptr<AbilityRuntime::Context>& 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<IRemoteObject> 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 void SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer) override;
virtual void RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
virtual void RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
virtual void UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
virtual void UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
virtual void RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
virtual void UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
virtual void RegisterDragListener(const sptr<IWindowDragListener>& listener) override;
virtual void UnregisterDragListener(const sptr<IWindowDragListener>& listener) override;
virtual void RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
virtual void UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override;
virtual void RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
virtual void UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
virtual void RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
virtual void UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
virtual void RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener) override;
virtual void RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
virtual void UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
virtual void RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
virtual void UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
virtual void RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
virtual void UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override;
virtual void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) override;
virtual void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& inputEvent) override;
virtual void RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback) override;
virtual void UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& 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<AbilityRuntime::Context> 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<Rect>& rects) override;
virtual void GetRequestedTouchHotAreas(std::vector<Rect>& rects) const override;
// colorspace, gamut
virtual bool IsSupportWideGamut() override;
virtual void SetColorSpace(ColorSpace colorSpace) override;
virtual ColorSpace GetColorSpace() override;
virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
virtual std::shared_ptr<Media::PixelMap> Snapshot() override;
virtual WMError NotifyMemoryLevel(int32_t level) const override;
private:
static std::map<std::string, std::pair<uint32_t, sptr<Window>>> windowMap_;
static std::map<uint32_t, std::vector<sptr<WindowImpl>>> subWindowMap_;
sptr<WindowProperty> property_;
WindowState state_ { WindowState::STATE_INITIAL };
std::string name_;
std::unique_ptr<Ace::UIContent> uiContent_;
};
} // namespace Rosen
} // namespace OHOS
#endif // OHOS_ROSEN_WINDOW_IMPL_H

View File

@ -17,32 +17,40 @@
#define INTERFACES_INNERKITS_WINDOW_SCENE_H
#include <refbase.h>
#include <iremote_object.h>
#include "window.h"
#include "window_option.h"
namespace OHOS::AppExecFwk {
class Configuration;
}
namespace OHOS {
namespace Rosen {
#ifdef CreateWindow
#undef CreateWindow
#endif
class WindowScene : public RefBase {
public:
WindowScene() = default;
~WindowScene();
WMError Init(DisplayId displayId, const std::shared_ptr<AbilityRuntime::Context>& context,
sptr<IWindowLifeCycle>& listener, sptr<WindowOption> option = nullptr);
sptr<Window> CreateWindow(const std::string& windowName, sptr<WindowOption>& option) const;
const sptr<Window>& GetMainWindow() const;
std::vector<sptr<Window>> GetSubWindow();
WMError GoDestroy();
void UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration);
private:
std::string GenerateMainWindowName(const std::shared_ptr<AbilityRuntime::Context>& context) const;
sptr<Window> mainWindow_ = nullptr;
static inline std::atomic<uint32_t> count { 0 };
static const std::string MAIN_WINDOW_ID;
static const DisplayId DEFAULT_DISPLAY_ID = 0;
DisplayId displayId_ = DEFAULT_DISPLAY_ID;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -11,4 +11,18 @@
* 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_ABILITY_RUNTIME_NATIVE_ABILITY_CONTEXT_H
#define OHOS_ABILITY_RUNTIME_NATIVE_ABILITY_CONTEXT_H
#include <map>
#include "context_container.h"
namespace OHOS {
namespace AppExecFwk {
class AbilityContext : public ContextContainer {
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_NATIVE_ABILITY_CONTEXT_H

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H
namespace OHOS {
namespace AppExecFwk {
enum class SupportWindowMode {
FULLSCREEN = 0,
SPLIT,
FLOATING,
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H

View File

@ -1,26 +0,0 @@
/*
* 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 ACCESS_TOKEN_DEF_H
#define ACCESS_TOKEN_DEF_H
namespace OHOS {
namespace Security {
namespace AccessToken {
typedef unsigned int AccessTokenID;
} // namespace AccessToken
} // namespace Security
} // namespace OHOS
#endif // ACCESS_TOKEN_DEF_H

View File

@ -17,18 +17,21 @@
#define INTERFACES_INNER_KITS_ACCESSTOKEN_KIT_H
#include <string>
#include <vector>
#include "access_token.h"
namespace OHOS {
namespace Security {
namespace AccessToken {
class AccessTokenKit {
public:
static int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName);
static int VerifyAccessToken(unsigned int tokenID, const std::string& permissionName)
{
return 0;
}
static int VerifyAccessToken(
AccessTokenID callerTokenID, AccessTokenID firstTokenID, const std::string& permissionName);
unsigned int callerTokenID, unsigned int firstTokenID, const std::string& permissionName)
{
return 0;
}
};
} // namespace AccessToken
} // namespace Security

View File

@ -13,7 +13,15 @@
* limitations under the License.
*/
#ifndef AXIS_EVENT_H
#define AXIS_EVENT_H
#include "input_event.h"
namespace OHOS {
namespace Rosen {
} // namespace Rosen
namespace MMI {
class AxisEvent : public InputEvent {
};
} // namespace MMI
} // namespace OHOS
#endif // AXIS_EVENT_H

View File

@ -16,7 +16,7 @@
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H
#include<map>
#include <map>
#include <string>
#include <vector>

View File

@ -13,37 +13,21 @@
* limitations under the License.
*/
#include "parcel.h"
#ifndef OHOS_ABILITY_BASE_CONFIGURATION_H
#define OHOS_ABILITY_BASE_CONFIGURATION_H
#include <string>
#include <vector>
#include <set>
namespace OHOS {
Parcelable::Parcelable()
{
}
namespace AppExecFwk {
class Configuration {
public:
Configuration();
Parcel::Parcel()
{
}
Parcel::~Parcel()
{
}
bool Parcel::WriteInt32(int32_t value)
{
return true;
}
bool Parcel::WriteUint32(uint32_t value)
{
return true;
}
bool Parcel::ReadInt32(int32_t &value)
{
return true;
}
bool Parcel::ReadUint32(uint32_t &value)
{
return true;
}
~Configuration();
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_ABILITY_BASE_CONFIGURATION_H

37
previewer/mock/context.h Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 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_ABILITY_RUNTIME_CONTEXT_H
#define OHOS_ABILITY_RUNTIME_CONTEXT_H
#include <memory>
namespace OHOS {
namespace AbilityRuntime {
class Context {
public:
Context() = default;
virtual ~Context() = default;
virtual std::string GetBundleName() const = 0;
};
} // namespace AbilityRuntime
namespace AppExecFwk {
class Context {
public:
Context() = default;
virtual ~Context() = default;
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_CONTEXT_H

View File

@ -11,4 +11,16 @@
* 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_ABILITY_RUNTIME_CONTEXT_CONTAINER_H
#define OHOS_ABILITY_RUNTIME_CONTEXT_CONTAINER_H
#include "context.h"
namespace OHOS {
namespace AppExecFwk {
class ContextContainer : public Context {
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_CONTEXT_CONTAINER_H

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 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_EVENTHANDLER_H
#define OHOS_EVENTHANDLER_H
#include <string>
#include <memory>
#include "event_queue.h"
#include "event_runner.h"
namespace OHOS {
namespace AppExecFwk {
class EventHandler {
public:
using Callback = std::function<void()>;
using Priority = EventQueue::Priority;
EventHandler() {};
explicit EventHandler(const std::shared_ptr<EventRunner> &runner = nullptr) {};
virtual ~EventHandler() {};
static std::shared_ptr<EventHandler> Current()
{
return nullptr;
}
void RemoveTask(const std::string &name)
{
return;
}
inline bool PostTask(const Callback &callback, const std::string &name = std::string(), int64_t delayTime = 0,
Priority priority = Priority::LOW)
{
return true;
}
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // OHOS_EVENTHANDLER_H

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 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 BASE_EVENTHANDLER_INTERFACES_INNER_API_EVENT_QUEUE_H
#define BASE_EVENTHANDLER_INTERFACES_INNER_API_EVENT_QUEUE_H
#include <list>
#include <map>
namespace OHOS {
namespace AppExecFwk {
class EventQueue final {
public:
enum class Priority : uint32_t {
IMMEDIATE = 0,
HIGH,
LOW,
IDLE,
};
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // #ifndef BASE_EVENTHANDLER_INTERFACES_INNER_API_EVENT_QUEUE_H

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 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 BASE_EVENTHANDLER_INTERFACES_INNER_API_EVENT_RUNNER_H
#define BASE_EVENTHANDLER_INTERFACES_INNER_API_EVENT_RUNNER_H
#include "event_queue.h"
namespace OHOS {
namespace AppExecFwk {
class EventRunner final {
public:
EventRunner() {};
virtual ~EventRunner() {};
static std::shared_ptr<EventRunner> Create(bool inNewThread = true)
{
return nullptr;
}
static std::shared_ptr<EventRunner> Create(const std::string &threadName)
{
return nullptr;
}
static inline std::shared_ptr<EventRunner> Create(const char *threadName)
{
return nullptr;
}
static std::shared_ptr<EventRunner> GetMainEventRunner()
{
return nullptr;
}
uint64_t GetThreadId()
{
return 0;
}
explicit EventRunner(bool deposit);
friend class EventHandler;
};
} // namespace AppExecFwk
} // namespace OHOS
#endif // #ifndef BASE_EVENTHANDLER_INTERFACES_INNER_API_EVENT_RUNNER_H

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 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 I_INPUT_EVENT_CONSUMER_H
#define I_INPUT_EVENT_CONSUMER_H
#include "axis_event.h"
#include "key_event.h"
#include "pointer_event.h"
namespace OHOS {
namespace MMI {
struct IInputEventConsumer {
public:
IInputEventConsumer() = default;
virtual ~IInputEventConsumer() = default;
virtual void OnInputEvent(std::shared_ptr<KeyEvent> keyEvent) const;
virtual void OnInputEvent(std::shared_ptr<PointerEvent> pointerEvent) const;
virtual void OnInputEvent(std::shared_ptr<AxisEvent> axisEvent) const;
};
} // namespace MMI
} // namespace OHOS
#endif // I_INPUT_EVENT_CONSUMER_H

View File

@ -13,21 +13,29 @@
* limitations under the License.
*/
#include "accesstoken_kit.h"
#ifndef INPUT_EVENT_H
#define INPUT_EVENT_H
#include "parcel.h"
namespace OHOS {
namespace Security {
namespace AccessToken {
int AccessTokenKit::VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName)
{
return 0;
}
namespace MMI {
class InputEvent {
public:
int32_t GetTargetWindowId() const
{
return 0;
}
int32_t GetAgentWindowId() const
{
return 0;
}
int AccessTokenKit::VerifyAccessToken(
AccessTokenID callerTokenID, AccessTokenID firstTokenID, const std::string& permissionName)
{
return 0;
}
} // namespace AccessToken
} // namespace Security
void MarkProcessed()
{
return;
}
};
} // namespace MMI
} // namespace OHOS
#endif // INPUT_EVENT_H

View File

@ -13,30 +13,31 @@
* limitations under the License.
*/
#ifndef OHOS_WM_INCLUDE_WM_HELPER_H
#define OHOS_WM_INCLUDE_WM_HELPER_H
#ifndef INPUT_MANAGER_H
#define INPUT_MANAGER_H
#include "i_input_event_consumer.h"
#include "event_handler.h"
namespace OHOS {
namespace Rosen {
class WindowHelper {
namespace MMI {
class InputManager : public AppExecFwk::EventHandler {
public:
static inline bool IsValidWindowMode(WindowMode mode)
void SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer)
{
return true;
return;
}
static inline bool IsSystemWindow(WindowType type)
void SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer,
std::shared_ptr<AppExecFwk::EventHandler> eventHandler)
{
return true;
return;
}
static inline bool LessNotEqual(double left, double right)
static InputManager *GetInstance()
{
return true;
return nullptr;
}
private:
WindowHelper() = default;
~WindowHelper() = default;
};
} // namespace MMI
} // namespace OHOS
} // namespace Rosen
#endif // OHOS_WM_INCLUDE_WM_HELPER_H
#endif // INPUT_MANAGER_H

View File

@ -13,11 +13,24 @@
* limitations under the License.
*/
#include "ipc_skeleton.h"
#ifndef FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_CONTROLLER_H
#define FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_CONTROLLER_H
#include <memory>
namespace OHOS {
uint32_t IPCSkeleton::GetCallingTokenID()
{
return 0;
}
} // namespace OHOS
namespace MiscServices {
class InputMethodController : public RefBase {
public:
static sptr<InputMethodController> GetInstance()
{
return nullptr;
}
bool dispatchKeyEvent(std::shared_ptr<MMI::KeyEvent> keyEvent)
{
return true;
}
};
} // namespace MiscServices
} // namespace OHOS
#endif // FRAMEWORKS_INPUTMETHOD_CONTROLLER_INCLUDE_INPUT_METHOD_CONTROLLER_H

View File

@ -24,7 +24,10 @@ public:
IPCSkeleton() = default;
~IPCSkeleton() = default;
static uint32_t GetCallingTokenID();
static uint32_t GetCallingTokenID()
{
return 0;
}
};
}
#endif // OHOS_IPC_IPC_SKELETON_H

View File

@ -1,14 +0,0 @@
/*
* Copyright (C) 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.
*/

View File

@ -16,12 +16,9 @@
#include "js_transition_controller.h"
namespace OHOS {
namespace Rosen {
JsTransitionController::JsTransitionController(NativeEngine& engine, std::shared_ptr<NativeReference> jsWin,
sptr<Window> window)
: engine_(engine), jsWin_(jsWin), windowToken_(window), weakRef_(wptr<JsTransitionController> (this))
{
NativeValue *objValue = engine_.CreateObject();
}
JsTransitionController::~JsTransitionController()
{

View File

@ -29,12 +29,6 @@ public:
void AnimationForShown() override;
void AnimationForHidden() override;
void SetJsController(std::shared_ptr<NativeReference> jsVal);
private:
NativeEngine& engine_;
std::weak_ptr<NativeReference> jsTransControllerObj_;
std::weak_ptr<NativeReference> jsWin_;
wptr<Window> windowToken_;
wptr<JsTransitionController> weakRef_ = nullptr;
};
}
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 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 KEY_EVENT_H
#define KEY_EVENT_H
#include "input_event.h"
namespace OHOS {
namespace MMI {
class KeyEvent : public InputEvent {
public:
static const int32_t KEYCODE_FN = 0;
static const int32_t KEYCODE_NUMPAD_RIGHT_PAREN = 1;
static const int32_t KEYCODE_0 = 2;
int32_t GetKeyCode() const
{
return 0;
}
};
} // namespace MMI
} // namespace OHOS
#endif // KEY_EVENT_H

View File

@ -1,24 +0,0 @@
/*
* Copyright (c) 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.
*/
#include "napi_remote_object.h"
namespace OHOS {
sptr<IRemoteObject> NAPI_ohos_rpc_getNativeRemoteObject(napi_env env, napi_value object)
{
return nullptr;
}
} // namespace OHOS

View File

@ -22,6 +22,9 @@
#include "refbase.h"
namespace OHOS {
sptr<IRemoteObject> NAPI_ohos_rpc_getNativeRemoteObject(napi_env env, napi_value object);
sptr<IRemoteObject> NAPI_ohos_rpc_getNativeRemoteObject(napi_env env, napi_value object)
{
return nullptr;
}
} // namespace OHOS
#endif // NAPI_IPC_OHOS_REMOTE_OBJECT_H

99
previewer/mock/parcel.cpp Normal file
View File

@ -0,0 +1,99 @@
/*
* Copyright (c) 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.
*/
#include "parcel.h"
namespace OHOS {
Parcelable::Parcelable()
{
}
Parcel::Parcel()
{
}
Parcel::~Parcel()
{
}
bool Parcel::WriteInt32(int32_t value)
{
return true;
}
bool Parcel::ReadInt32(int32_t &value)
{
return true;
}
int32_t Parcel::ReadInt32()
{
return 0;
}
bool Parcel::WriteUint32(uint32_t value)
{
return true;
}
bool Parcel::ReadUint32(uint32_t &value)
{
return true;
}
uint32_t Parcel::ReadUint32()
{
return 0;
}
bool Parcel::WriteUint64(uint64_t value)
{
return true;
}
uint64_t Parcel::ReadUint64()
{
return 0;
}
bool Parcel::WriteFloat(float value)
{
return true;
}
float Parcel::ReadFloat()
{
return 0;
}
bool Parcel::WriteString(const std::string &value)
{
return true;
}
const std::string Parcel::ReadString()
{
return "";
}
bool Parcel::WriteBool(bool value)
{
return true;
}
bool Parcel::ReadBool()
{
return true;
}
} // namespace OHOS

View File

@ -21,7 +21,6 @@
#include "refbase.h"
namespace OHOS {
class Parcel;
class Parcelable : public virtual RefBase {
@ -38,14 +37,46 @@ public:
Parcel();
virtual ~Parcel();
bool WriteInt32(int32_t value);
bool WriteUint32(uint32_t value);
bool ReadInt32(int32_t &value);
int32_t ReadInt32();
bool WriteUint32(uint32_t value);
bool ReadUint32(uint32_t &value);
uint32_t ReadUint32();
bool WriteUint64(uint64_t value);
uint64_t ReadUint64();
bool WriteFloat(float value);
float ReadFloat();
bool WriteString(const std::string &value);
const std::string ReadString();
bool WriteBool(bool value);
bool ReadBool();
template<typename T>
bool WriteObject(const sptr<T> &object)
{
return true;
}
template <typename T>
sptr<T> ReadObject()
{
return nullptr;
}
};
} // namespace OHOS
#endif // OHOS_UTILS_PARCEL_H

View File

@ -31,9 +31,6 @@ public:
napi_env getEnv();
napi_ref getWrapper();
private:
static thread_local napi_ref sConstructor_;
static std::shared_ptr<PixelMap> sPixelMap_;
napi_env env_ = nullptr;
napi_ref wrapper_ = nullptr;
};

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 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 POINTER_EVENT_H
#define POINTER_EVENT_H
#include <array>
#include <list>
#include <memory>
#include <ostream>
#include <set>
#include <vector>
#include "input_event.h"
namespace OHOS {
namespace MMI {
class PointerEvent : public InputEvent {
public:
static constexpr int32_t POINTER_ACTION_UNKNOWN = 0;
static constexpr int32_t POINTER_ACTION_CANCEL = 1;
static constexpr int32_t POINTER_ACTION_DOWN = 2;
static constexpr int32_t POINTER_ACTION_MOVE = 3;
static constexpr int32_t POINTER_ACTION_UP = 4;
static constexpr int32_t POINTER_ACTION_AXIS_BEGIN = 5;
static constexpr int32_t POINTER_ACTION_AXIS_UPDATE = 6;
static constexpr int32_t POINTER_ACTION_AXIS_END = 7;
static constexpr int32_t POINTER_ACTION_BUTTON_DOWN = 8;
static constexpr int32_t POINTER_ACTION_BUTTON_UP = 9;
static constexpr int32_t POINTER_ACTION_ENTER_WINDOW = 10;
static constexpr int32_t POINTER_ACTION_LEAVE_WINDOW = 11;
int32_t GetPointerAction() const
{
return 0;
}
};
} // namespace MMI
} // namespace OHOS
#endif // POINTER_EVENT_H

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 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 RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H
#define RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H
#include <memory>
#include <windows.h>
#include <process.h>
namespace OHOS {
namespace Rosen {
class RSInterfaces {
public:
static RSInterfaces &GetInstance()
{
static RSInterfaces instance;
return instance;
};
std::shared_ptr<VSyncReceiver> CreateVSyncReceiver(
const std::string& name, const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper = nullptr)
{
return nullptr;
}
private:
RSInterfaces() = default;
~RSInterfaces() noexcept {};
};
} // namespace Rosen
} // namespace OHOS
#endif // RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H

View File

@ -41,6 +41,14 @@ void RSNode::SetRotation(const Quaternion& quaternion)
{
}
void RSNode::SetRotationX(float degree)
{
}
void RSNode::SetRotationY(float degree)
{
}
void RSNode::SetTranslateX(float translate)
{
}

View File

@ -26,9 +26,11 @@ public:
void SetScaleX(float scaleX);
void SetScaleY(float scaleY);
void SetRotation(float degree);
void SetRotation(const Quaternion& quaternion);
void SetRotationX(float degree);
void SetRotationY(float degree);
void SetTranslateX(float translate);
void SetTranslateY(float translate);

View File

@ -16,6 +16,7 @@
#define RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_NODE_H
#include "ui/rs_node.h"
namespace OHOS {
namespace Rosen {
class RSSurfaceNode : public RSNode {

View File

@ -18,12 +18,14 @@
namespace OHOS {
namespace Rosen {
class Vector4 {
};
class Quaternion {
public:
Quaternion(float x, float y, float z, float w) : myx(x), myy(y), myz(z), myw(w) {}
int useXYZW()
{
return myx+myy+myz+myw;
return myx + myy + myz + myw;
};
private:
float myx;

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 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 FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_CONTENT_H
#define FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_CONTENT_H
#include <memory>
#include <string>
namespace OHOS {
namespace AppExecFwk {
class Configuration;
class Ability;
}
namespace Rosen {
class Window;
enum class WindowMode : uint32_t;
}
namespace AAFwk {
class Want;
}
namespace MMI {
class PointerEvent;
class KeyEvent;
class AxisEvent;
} // namespace MMI
} // namespace OHOS
class NativeEngine;
class NativeValue;
namespace OHOS::Ace {
#define ACE_EXPORT __attribute__((visibility("default")))
class ACE_EXPORT UIContent {
public:
static std::unique_ptr<UIContent> Create(OHOS::AbilityRuntime::Context* context, NativeEngine* runtime);
static std::unique_ptr<UIContent> Create(OHOS::AppExecFwk::Ability* ability);
static void ShowDumpHelp(std::vector<std::string>& info);
virtual ~UIContent() = default;
// UI content life-cycles
virtual void Initialize(OHOS::Rosen::Window* window, const std::string& url, NativeValue* storage) = 0;
virtual void Foreground() = 0;
virtual void Background() = 0;
virtual void Focus() = 0;
virtual void UnFocus() = 0;
virtual void Destroy() = 0;
virtual void OnNewWant(const OHOS::AAFwk::Want& want) = 0;
// distribute
virtual void Restore(OHOS::Rosen::Window* window, const std::string& contentInfo, NativeValue* storage) = 0;
virtual std::string GetContentInfo() const = 0;
virtual void DestroyUIDirector() = 0;
// UI content event process
virtual bool ProcessBackPressed() = 0;
virtual bool ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) = 0;
virtual bool ProcessKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent) = 0;
virtual bool ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) = 0;
virtual bool ProcessVsyncEvent(uint64_t timeStampNanos) = 0;
virtual void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) = 0;
virtual void UpdateWindowMode(OHOS::Rosen::WindowMode mode) = 0;
virtual void HideWindowTitleButton(bool hideSplit, bool hideMaximize, bool hideMinimize) = 0;
// Window color
virtual uint32_t GetBackgroundColor() = 0;
virtual void SetBackgroundColor(uint32_t color) = 0;
virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
// Set UIContent callback for custom window animation
virtual void SetNextFrameLayoutCallback(std::function<void()>&& callback) = 0;
// Receive memory level notification
virtual void NotifyMemoryLevel(int32_t level) = 0;
};
} // namespace OHOS::Ace
#endif // FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_CONTENT_H

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 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 VSYNC_VSYNC_RECEIVER_H
#define VSYNC_VSYNC_RECEIVER_H
#include <mutex>
#include <refbase.h>
namespace OHOS {
namespace Rosen {
enum VsyncError {
GSERROR_OK = 0,
};
class VSyncCallBackListener {
public:
using VSyncCallback = std::function<void(int64_t, void*)>;
struct FrameCallback {
void *userData_;
VSyncCallback callback_;
};
};
class VSyncReceiver : public RefBase {
public:
using FrameCallback = VSyncCallBackListener::FrameCallback;
VsyncError Init()
{
return GSERROR_OK;
}
VsyncError RequestNextVSync(FrameCallback callback)
{
return GSERROR_OK;
}
};
} // namespace Rosen
} // namespace OHOS
#endif

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 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_ABILITY_RUNTIME_WINDOW_INFO_H
#define OHOS_ABILITY_RUNTIME_WINDOW_INFO_H
#include "parcel.h"
namespace OHOS {
namespace AAFwk {
struct AbilityTransitionInfo : public Parcelable {
std::string bundleName_;
std::string abilityName_;
uint32_t mode_ = 0;
std::vector<AppExecFwk::SupportWindowMode> windowModes_;
sptr<IRemoteObject> abilityToken_ = nullptr;
uint64_t displayId_ = 0;
bool isShowWhenLocked_ = false;
bool isRecent_ = false;
double maxWindowRatio_;
double minWindowRatio_;
uint32_t maxWindowWidth_;
uint32_t minWindowWidth_;
uint32_t maxWindowHeight_;
uint32_t minWindowHeight_;
virtual bool Marshalling(Parcel& parcel) const override
{
return true;
}
bool WriteWindowInfo(Parcel& parcel) const
{
return true;
}
static AbilityTransitionInfo* Unmarshalling(Parcel& parcel)
{
return nullptr;
}
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_WINDOW_INFO_H

View File

@ -33,7 +33,6 @@ struct SystemBarRegionTint {
};
using SystemBarRegionTints = std::vector<SystemBarRegionTint>;
class WindowManager {
};
} // namespace Rosen

View File

@ -16,6 +16,7 @@
#ifndef OHOS_WM_INCLUDE_WINDOW_MANAGER_HILOG_H
#define OHOS_WM_INCLUDE_WINDOW_MANAGER_HILOG_H
#include "window_input_channel.h"
namespace OHOS {
namespace Rosen {
typedef enum {

View File

@ -1,469 +0,0 @@
/*
* Copyright (c) 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_H
#define OHOS_ROSEN_WINDOW_H
#include <refbase.h>
#include <parcel.h>
#include <pixel_map.h>
#include <iremote_object.h>
#include "wm_common.h"
#include "window_option.h"
class NativeValue;
class NativeEngine;
namespace OHOS::MMI {
class PointerEvent;
class KeyEvent;
class AxisEvent;
}
namespace OHOS::AppExecFwk {
class Configuration;
class Ability;
}
namespace OHOS::AbilityRuntime {
class AbilityContext;
class Context;
}
namespace OHOS::AAFwk {
class Want;
}
namespace OHOS::Ace {
class UIContent;
}
namespace OHOS {
namespace Rosen {
using NotifyNativeWinDestroyFunc = std::function<void(std::string windowName)>;
class RSSurfaceNode;
class IWindowLifeCycle : virtual public RefBase {
public:
virtual void AfterForeground() = 0;
virtual void AfterBackground() = 0;
virtual void AfterFocused() = 0;
virtual void AfterUnfocused() = 0;
virtual void ForegroundFailed() {}
virtual void ForegroundInvalidMode() {}
virtual void AfterActive() {}
virtual void AfterInactive() {}
};
class IWindowChangeListener : virtual public RefBase {
public:
virtual void OnSizeChange(Rect rect, WindowSizeChangeReason reason) = 0;
virtual void OnModeChange(WindowMode mode) = 0;
};
class IAvoidAreaChangedListener : virtual public RefBase {
public:
virtual void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) = 0;
};
class IWindowDragListener : virtual public RefBase {
public:
virtual void OnDrag(int32_t x, int32_t y, DragEvent event) = 0;
};
class IDisplayMoveListener : virtual public RefBase {
public:
virtual void OnDisplayMove(DisplayId from, DisplayId to) = 0;
};
class IDispatchInputEventListener : virtual public RefBase {
public:
virtual void OnDispatchPointerEvent(std::shared_ptr<MMI::PointerEvent>& inputEvent) = 0;
virtual void OnDispatchKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent) = 0;
};
class OccupiedAreaChangeInfo : public Parcelable {
public:
OccupiedAreaChangeInfo() = default;
OccupiedAreaChangeInfo(OccupiedAreaType type, Rect rect) : type_(type), rect_(rect) {};
~OccupiedAreaChangeInfo() = default;
virtual bool Marshalling(Parcel& parcel) const override;
static OccupiedAreaChangeInfo* Unmarshalling(Parcel& parcel);
OccupiedAreaType type_ = OccupiedAreaType::TYPE_INPUT;
Rect rect_ = { 0, 0, 0, 0 };
};
class IOccupiedAreaChangeListener : virtual public RefBase {
public:
virtual void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info) = 0;
};
class IAceAbilityHandler : virtual public RefBase {
public:
virtual void SetBackgroundColor(uint32_t color) = 0;
virtual uint32_t GetBackgroundColor() = 0;
};
class IInputEventConsumer {
public:
IInputEventConsumer() = default;
virtual ~IInputEventConsumer() = default;
virtual bool OnInputEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const = 0;
virtual bool OnInputEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const = 0;
virtual bool OnInputEvent(const std::shared_ptr<MMI::AxisEvent>& axisEvent) const = 0;
};
class ITouchOutsideListener : virtual public RefBase {
public:
virtual void OnTouchOutside() const = 0;
};
class IAnimationTransitionController : virtual public RefBase {
public:
virtual void AnimationForShown() = 0;
virtual void AnimationForHidden() = 0;
};
class IScreenshotListener : virtual public RefBase {
public:
virtual void OnScreenshot() = 0;
};
class IDialogTargetTouchListener : virtual public RefBase {
public:
virtual void OnDialogTargetTouch() const = 0;
};
class IDialogDeathRecipientListener : virtual public RefBase {
public:
virtual void OnDialogDeathRecipient() const = 0;
};
class Window : public RefBase {
public:
/**
* @brief create window, include main_window/sub_window/system_window
*
* @param windowName window name, identify window instance
* @param option window propertion
* @param context ability context
* @return sptr<Window> If create window success,return window instance;Otherwise, return nullptr
*/
static sptr<Window> Create(const std::string& windowName,
sptr<WindowOption>& option, const std::shared_ptr<AbilityRuntime::Context>& context = nullptr);
/**
* @brief find window by windowName
*
* @param windowName
* @return sptr<Window> Return the window instance founded
*/
static sptr<Window> Find(const std::string& windowName);
/**
* @brief Get the final show window by context. Its implemented in api8
*
* @param context Indicates the context on which the window depends
* @return sptr<Window>
*/
static sptr<Window> GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context>& context = nullptr);
/**
* @brief Get the final show window by id. Its implemented in api8
*
* @param mainWinId main window id?
* @return sptr<Window>
*/
static sptr<Window> GetTopWindowWithId(uint32_t mainWinId);
/**
* @brief Get the all sub windows by parent
*
* @param parentId parent window id
* @return std::vector<sptr<Window>>
*/
static std::vector<sptr<Window>> GetSubWindow(uint32_t parentId);
/**
* @brief Update configuration for all windows
*
* @param configuration configuration for app
*/
static void UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration);
virtual std::shared_ptr<RSSurfaceNode> GetSurfaceNode() const = 0;
virtual const std::shared_ptr<AbilityRuntime::Context> GetContext() const = 0;
/**
* @brief Get the window show rect
*
* @return Rect window rect
*/
virtual Rect GetRect() const = 0;
virtual Rect GetRequestRect() const = 0;
/**
* @brief Get the window type
*
* @return WindowType window type
*/
virtual WindowType GetType() const = 0;
virtual WindowMode GetMode() const = 0;
virtual float GetAlpha() const = 0;
virtual const std::string& GetWindowName() const = 0;
virtual uint32_t GetWindowId() const = 0;
virtual uint32_t GetWindowFlags() const = 0;
virtual WindowState GetWindowState() const = 0;
virtual WMError SetFocusable(bool isFocusable) = 0;
virtual bool GetFocusable() const = 0;
virtual WMError SetTouchable(bool isTouchable) = 0;
virtual bool GetTouchable() const = 0;
virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const = 0;
/**
* @brief judge this window is full screen.
*
* @return true If SetFullScreen(true) is called , return true.
* @return false default return false
*/
virtual bool IsFullScreen() const = 0;
/**
* @brief judge window layout is full screen
*
* @return true this window layout is full screen
* @return false this window layout is not full screen
*/
virtual bool IsLayoutFullScreen() const = 0;
/**
* @brief Set the Window Type
*
* @param type window type
* @return WMError
*/
virtual WMError SetWindowType(WindowType type) = 0;
/**
* @brief Set the Window Mode
*
* @param mode window mode
* @return WMError
*/
virtual WMError SetWindowMode(WindowMode mode) = 0;
virtual void SetAlpha(float alpha) = 0;
virtual void SetTransform(const Transform& trans) = 0;
virtual Transform GetTransform() const = 0;
virtual WMError AddWindowFlag(WindowFlag flag) = 0;
virtual WMError RemoveWindowFlag(WindowFlag flag) = 0;
virtual WMError SetWindowFlags(uint32_t flags) = 0;
/**
* @brief Set the System Bar(include status bar and nav bar) Property
*
* @param type WINDOW_TYPE_STATUS_BAR or WINDOW_TYPE_NAVIGATION_BAR
* @param property system bar prop,include content color, background color
* @return WMError
*/
virtual WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) = 0;
/**
* @brief Get the Avoid Area By Type object
*
* @param type avoid area type.@see reference
* @param avoidArea
* @return WMError
*/
virtual WMError GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea) = 0;
/**
* @brief Set this window layout full screen, with hide status bar and nav bar above on this window
*
* @param status
* @return WMError
*/
virtual WMError SetLayoutFullScreen(bool status) = 0;
/**
* @brief Set this window full screen, with hide status bar and nav bar
*
* @param status if true, hide status bar and nav bar; Otherwise, show status bar and nav bar
* @return WMError
*/
virtual WMError SetFullScreen(bool status) = 0;
/**
* @brief destroy window
*
* @return WMError
*/
virtual WMError Destroy() = 0;
virtual WMError Show(uint32_t reason = 0, bool withAnimation = false) = 0;
virtual WMError Hide(uint32_t reason = 0, bool withAnimation = false) = 0;
/**
* @brief move the window to (x, y)
*
* @param x
* @param y
* @return WMError
*/
virtual WMError MoveTo(int32_t x, int32_t y) = 0;
/**
* @brief resize the window instance (w,h)
*
* @param width
* @param height
* @return WMError
*/
virtual WMError Resize(uint32_t width, uint32_t height) = 0;
/**
* @brief Set the screen always on
*
* @param keepScreenOn
* @return WMError
*/
virtual WMError SetKeepScreenOn(bool keepScreenOn) = 0;
virtual bool IsKeepScreenOn() const = 0;
virtual WMError SetTurnScreenOn(bool turnScreenOn) = 0;
virtual bool IsTurnScreenOn() const = 0;
virtual WMError SetBackgroundColor(const std::string& color) = 0;
virtual WMError SetTransparent(bool isTransparent) = 0;
virtual bool IsTransparent() const = 0;
virtual WMError SetBrightness(float brightness) = 0;
virtual float GetBrightness() const = 0;
virtual WMError SetCallingWindow(uint32_t windowId) = 0;
virtual void SetPrivacyMode(bool isPrivacyMode) = 0;
virtual bool IsPrivacyMode() const = 0;
virtual WMError BindDialogTarget(sptr<IRemoteObject> targetToken) = 0;
virtual void SetSnapshotSkip(bool isSkip) = 0;
// window effect
virtual WMError SetCornerRadius(float cornerRadius) = 0;
virtual WMError SetShadowRadius(float radius) = 0;
virtual WMError SetShadowColor(std::string color) = 0;
virtual void SetShadowOffsetX(float offsetX) = 0;
virtual void SetShadowOffsetY(float offsetY) = 0;
virtual WMError SetBlur(float radius) = 0;
virtual WMError SetBackdropBlur(float radius) = 0;
virtual WMError SetBackdropBlurStyle(WindowBlurStyle blurStyle) = 0;
virtual WMError RequestFocus() const = 0;
virtual WMError UpdateSurfaceNodeAfterCustomAnimation(bool isAdd) = 0;
virtual void SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer) = 0;
virtual void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) = 0;
virtual void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& inputEvent) = 0;
virtual void UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration) = 0;
/**
* @brief register window lifecycle listener.
*
* @param listener
*/
virtual void RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;
virtual void RegisterWindowChangeListener(sptr<IWindowChangeListener>& listener) = 0;
virtual void UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) = 0;
virtual void UnregisterWindowChangeListener(sptr<IWindowChangeListener>& listener) = 0;
virtual void RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
virtual void UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) = 0;
virtual void RegisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
virtual void UnregisterDragListener(const sptr<IWindowDragListener>& listener) = 0;
virtual void RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
virtual void UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) = 0;
virtual void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) = 0;
virtual void RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
virtual void UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) = 0;
virtual void RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) = 0;
virtual void UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) = 0;
virtual void RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener) = 0;
virtual void RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) = 0;
virtual void UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) = 0;
virtual void RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) = 0;
virtual void UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) = 0;
virtual void RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) = 0;
virtual void UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) = 0;
virtual void NotifyTouchDialogTarget() = 0;
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) = 0;
/**
* @brief set window ui content
*
* @param contentInfo content info path
* @param engine
* @param storage
* @param isDistributed
* @param ability
* @return WMError
*/
virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine,
NativeValue* storage, bool isDistributed = false, AppExecFwk::Ability* ability = nullptr) = 0;
virtual std::string GetContentInfo() = 0;
virtual Ace::UIContent* GetUIContent() const = 0;
virtual void OnNewWant(const AAFwk::Want& want) = 0;
virtual void SetRequestedOrientation(Orientation) = 0;
virtual Orientation GetRequestedOrientation() = 0;
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0;
virtual uint32_t GetRequestModeSupportInfo() const = 0;
virtual WMError SetTouchHotAreas(const std::vector<Rect>& rects) = 0;
virtual void GetRequestedTouchHotAreas(std::vector<Rect>& rects) const = 0;
/**
* @brief disable main window decoration. It must be callled before loadContent.
*
*/
virtual void DisableAppWindowDecor() = 0;
/**
* @brief return window decoration is enabled. It is called by ACE
*
* @return true means window decoration is enabled. Otherwise disabled
*/
virtual bool IsDecorEnable() const = 0;
/**
* @brief maximize the main window. It is called by ACE when maximize button is clicked.
*
* @return WMError
*/
virtual WMError Maximize() = 0;
/**
* @brief minimize the main window. It is called by ACE when minimize button is clicked.
*
* @return WMError
*/
virtual WMError Minimize() = 0;
/**
* @brief recovery the main window. It is called by ACE when recovery button is clicked.
*
* @return WMError
*/
virtual WMError Recover() = 0;
/**
* @brief close the main window. It is called by ACE when close button is clicked.
*
* @return WMError
*/
virtual WMError Close() = 0;
/**
* @brief start move main window. It is called by ACE when title is moved.
*
*/
virtual void StartMove() = 0;
virtual void SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel) = 0;
// colorspace, gamut
virtual bool IsSupportWideGamut() = 0;
virtual void SetColorSpace(ColorSpace colorSpace) = 0;
virtual ColorSpace GetColorSpace() = 0;
virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
/**
* @brief window snapshot
*
* @return std::shared_ptr<Media::PixelMap> snapshot pixel
*/
virtual std::shared_ptr<Media::PixelMap> Snapshot() = 0;
/**
* @brief Handle and notify memory level.
*
* @param level memory level
* @return the error code of window
*/
virtual WMError NotifyMemoryLevel(int32_t level) const = 0;
};
}
}
#endif // OHOS_ROSEN_WINDOW_H

View File

@ -0,0 +1,693 @@
/*
* Copyright (c) 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.
*/
#include "window_impl.h"
#include "window_manager_hilog.h"
namespace OHOS {
namespace Rosen {
std::map<std::string, std::pair<uint32_t, sptr<Window>>> WindowImpl::windowMap_;
std::map<uint32_t, std::vector<sptr<WindowImpl>>> WindowImpl::subWindowMap_;
static int constructorCnt = 0;
static int deConstructorCnt = 0;
WindowImpl::WindowImpl(const sptr<WindowOption>& option)
{
property_ = new (std::nothrow) WindowProperty();
property_->SetWindowName(option->GetWindowName());
property_->SetRequestRect(option->GetWindowRect());
property_->SetWindowType(option->GetWindowType());
property_->SetWindowMode(option->GetWindowMode());
property_->SetFullScreen(option->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN);
property_->SetFocusable(option->GetFocusable());
property_->SetTouchable(option->GetTouchable());
property_->SetDisplayId(option->GetDisplayId());
property_->SetCallingWindow(option->GetCallingWindow());
property_->SetWindowFlags(option->GetWindowFlags());
property_->SetHitOffset(option->GetHitOffset());
property_->SetRequestedOrientation(option->GetRequestedOrientation());
property_->SetTurnScreenOn(option->IsTurnScreenOn());
property_->SetKeepScreenOn(option->IsKeepScreenOn());
property_->SetBrightness(option->GetBrightness());
auto& sysBarPropMap = option->GetSystemBarProperty();
for (auto it : sysBarPropMap) {
property_->SetSystemBarProperty(it.first, it.second);
}
name_ = option->GetWindowName();
WLOGFI("WindowImpl constructorCnt: %{public}d name: %{public}s",
++constructorCnt, property_->GetWindowName().c_str());
}
WindowImpl::~WindowImpl()
{
WLOGFI("windowName: %{public}s, windowId: %{public}d, deConstructorCnt: %{public}d",
GetWindowName().c_str(), GetWindowId(), ++deConstructorCnt);
Destroy();
}
sptr<Window> WindowImpl::Find(const std::string& name)
{
return nullptr;
}
const std::shared_ptr<AbilityRuntime::Context> WindowImpl::GetContext() const
{
return nullptr;
}
sptr<Window> WindowImpl::GetTopWindowWithId(uint32_t mainWinId)
{
return nullptr;
}
sptr<Window> WindowImpl::GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context>& context)
{
return nullptr;
}
std::vector<sptr<Window>> WindowImpl::GetSubWindow(uint32_t parentId)
{
if (subWindowMap_.find(parentId) == subWindowMap_.end()) {
WLOGFE("Cannot parentWindow with id: %{public}u!", parentId);
return std::vector<sptr<Window>>();
}
return std::vector<sptr<Window>>(subWindowMap_[parentId].begin(), subWindowMap_[parentId].end());
}
void WindowImpl::UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
{
return;
}
std::shared_ptr<RSSurfaceNode> WindowImpl::GetSurfaceNode() const
{
return nullptr;
}
Rect WindowImpl::GetRect() const
{
return property_->GetWindowRect();
}
Rect WindowImpl::GetRequestRect() const
{
return property_->GetRequestRect();
}
WindowType WindowImpl::GetType() const
{
return property_->GetWindowType();
}
WindowMode WindowImpl::GetMode() const
{
return property_->GetWindowMode();
}
float WindowImpl::GetAlpha() const
{
return property_->GetAlpha();
}
WindowState WindowImpl::GetWindowState() const
{
return state_;
}
WMError WindowImpl::SetFocusable(bool isFocusable)
{
return WMError::WM_OK;
}
bool WindowImpl::GetFocusable() const
{
return property_->GetFocusable();
}
WMError WindowImpl::SetTouchable(bool isTouchable)
{
return WMError::WM_OK;
}
bool WindowImpl::GetTouchable() const
{
return property_->GetTouchable();
}
const std::string& WindowImpl::GetWindowName() const
{
return name_;
}
uint32_t WindowImpl::GetWindowId() const
{
return property_->GetWindowId();
}
uint32_t WindowImpl::GetWindowFlags() const
{
return property_->GetWindowFlags();
}
uint32_t WindowImpl::GetRequestModeSupportInfo() const
{
return property_->GetRequestModeSupportInfo();
}
bool WindowImpl::IsMainHandlerAvailable() const
{
return true;
}
SystemBarProperty WindowImpl::GetSystemBarPropertyByType(WindowType type) const
{
auto curProperties = property_->GetSystemBarProperty();
return curProperties[type];
}
WMError WindowImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetWindowType(WindowType type)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetWindowMode(WindowMode mode)
{
return WMError::WM_OK;
}
void WindowImpl::SetAlpha(float alpha)
{
return;
}
void WindowImpl::SetTransform(const Transform& trans)
{
return;
}
const Transform& WindowImpl::GetTransform() const
{
return property_->GetTransform();
}
WMError WindowImpl::AddWindowFlag(WindowFlag flag)
{
return WMError::WM_OK;
}
WMError WindowImpl::RemoveWindowFlag(WindowFlag flag)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetWindowFlags(uint32_t flags)
{
return WMError::WM_OK;
}
void WindowImpl::OnNewWant(const AAFwk::Want& want)
{
return;
}
WMError WindowImpl::SetUIContent(const std::string& contentInfo,
NativeEngine* engine, NativeValue* storage, bool isdistributed, AppExecFwk::Ability* ability)
{
return WMError::WM_OK;
}
Ace::UIContent* WindowImpl::GetUIContent() const
{
return uiContent_.get();
}
std::string WindowImpl::GetContentInfo()
{
return "";
}
bool WindowImpl::IsSupportWideGamut()
{
return true;
}
void WindowImpl::SetColorSpace(ColorSpace colorSpace)
{
return;
}
ColorSpace WindowImpl::GetColorSpace()
{
return ColorSpace::COLOR_SPACE_DEFAULT;
}
std::shared_ptr<Media::PixelMap> WindowImpl::Snapshot()
{
return nullptr;
}
void WindowImpl::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
{
return;
}
WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetLayoutFullScreen(bool status)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetFullScreen(bool status)
{
return WMError::WM_OK;
}
WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<AbilityRuntime::Context>& context)
{
WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str());
// check window name, same window names are forbidden
if (windowMap_.find(name_) != windowMap_.end()) {
WLOGFE("WindowName(%{public}s) already exists.", name_.c_str());
return WMError::WM_ERROR_INVALID_PARAM;
}
// check parent name, if create sub window and there is not exist parent Window, then return
if (parentName != "") {
if (windowMap_.find(parentName) == windowMap_.end()) {
WLOGFE("ParentName is empty or valid. ParentName is %{public}s", parentName.c_str());
return WMError::WM_ERROR_INVALID_PARAM;
} else {
uint32_t parentId = windowMap_[parentName].first;
property_->SetParentId(parentId);
}
}
state_ = WindowState::STATE_CREATED;
return WMError::WM_OK;
}
WMError WindowImpl::BindDialogTarget(sptr<IRemoteObject> targetToken)
{
return WMError::WM_OK;
}
WMError WindowImpl::Destroy()
{
return WMError::WM_OK;
}
WMError WindowImpl::UpdateSurfaceNodeAfterCustomAnimation(bool isAdd)
{
return WMError::WM_OK;
}
WMError WindowImpl::Show(uint32_t reason, bool withAnimation)
{
return WMError::WM_OK;
}
WMError WindowImpl::Hide(uint32_t reason, bool withAnimation)
{
return WMError::WM_OK;
}
WMError WindowImpl::MoveTo(int32_t x, int32_t y)
{
return WMError::WM_OK;
}
WMError WindowImpl::Resize(uint32_t width, uint32_t height)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetKeepScreenOn(bool keepScreenOn)
{
return WMError::WM_OK;
}
bool WindowImpl::IsKeepScreenOn() const
{
return property_->IsKeepScreenOn();
}
WMError WindowImpl::SetTurnScreenOn(bool turnScreenOn)
{
return WMError::WM_OK;
}
bool WindowImpl::IsTurnScreenOn() const
{
return property_->IsTurnScreenOn();
}
WMError WindowImpl::SetBackgroundColor(const std::string& color)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetTransparent(bool isTransparent)
{
return WMError::WM_OK;
}
bool WindowImpl::IsTransparent() const
{
return true;
}
WMError WindowImpl::SetBrightness(float brightness)
{
return WMError::WM_OK;
}
float WindowImpl::GetBrightness() const
{
return property_->GetBrightness();
}
WMError WindowImpl::SetCallingWindow(uint32_t windowId)
{
return WMError::WM_OK;
}
void WindowImpl::SetPrivacyMode(bool isPrivacyMode)
{
return;
}
bool WindowImpl::IsPrivacyMode() const
{
return property_->GetPrivacyMode();
}
void WindowImpl::SetSystemPrivacyMode(bool isSystemPrivacyMode)
{
return;
}
void WindowImpl::SetSnapshotSkip(bool isSkip)
{
return;
}
void WindowImpl::DisableAppWindowDecor()
{
return;
}
bool WindowImpl::IsDecorEnable() const
{
return property_->GetDecorEnable();
}
WMError WindowImpl::Maximize()
{
return WMError::WM_OK;
}
WMError WindowImpl::Minimize()
{
return WMError::WM_OK;
}
WMError WindowImpl::Recover()
{
return WMError::WM_OK;
}
WMError WindowImpl::Close()
{
return WMError::WM_OK;
}
void WindowImpl::StartMove()
{
return;
}
WMError WindowImpl::RequestFocus() const
{
return WMError::WM_OK;
}
void WindowImpl::SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer)
{
return;
}
void WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
{
return;
}
void WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
{
return;
}
void WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
{
return;
}
void WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
{
return;
}
void WindowImpl::RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
{
return;
}
void WindowImpl::UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
{
return;
}
void WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
{
return;
}
void WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
{
return;
}
void WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
{
return;
}
void WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
{
return;
}
void WindowImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func)
{
return;
}
void WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
{
return;
}
void WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
{
return;
}
void WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
{
return;
}
void WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
{
return;
}
void WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
{
return;
}
void WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
{
return;
}
void WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
{
return;
}
void WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
{
return;
}
void WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
{
return;
}
void WindowImpl::RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
{
return;
}
void WindowImpl::UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
{
return;
}
void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
{
return;
}
void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo)
{
return;
}
void WindowImpl::ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
return;
}
void WindowImpl::ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
return;
}
void WindowImpl::RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback)
{
return;
}
void WindowImpl::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
{
if (uiContent_ != nullptr) {
WLOGFD("notify ace winId:%{public}u", GetWindowId());
uiContent_->UpdateConfiguration(configuration);
}
if (subWindowMap_.count(GetWindowId()) == 0) {
return;
}
for (auto& subWindow : subWindowMap_.at(GetWindowId())) {
subWindow->UpdateConfiguration(configuration);
}
}
void WindowImpl::NotifyTouchDialogTarget()
{
return;
}
void WindowImpl::SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel)
{
return;
}
bool WindowImpl::IsLayoutFullScreen() const
{
return true;
}
bool WindowImpl::IsFullScreen() const
{
return true;
}
void WindowImpl::SetRequestedOrientation(Orientation orientation)
{
return;
}
Orientation WindowImpl::GetRequestedOrientation()
{
return property_->GetRequestedOrientation();
}
WMError WindowImpl::SetTouchHotAreas(const std::vector<Rect>& rects)
{
return WMError::WM_OK;
}
void WindowImpl::GetRequestedTouchHotAreas(std::vector<Rect>& rects) const
{
property_->GetTouchHotAreas(rects);
}
WMError WindowImpl::SetCornerRadius(float cornerRadius)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetShadowRadius(float radius)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetShadowColor(std::string color)
{
return WMError::WM_OK;
}
void WindowImpl::SetShadowOffsetX(float offsetX)
{
return;
}
void WindowImpl::SetShadowOffsetY(float offsetY)
{
return;
}
WMError WindowImpl::SetBlur(float radius)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetBackdropBlur(float radius)
{
return WMError::WM_OK;
}
WMError WindowImpl::SetBackdropBlurStyle(WindowBlurStyle blurStyle)
{
return WMError::WM_OK;
}
WMError WindowImpl::NotifyMemoryLevel(int32_t level) const
{
return WMError::WM_OK;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -13,17 +13,63 @@
* limitations under the License.
*/
#include <configuration.h>
#include "window_impl.h"
#include "window_manager_hilog.h"
#include "window_scene.h"
namespace OHOS {
namespace Rosen {
const std::string WindowScene::MAIN_WINDOW_ID = "main window";
WindowScene::~WindowScene()
{
}
WMError WindowScene::Init(DisplayId displayId, const std::shared_ptr<AbilityRuntime::Context>& context,
sptr<IWindowLifeCycle>& listener, sptr<WindowOption> option)
{
displayId_ = displayId;
if (option == nullptr) {
option = new(std::nothrow) WindowOption();
if (option == nullptr) {
WLOGFW("alloc WindowOption failed");
return WMError::WM_ERROR_NULLPTR;
}
}
option->SetDisplayId(displayId);
option->SetWindowTag(WindowTag::MAIN_WINDOW);
mainWindow_ = Window::Create(GenerateMainWindowName(context), option, context);
if (mainWindow_ == nullptr) {
return WMError::WM_ERROR_NULLPTR;
}
mainWindow_->RegisterLifeCycleListener(listener);
return WMError::WM_OK;
}
std::string WindowScene::GenerateMainWindowName(const std::shared_ptr<AbilityRuntime::Context>& context) const
{
if (context == nullptr) {
return MAIN_WINDOW_ID + std::to_string(count++);
} else {
std::string windowName = context->GetBundleName() + std::to_string(count++);
std::size_t pos = windowName.find_last_of('.');
return (pos == std::string::npos) ? windowName : windowName.substr(pos + 1); // skip '.'
}
}
sptr<Window> WindowScene::CreateWindow(const std::string& windowName, sptr<WindowOption>& option) const
{
return nullptr;
if (windowName.empty() || mainWindow_ == nullptr || option == nullptr) {
WLOGFE("WindowScene Name: %{public}s", windowName.c_str());
return nullptr;
}
option->SetParentName(mainWindow_->GetWindowName());
option->SetWindowTag(WindowTag::SUB_WINDOW);
return Window::Create(windowName, option, mainWindow_->GetContext());
}
const sptr<Window>& WindowScene::GetMainWindow() const
@ -33,7 +79,37 @@ const sptr<Window>& WindowScene::GetMainWindow() const
std::vector<sptr<Window>> WindowScene::GetSubWindow()
{
return std::vector<sptr<Window>>();
if (mainWindow_ == nullptr) {
WLOGFE("Get sub window failed, because main window is null");
return std::vector<sptr<Window>>();
}
uint32_t parentId = mainWindow_->GetWindowId();
return Window::GetSubWindow(parentId);
}
WMError WindowScene::GoDestroy()
{
if (mainWindow_ == nullptr) {
return WMError::WM_ERROR_NULLPTR;
}
WMError ret = mainWindow_->Destroy();
if (ret != WMError::WM_OK) {
WLOGFE("WindowScene go destroy failed name: %{public}s", mainWindow_->GetWindowName().c_str());
return ret;
}
mainWindow_ = nullptr;
return WMError::WM_OK;
}
void WindowScene::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
{
if (mainWindow_ == nullptr) {
WLOGFE("Update configuration failed, because main window is null");
return;
}
WLOGFI("notify mainWindow winId:%{public}u", mainWindow_->GetWindowId());
mainWindow_->UpdateConfiguration(configuration);
}
} // namespace Rosen
} // namespace OHOS