Merge branch 'rsprocess2master2' of git@gitcode.com:nealchristmas/window_window_manager.git into 'master'
# Conflicts: # conflict window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h Signed-off-by: 18 <zhuchunjie2@huawei.com>
@@ -1,15 +1,55 @@
|
||||
# AGENTS.md — Window Manager (OpenHarmony)
|
||||
|
||||
This repo is a window sussystem of OpenHarmony.
|
||||
The Window Manager subsystem provides basic capabilities of window and display management. It is the basis for UI display. The following figure shows the architecture of the Window Manager subsystem.
|
||||
This repo is the window management subsystem of OpenHarmony. It provides core capabilities for window and display management, serving as the foundational subsystem for UI display. See [README.md](./README.md) for full architecture details.
|
||||
|
||||
## What is `window_manager`
|
||||
You can read [README](./README.md) to obtain detail information.
|
||||
|
||||
`window_manager` is a `Client-Server` architecture subsystem. Key modules:
|
||||
- `wm/` — Window Manager Client
|
||||
- `dm/` — Display Manager Client
|
||||
- `wmserver/` — Window Manager Server (separated arch)
|
||||
- `dmserver/` — Display Manager Server
|
||||
- `window_scene/` — Window Manager Server (unified arch)
|
||||
- `interfaces/innerkits/` — Native APIs
|
||||
- `interfaces/kits/` — JS/NAPI APIs
|
||||
- `extension/` — Ability Component window integration
|
||||
- `utils/` — Shared utilities
|
||||
|
||||
Two compile-time architectures are selected via `window_manager_use_sceneboard` in `product/define.gni`:
|
||||
|
||||
| Value | Architecture | Key module compiled |
|
||||
|-------|-------------|---------------------|
|
||||
| `false` | Separated | `wmserver/` |
|
||||
| `true` | Unified | `window_scene/` |
|
||||
|
||||
## WorkFlow
|
||||
|
||||
### CodeStyle specification
|
||||
You must follow the [CodeStyle](./docs/CodeStyle.md) specification when you write code.
|
||||
|
||||
Key rules:
|
||||
- **C++ standard**: C++11; **Column limit**: 120; **Indent**: 4 spaces, no tabs
|
||||
- **Namespace**: always `OHOS::Rosen`
|
||||
- **Naming**: Classes `PascalCase`, methods `camelCase`, member vars `camelCase_`, constants `UPPER_SNAKE_CASE`, files `snake_case`
|
||||
- **Include order**: corresponding header → stdlib → OH framework → `interfaces/` → other internal
|
||||
- **Logging**: `TLOGD` / `TLOGI` / `TLOGW` / `TLOGE`
|
||||
- **Error handling**: return `WMError`/`WmErrorCode`; early-return with `WLOGFE` log
|
||||
- **Memory**: `sptr<T>` for IPC/singletons, `wptr<T>` for weak refs; prefer RAII
|
||||
- Every source file must begin with the Apache 2.0 license header
|
||||
|
||||
### Testing specification
|
||||
You must follow the [Testing](./docs/Testing.md) specification after you write testing code and keep testing suite pass.
|
||||
|
||||
### Git Commit Rules
|
||||
|
||||
- **User approval required**: Ask user before `git commit`. Use `git commit -s` after approval.
|
||||
- **Angular format**: `type(scope): subject` (feat, fix, docs, style, refactor, test, chore)
|
||||
- **Co-authored footer**: Append `Co-Authored-By: Agent` to every commit message.
|
||||
|
||||
Example:
|
||||
```
|
||||
feat(auth): add user login feature
|
||||
|
||||
Signed-off-by: Your Name <your.email@example.com>
|
||||
Co-Authored-by: Agent
|
||||
```
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
# CLAUDE.md — Window Manager (OpenHarmony)
|
||||
|
||||
This file provides guidance for AI coding agents working in this repository.
|
||||
|
||||
## What is this repo
|
||||
|
||||
`window_manager` is the window management subsystem of OpenHarmony. It provides core capabilities for window and display management, serving as the foundational subsystem for UI display. See [README.md](./README.md) for full architecture details.
|
||||
|
||||
## Architecture
|
||||
|
||||
Two compile-time architectures are supported, selected via `window_manager_use_sceneboard` in `product/define.gni`:
|
||||
|
||||
| Value | Architecture | Key module compiled |
|
||||
|-------|-------------|---------------------|
|
||||
| `false` | Separated | `wmserver/` |
|
||||
| `true` | Unified | `window_scene/` |
|
||||
|
||||
Key modules:
|
||||
- `wm/` — Window Manager Client
|
||||
- `dm/` — Display Manager Client
|
||||
- `wmserver/` — Window Manager Server (separated arch)
|
||||
- `dmserver/` — Display Manager Server
|
||||
- `window_scene/` — Window Manager Server (unified arch)
|
||||
- `interfaces/innerkits/` — Native APIs
|
||||
- `interfaces/kits/` — JS/NAPI APIs
|
||||
- `extension/` — Ability Component window integration
|
||||
- `utils/` — Shared utilities
|
||||
|
||||
## Build
|
||||
|
||||
This project uses the OpenHarmony `gn` + `ninja` build system.
|
||||
|
||||
Feature flags are declared via `declare_args()` in `windowmanager_aafwk.gni`. The global architecture switch is:
|
||||
```gni
|
||||
window_manager_use_sceneboard = true # unified arch
|
||||
window_manager_use_sceneboard = false # separated arch
|
||||
```
|
||||
|
||||
## Code Style
|
||||
|
||||
Full rules: [docs/CodeStyle.md](./docs/CodeStyle.md)
|
||||
|
||||
- **C++ standard**: C++11
|
||||
- **Column limit**: 120 characters
|
||||
- **Indent**: 4 spaces, no tabs
|
||||
- **Braces**: Same line for classes/structs/control flow; new line for functions
|
||||
- **Pointer alignment**: Left — `int* ptr`
|
||||
- **Namespace**: always `OHOS::Rosen`
|
||||
|
||||
### Naming conventions
|
||||
|
||||
| Element | Convention | Example |
|
||||
|---------|-----------|---------|
|
||||
| Classes / Structs | PascalCase | `WindowManagerService` |
|
||||
| Methods | camelCase | `GetWindowById()` |
|
||||
| Member variables | camelCase + trailing `_` | `windowManagerMap_` |
|
||||
| Constants / Enums | UPPER_SNAKE_CASE | `DEFAULT_SPACING` |
|
||||
| Namespaces | PascalCase | `OHOS::Rosen` |
|
||||
| File names | snake_case | `window_manager.cpp` |
|
||||
| Test classes | PascalCase + `Test` suffix | `WindowManagerServiceTest` |
|
||||
| Macros | UPPER_SNAKE_CASE | `WMSERVER_LOG_TAG` |
|
||||
|
||||
### Include order (per `.cpp`)
|
||||
|
||||
1. Corresponding header
|
||||
2. Standard library headers (`<algorithm>`, `<string>`, …)
|
||||
3. OpenHarmony framework headers (`<hilog.h>`, `<ipc_skeleton.h>`, …)
|
||||
4. Project headers from `interfaces/`
|
||||
5. Other project-internal headers
|
||||
|
||||
Use `#pragma once` or `#ifndef OHOS_ROSEN_*_H` include guards in headers.
|
||||
|
||||
### Logging
|
||||
|
||||
```cpp
|
||||
TLOGD("message %d", value); // Debug
|
||||
TLOGI("message"); // Info
|
||||
TLOGW("warning"); // Warn
|
||||
TLOGE("error: %s", err); // Error
|
||||
```
|
||||
|
||||
### Error handling
|
||||
|
||||
- Return `WMError` / `WmErrorCode` enum values from public APIs.
|
||||
- Use early-return for error cases; log with `WLOGFE` before returning.
|
||||
|
||||
### Memory management
|
||||
|
||||
- Use `sptr<T>` for IPC objects and singletons; `wptr<T>` for weak refs.
|
||||
- Prefer RAII; avoid raw `new`/`delete`.
|
||||
|
||||
### License header
|
||||
|
||||
Every source file must begin with:
|
||||
```cpp
|
||||
/*
|
||||
* Copyright (c) xxxx-xxxx Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* ...
|
||||
*/
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Full rules: [docs/Testing.md](./docs/Testing.md)
|
||||
|
||||
- Test files use `*_test.cpp` suffix, named after the class under test.
|
||||
- Use `HWTEST_F` macro; namespace must be `OHOS::Rosen`.
|
||||
- `EXPECT_*` for non-fatal checks; `ASSERT_*` for fatal.
|
||||
|
||||
### Test structure template
|
||||
|
||||
```cpp
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class MyFeatureTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
HWTEST_F(MyFeatureTest, TestSomething, TestSize.Level1)
|
||||
{
|
||||
EXPECT_EQ(result, expected);
|
||||
ASSERT_NE(ptr, nullptr);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
```
|
||||
|
||||
### Build targets per module
|
||||
|
||||
| Module | Build target |
|
||||
|--------|-------------|
|
||||
| wm | `wm:test` |
|
||||
| wmserver | `wmserver:test` |
|
||||
| dm | `dm:test` |
|
||||
| dmserver | `dmserver:test` |
|
||||
| dm_lite | `dm_lite:test` |
|
||||
| window_scene | `window_scene:test` |
|
||||
| snapshot | `snapshot:test` |
|
||||
| extension/window_extension | `extension/window_extension:test` |
|
||||
|
||||
## IPC / ZIDL
|
||||
|
||||
IPC proxy/stub code lives in `src/zidl/` subdirectories within each module. IDL definitions are at the module root (e.g. `dmserver/IDisplayManager.idl`).
|
||||
@@ -1,86 +1,562 @@
|
||||
# Window Manager
|
||||
# window_manager
|
||||
|
||||
## Introduction
|
||||
- [Introduction](#1-introduction)
|
||||
- [Architecture Overview](#2-architecture-overview)
|
||||
- [Separated vs. Unified Architecture](#3-separated-vs-unified-architecture)
|
||||
- [Sub-module Architecture Details](#4-sub-module-architecture-details)
|
||||
- [Development Guide](#5-development-guide)
|
||||
- [Directory Structure](#6-directory-structure)
|
||||
- [Constraints](#7-constraints)
|
||||
- [Available APIs](#8-available-apis)
|
||||
- [Repositories Involved](#9-repositories-involved)
|
||||
|
||||
The Window Manager subsystem provides basic capabilities of window and display management. It is the basis for UI display. The following figure shows the architecture of the Window Manager subsystem.
|
||||
## 1. Introduction
|
||||
|
||||
**Figure 1** Architecture of the Window Manager subsystem
|
||||
### 1.1 Window Subsystem Overview
|
||||
The Window Manager subsystem provides core capabilities for window and display management in OpenHarmony. It is the foundational subsystem for UI display, responsible for coordinating and managing the creation, destruction, layout, rendering, and interaction of all windows in the system.
|
||||
|
||||

|
||||
### 1.2 Core Capabilities
|
||||
#### Screen Management
|
||||
- **Display-Screen Mapping**: Manages the mapping relationship between logical Displays and physical Screens
|
||||
- **Display Management**: Multi-display management and information query
|
||||
- **Screen Control**: Screen on/off control and brightness adjustment
|
||||
- **Screenshot**: Full-screen screenshot capability
|
||||
|
||||
- **Window Manager Client**
|
||||
#### Window Management
|
||||
- **Window Lifecycle Management**: Window creation, show, hide, and destruction
|
||||
- **Window Relationships and Structure**: Parent-child window relationship management with support for window nesting
|
||||
- **Window Layout Management**: Window position, size, and Z-order control
|
||||
- **Window Interaction**: Window drag, resize, and move operations
|
||||
- **Window Snapshot**: Window content screenshot capability
|
||||
- **Focus Management**: Window focus switching and input event dispatching
|
||||
- **Multimodal Input Support**: Provides window layout and focus window information for the multimodal input system
|
||||
|
||||
Provides window object abstraction and window management interfaces, and connects to the ability and UI framework.
|
||||
### 1.3 Parts and Relationships
|
||||

|
||||
|
||||
- **Display Manager Client**
|
||||
The window subsystem consists of 3 parts:
|
||||
1. `window_manager`: The current part, hosting the window management service and the application-layer window framework.
|
||||
1. It is the core foundation of the entire window subsystem.
|
||||
2. `scene_board_core`: Hosts the intermediate-layer framework between desktop-related system applications / system UI and the window management service.
|
||||
1. It serves as the middle layer between `window_manager` and `scene_board`.
|
||||
3. `scene_board`: Hosts the desktop-related system applications and system UI implementations, such as the launcher, wallpaper, lock screen, status bar, navigation bar, and control center.
|
||||
1. It is the topmost module of the window subsystem and the entry point for users to interact with the system UI.
|
||||
|
||||
Provides display information abstraction and display management interfaces.
|
||||
The window subsystem is primarily associated with the following subsystems:
|
||||
- **Applications**: Applications can manage windows and screens through the window or display related APIs
|
||||
- **Multimodal Input Subsystem**: The multimodal input system relies on the window subsystem for event dispatching
|
||||
- **Graphics Rendering Subsystem**: The window subsystem works in coordination with the graphics rendering system to accomplish window management and UI rendering
|
||||
|
||||
- **Window Manager Server**
|
||||
In addition, the window subsystem also serves the following consumers:
|
||||
- **System Applications**: Provides system window and application window management capabilities for system-level UI applications such as the launcher and wallpaper
|
||||
- **UI Framework**: The `ArkUI` framework implements UI rendering through windows
|
||||
|
||||
Provides capabilities such as window layout, Z-order control, window tree structure, window dragging, and window snapshot, and offers the window layout and focus window for multimodal input.
|
||||
## 2. Architecture Overview
|
||||
|
||||
- **Display Manager Server**
|
||||
### 2.1 Overall Architecture
|
||||
|
||||
Provides display information, screenshot, screen on/off, and brightness processing control, and processes the mapping between the display and screen.
|
||||
The window subsystem adopts a `Client-Server` architecture, achieving client-server separation through IPC (Inter-Process Communication).
|
||||
The overall architecture is shown below:
|
||||
|
||||
## Architectures
|
||||
The current `window_manager` part, incorporates two architectures of the window subsystem. Respectively referred to as the "separated architecture" and the "unified architecture".
|
||||

|
||||
|
||||
The main differences are shown in the **Figure 2**: 
|
||||
### 2.2 Architecture Design Principles
|
||||
Layered design:
|
||||
- **Interface Layer**:
|
||||
- Provides Native API and JS/NAPI interfaces for application use
|
||||
- **Client Layer**:
|
||||
- Window Manager Client and Display Manager Client, responsible for interface encapsulation, application framework implementation, and IPC communication
|
||||
- **Server Layer**:
|
||||
- WindowManagerService and DisplayManagerService, acting as system services (ServiceAbility) to provide core business logic for window management and screen management
|
||||
- SceneSessionManager and ScreenSessionManager are the core business implementation modules for window management and screen management at the system service layer
|
||||
|
||||
- **Separated Architecture**
|
||||
The "desktop-related" system Apps, such as the desktop and wallpaper, are all located in the application layer and operate independently in separate processes.Therefore, under this architecture, the APPs task management, such as the startup and shutdown of applications, involve multiple IPC communication between desktop-related system APPs and system services, as well as between system services and APPs.
|
||||
Collaborative relationships under the layered design:
|
||||
- **Application Window Creation Flow**
|
||||
```
|
||||
Application → window API → Window Manager Client → IPC → WindowManagerService
|
||||
```
|
||||
|
||||
- **Unified Architecture**
|
||||
The desktop-related system Apps and the window management service process are integrated together. They no longer run as independent processes but have transformed into individual system "[WindowScene Component](https://gitcode.com/openharmony/arkui_ace_engine/blob/master/frameworks/core/components_ng/pattern/window_scene/scene)". Therefore, the window management subsystem provides new "WindowScene Component" for implementing the management of windows and the layout management of windows.
|
||||
In addition, screen management are also provided by the "[Screen Component](https://gitcode.com/openharmony/arkui_ace_engine/blob/master/frameworks/core/components_ng/pattern/window_scene/screen)".
|
||||
- **Display Information Query Flow**
|
||||
```
|
||||
Application → display API → Display Manager Client → IPC → DisplayManagerService
|
||||
```
|
||||
|
||||
### Key Differences in Different Architectures
|
||||
On one hand, the management of windows has shifted to being accomplished through window controls. On the other hand, system applications related to the desktop have transformed into system window controls. As a result, there have been significant changes in the task management processes such as startup and shutdown.
|
||||
### 2.3 Dual Architectures
|
||||
The window subsystem currently supports two base architectures: the Separated Architecture and the Unified Architecture. They can be switched via compile-time feature configuration.
|
||||
- **Global feature configuration key**: `window_manager_use_sceneboard`
|
||||
- **Configuration file**: `product/define.gni` or the system feature configuration file
|
||||
- **Configuration method**:
|
||||
```gni
|
||||
# Select separated architecture
|
||||
window_manager_use_sceneboard = false
|
||||
|
||||
- **Separated Architecture**
|
||||

|
||||
# Select unified architecture
|
||||
window_manager_use_sceneboard = true
|
||||
```
|
||||
- **Scope of impact**:
|
||||
- Separated Architecture: compiles the `window_manager/wmserver` module
|
||||
- Unified Architecture: compiles the `window_manager/window_scene` module, `scene_board_core`, and `scene_board`
|
||||
|
||||
- **Unified Architecture**
|
||||

|
||||
#### Architecture Differences
|
||||

|
||||
|
||||
## Directory Structure
|
||||
Both architectures expose exactly the same API interfaces to the outside. There is no perceptible difference at the application layer; the differences are mainly in internal implementation and process model.
|
||||
|
||||
## 3. Separated vs. Unified Architecture
|
||||
|
||||
### 3.1 Separated Architecture
|
||||
|
||||
#### 3.1.1 Architecture Characteristics
|
||||
|
||||
The Separated Architecture is the traditional window management implementation approach, with the following characteristics:
|
||||
- **Independent Process Model**: Desktop, wallpaper, and other system applications run as independent processes
|
||||
- **Traditional IPC Communication**: Application startup/shutdown involves multiple IPC communications
|
||||
|
||||
#### 3.1.2 Process Model
|
||||

|
||||
|
||||
#### 3.1.3 Startup Flow
|
||||
|
||||

|
||||
|
||||
**Application Startup Steps**:
|
||||
1. Tap the icon to launch the application.
|
||||
2. Via IPC, other system services create the process; the window service creates a splash window and loads the splash screen.
|
||||
3. Through multiple IPC calls, the application and system services establish connections and schedule different lifecycle callbacks (e.g., `onCreate`, `onForeground`).
|
||||
4. The application creates an application window during startup and loads the application UI.
|
||||
5. Throughout the process, the launcher controls the startup animation of the application window via IPC through the window management service.
|
||||
|
||||
#### 3.1.4 Pros and Cons
|
||||
|
||||
**Advantages**:
|
||||
- Good process isolation; a system application crash does not affect the window service
|
||||
- Clear architecture with well-defined separation of responsibilities
|
||||
- Suitable for traditional desktop systems
|
||||
|
||||
**Disadvantages**:
|
||||
- High IPC communication overhead
|
||||
- Complex startup flow involving multiple IPC calls
|
||||
- Cross-process window management is complex
|
||||
|
||||
### 3.2 Unified Architecture
|
||||
|
||||
#### 3.2.1 Architecture Characteristics
|
||||
|
||||
The Unified Architecture is the new window management implementation approach, with the following characteristics:
|
||||
- **Unified Process**: Desktop, wallpaper, and other system applications are merged into the same process as the window service
|
||||
- **Component-based Management**: System applications are transformed into system window components
|
||||
- **Layout-driven**: Window layout management is driven by the ArkUI layout pipeline
|
||||
|
||||
#### 3.2.2 Process Model
|
||||

|
||||
|
||||
#### 3.2.3 Startup Flow
|
||||
|
||||

|
||||
|
||||
**Startup Steps**:
|
||||
1. Tap the icon to launch the application.
|
||||
2. The window management service creates the window first and loads the splash screen.
|
||||
3. The window management service notifies the Ability Manager Service to start the application and schedule different lifecycle callbacks (e.g., `onCreate`, `onForeground`).
|
||||
4. After the application starts, it loads the UI and connects to the window management service to replace the splash screen.
|
||||
5. Throughout the process, the launcher and the window management service are in the same process and directly control the startup animation of the application window.
|
||||
|
||||
#### 3.2.4 Core Components
|
||||
|
||||
**WindowScene Component**:
|
||||
- Responsible for component-based window management
|
||||
- Implements layout management for window components
|
||||
- Provides window lifecycle control
|
||||
|
||||
**Screen Component**:
|
||||
- Responsible for component-based screen management
|
||||
- Manages the mapping between physical screens and logical Displays
|
||||
- Provides screen control capabilities
|
||||
|
||||
#### 3.2.5 Pros and Cons
|
||||
|
||||
**Advantages**:
|
||||
- Fewer IPC communications, better performance
|
||||
- Simplified startup flow, faster launch speed
|
||||
- Leverages the ArkUI layout pipeline for more flexible layout management
|
||||
- Suitable for mobile and embedded systems
|
||||
|
||||
**Disadvantages**:
|
||||
- High process coupling
|
||||
- A system application crash may affect the window service
|
||||
- Increased debugging complexity
|
||||
|
||||
## 4. Sub-module Architecture Details
|
||||
|
||||
### 4.1 Window Manager Client (wm)
|
||||
|
||||
#### 4.1.2 Module Responsibilities
|
||||
|
||||
1. **Window Object Abstraction**: Provides the Window class, encapsulating all window operations
|
||||
2. **Interface Encapsulation**: Wraps lower-level IPC communication into easy-to-use APIs
|
||||
3. **Lifecycle Management**: Manages the creation and destruction of window objects
|
||||
4. **Event Callbacks**: Handles window state change events
|
||||
5. **IPC Communication**: Communicates with the server side via IPC
|
||||
|
||||
#### 4.1.3 Collaborative Relationship
|
||||
|
||||
```
|
||||
Application Code
|
||||
↓
|
||||
Window API (interfaces/kits)
|
||||
↓
|
||||
Window Manager Client (wm)
|
||||
↓
|
||||
IPC Communication
|
||||
↓
|
||||
Window Manager Server
|
||||
```
|
||||
|
||||
### 4.2 Display Manager Client (dm)
|
||||
|
||||
#### 4.2.1 Module Structure
|
||||
|
||||
```
|
||||
dm/
|
||||
├── include/ # Header files
|
||||
│ ├── display.h # Display interface definitions
|
||||
│ └── display_info.h # Display information structures
|
||||
└── src/ # Source files
|
||||
├── display.cpp # Display implementation
|
||||
└── display_manager.cpp # Display manager
|
||||
```
|
||||
|
||||
#### 4.2.2 Module Responsibilities
|
||||
|
||||
1. **Display Information Abstraction**: Provides the Display class, encapsulating Display information queries
|
||||
2. **Interface Encapsulation**: Provides Display management APIs
|
||||
3. **IPC Communication**: Communicates with Display Manager Server
|
||||
4. **Event Listening**: Listens for Display change events
|
||||
|
||||
#### 4.2.3 Collaborative Relationship
|
||||
|
||||
```
|
||||
Application Code
|
||||
↓
|
||||
Display API (interfaces/kits)
|
||||
↓
|
||||
Display Manager Client (dm)
|
||||
↓
|
||||
IPC Communication
|
||||
↓
|
||||
Display Manager Server
|
||||
```
|
||||
|
||||
### 4.3 Window Manager Server (wmserver)
|
||||
|
||||
#### 4.3.1 Module Structure
|
||||
|
||||
```
|
||||
wmserver/
|
||||
├── include/ # Header files
|
||||
│ ├── window_root.h # Window root node
|
||||
│ ├── window_node.h # Window node
|
||||
│ ├── window_layout.h # Window layout manager
|
||||
│ └── ...
|
||||
└── src/ # Source files
|
||||
├── window_root.cpp # Window root node implementation
|
||||
├── window_node.cpp # Window node implementation
|
||||
├── window_layout.cpp # Window layout implementation
|
||||
└── ...
|
||||
```
|
||||
|
||||
#### 4.3.2 Module Responsibilities
|
||||
|
||||
1. **Window Tree Management**: Maintains the window tree structure and manages parent-child window relationships
|
||||
2. **Window Layout**: Calculates window positions and sizes, handles window layout
|
||||
3. **Z-order Management**: Manages window Z-order and controls window display sequence
|
||||
4. **Focus Management**: Manages window focus and handles focus switching
|
||||
5. **Input Dispatching**: Provides focus window information to the input system
|
||||
6. **Window Dragging**: Handles window drag logic
|
||||
7. **Window Snapshot**: Provides window screenshot capability
|
||||
|
||||
#### 4.3.3 Core Class Descriptions
|
||||
|
||||
- **WindowRoot**: The root node of the window tree, managing all top-level windows
|
||||
- **WindowNode**: A window node representing a window instance
|
||||
- **WindowLayout**: The window layout manager, responsible for layout calculation
|
||||
- **FocusController**: The focus controller, managing window focus
|
||||
|
||||
#### 4.3.4 Collaborative Relationship
|
||||
|
||||
```
|
||||
IPC Communication
|
||||
↓
|
||||
Window Manager Service
|
||||
├── WindowRoot (Window Tree)
|
||||
├── WindowLayout (Layout Management)
|
||||
├── FocusController (Focus Management)
|
||||
└── ...
|
||||
↓
|
||||
Graphics System (RenderService)
|
||||
```
|
||||
|
||||
### 4.4 Display Manager Server (dmserver)
|
||||
|
||||
#### 4.4.1 Module Structure
|
||||
|
||||
```
|
||||
dmserver/
|
||||
├── include/ # Header files
|
||||
│ ├── abstract_display.h # Abstract Display
|
||||
│ ├── abstract_screen.h # Abstract Screen
|
||||
│ ├── display_controller.h # Display controller
|
||||
│ └── ...
|
||||
└── src/ # Source files
|
||||
├── abstract_display.cpp # Abstract Display implementation
|
||||
├── abstract_screen.cpp # Abstract Screen implementation
|
||||
└── ...
|
||||
```
|
||||
|
||||
#### 4.4.2 Module Responsibilities
|
||||
|
||||
1. **Display Management**: Manages logical Displays and provides Display information queries
|
||||
2. **Screen Management**: Manages physical Screens and provides Screen control
|
||||
3. **Mapping Management**: Maintains the mapping relationship between Displays and Screens
|
||||
4. **Screen Control**: Controls screen on/off and brightness
|
||||
5. **Screenshot**: Provides full-screen screenshot capability
|
||||
|
||||
#### 4.4.3 Core Class Descriptions
|
||||
|
||||
- **AbstractDisplay**: Abstract Display class, representing a logical display
|
||||
- **AbstractScreen**: Abstract Screen class, representing a physical screen
|
||||
- **DisplayController**: Display controller, managing Display lifecycle
|
||||
|
||||
#### 4.4.4 Collaborative Relationship
|
||||
|
||||
```
|
||||
IPC Communication
|
||||
↓
|
||||
Display Manager Service
|
||||
├── AbstractDisplay (Logical Display)
|
||||
├── AbstractScreen (Physical Screen)
|
||||
└── DisplayController (Controller)
|
||||
↓
|
||||
Hardware Abstraction Layer (HDI)
|
||||
```
|
||||
|
||||
### 4.5 WindowScene (window_scene)
|
||||
|
||||
#### 4.5.1 Module Structure
|
||||
|
||||
```
|
||||
window_scene/
|
||||
├── include/ # Header files
|
||||
│ ├── scene_root.h # Scene root node
|
||||
│ ├── scene_board.h # Scene board
|
||||
│ └── ...
|
||||
└── src/ # Source files
|
||||
├── scene_root.cpp # Scene root node implementation
|
||||
└── scene_board.cpp # Scene board implementation
|
||||
```
|
||||
|
||||
#### 4.5.2 Module Responsibilities
|
||||
|
||||
1. **Scene Management**: Manages window scenes, serving as the container for window components
|
||||
2. **Component-based Management**: Manages windows as `ArkUI` components
|
||||
3. **Layout Integration**: Integrates the `ArkUI` layout pipeline to enable layout pipeline reuse
|
||||
4. **System Component Management**: Manages system window components such as the launcher and wallpaper
|
||||
|
||||
#### 4.5.4 Collaborative Relationship
|
||||
|
||||
```
|
||||
IPC Communication
|
||||
↓
|
||||
WindowScene (ArkUI Component)
|
||||
├── RootScene (Scene Root)
|
||||
├── SystemWindowScene - Launcher Component
|
||||
├── SystemWindowScene - Wallpaper Component
|
||||
└── WindowScene - Application Window Component
|
||||
↓
|
||||
ArkUI Layout Pipeline
|
||||
↓
|
||||
Graphics Rendering System
|
||||
```
|
||||
|
||||
### 4.6 Extension (extension)
|
||||
|
||||
#### 4.6.1 Module Structure
|
||||
|
||||
```
|
||||
extension/
|
||||
├── extension_connection/ # ExtensionAbility component connection part
|
||||
│ ├── ability_connection.cpp
|
||||
│ └── ...
|
||||
└── window_extension/ # ExtensionAbility component window part
|
||||
├── window_extension.cpp
|
||||
└── ...
|
||||
```
|
||||
|
||||
#### 4.6.2 Module Responsibilities
|
||||
|
||||
1. **Ability Binding**: Implements the binding relationship between an Ability and a window
|
||||
2. **Lifecycle Synchronization**: Synchronizes the lifecycle of an Ability and its window
|
||||
3. **Property Propagation**: Passes properties between an Ability and its window
|
||||
|
||||
#### 4.6.3 Collaborative Relationship
|
||||
|
||||
```
|
||||
Ability Framework
|
||||
↓
|
||||
Extension
|
||||
├── ExtensionConnection (Connection Management)
|
||||
└── WindowExtension (Window Extension)
|
||||
↓
|
||||
Window Manager
|
||||
```
|
||||
|
||||
## 5. Development Guide
|
||||
|
||||
### 5.1 Window Properties
|
||||
|
||||
**Customizable Window Properties**:
|
||||
```cpp
|
||||
// Window type
|
||||
enum class WindowType {
|
||||
TYPE_APP, // Application window
|
||||
TYPE_SYSTEM_ALERT, // System alert window
|
||||
TYPE_INPUT_METHOD, // Input method window
|
||||
TYPE_STATUS_BAR, // Status bar window
|
||||
TYPE_PANEL, // Panel window
|
||||
TYPE_FLOAT, // Floating window
|
||||
// ... extensible as needed
|
||||
};
|
||||
|
||||
// Window mode
|
||||
enum class WindowMode {
|
||||
UNDEFINED,
|
||||
FULLSCREEN, // Full-screen mode
|
||||
PRIMARY, // Split-screen primary window
|
||||
SECONDARY, // Split-screen secondary window
|
||||
FLOATING, // Floating mode
|
||||
};
|
||||
|
||||
// Window layout properties
|
||||
struct WindowLayoutProperty {
|
||||
Rect rect; // Window position and size
|
||||
uint32_t zOrder; // Window Z-order
|
||||
WindowMode mode; // Window mode
|
||||
// ... extensible as needed
|
||||
};
|
||||
```
|
||||
|
||||
**Development Steps**:
|
||||
1. Extend the `WindowType` enum to add a custom window type
|
||||
2. Add the corresponding window type handling logic in the Window Manager Server
|
||||
3. Modify the window layout algorithm to support the new window type
|
||||
|
||||
#### Adding a Custom Window Type
|
||||
|
||||
**Step 1**: Extend the window type enum
|
||||
```cpp
|
||||
// In interfaces/innerkits/native/include/window/window_type.h
|
||||
enum class WindowType {
|
||||
// ... existing types
|
||||
TYPE_CUSTOM_WINDOW = 1000, // Custom window type
|
||||
};
|
||||
```
|
||||
|
||||
**Step 2**: Add window type handling logic
|
||||
```cpp
|
||||
// In wmserver/src/window_type.cpp
|
||||
bool IsSystemWindow(WindowType type)
|
||||
{
|
||||
// ... existing logic
|
||||
if (type == WindowType::TYPE_CUSTOM_WINDOW) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
**Step 3**: Handle the new type in the layout algorithm
|
||||
```cpp
|
||||
// In wmserver/src/window_layout.cpp
|
||||
void WindowLayout::CalculateLayout(WindowNode* node)
|
||||
{
|
||||
if (node->GetType() == WindowType::TYPE_CUSTOM_WINDOW) {
|
||||
// Custom layout logic
|
||||
CalculateCustomWindowLayout(node);
|
||||
} else {
|
||||
// Default layout logic
|
||||
CalculateDefaultLayout(node);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 5.2 Window Layout Algorithm
|
||||
|
||||
**Customizable Layout Algorithm**:
|
||||
```cpp
|
||||
// In window_layout.h
|
||||
class WindowLayout {
|
||||
public:
|
||||
// Overridable layout calculation functions
|
||||
virtual void CalculateLayout(WindowNode* node);
|
||||
virtual void CalculateZOrder(std::vector<WindowNode*>& nodes);
|
||||
|
||||
protected:
|
||||
// Layout strategy
|
||||
LayoutStrategy layoutStrategy_;
|
||||
|
||||
// Customization: add a custom layout strategy
|
||||
void ApplyCustomLayout(WindowNode* node);
|
||||
};
|
||||
```
|
||||
|
||||
**Customization Steps**:
|
||||
1. Inherit from the `WindowLayout` class
|
||||
2. Override the `CalculateLayout` method to implement a custom layout algorithm
|
||||
3. Use the custom layout class in the Window Manager Server
|
||||
|
||||
### 5.3 Notes
|
||||
|
||||
1. **Compatibility**: Maintain compatibility with existing interfaces
|
||||
2. **Performance**: Business logic must not impact system performance
|
||||
3. **Stability**: Code must be thoroughly tested to ensure it does not affect system stability
|
||||
4. **Maintainability**: Code must have good comments and documentation
|
||||
5. **Version Upgrades**: Compatibility must be considered when upgrading the system
|
||||
|
||||
## 6. Directory Structure
|
||||
|
||||
```
|
||||
foundation/window/window_manager/
|
||||
├── dm # Dislplay Manager Client
|
||||
├── dmserver # Dislplay Manager Service
|
||||
├── extension # Ability Component Window
|
||||
│ ├── extension_connection # Ability Component
|
||||
│ └── window_extension # Ability Component 被嵌入部分
|
||||
├── interfaces # apis
|
||||
│ ├── innerkits # native apis
|
||||
│ └── kits # js/napi apis
|
||||
├── previewer # lite previewer for IDE
|
||||
├── resources # resources
|
||||
├── sa_profile # system ability configs
|
||||
├── snapshot # snapshow util
|
||||
├── test # tests like fuzz
|
||||
├── utils # utils functions
|
||||
├── window_scene # Unified Window Manager Service
|
||||
├── wm # Window Manager Client
|
||||
└── wmserver # Separated Window Manager Service
|
||||
├── dm # Display Manager Client implementation
|
||||
├── dmserver # Display Manager Service implementation
|
||||
├── extension # Ability Component window-related code
|
||||
│ ├── extension_connection # Ability Component embedding part
|
||||
│ └── window_extension # Ability Component embedded part
|
||||
├── interfaces # External API directory
|
||||
│ ├── innerkits # Native API directory
|
||||
│ └── kits # JS/NAPI API directory
|
||||
├── previewer # Lightweight IDE simulator window implementation
|
||||
├── resources # Framework resource files
|
||||
├── sa_profile # System service configuration files
|
||||
├── snapshot # Screenshot command-line tool implementation
|
||||
├── test # Fuzz tests and system test cases
|
||||
├── utils # Utility classes
|
||||
├── window_scene # Unified Architecture Window Manager Service implementation
|
||||
├── wm # Window Manager Client implementation
|
||||
└── wmserver # Separated Architecture Window Manager Service implementation
|
||||
```
|
||||
|
||||
## Constraints
|
||||
## 7. Constraints
|
||||
- Language version
|
||||
- C++11 or later
|
||||
|
||||
- Programming language version
|
||||
- C++ 11 or later
|
||||
## 8. Available APIs
|
||||
|
||||
## Available APIs
|
||||
- [Window](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkts-apis-window.md)
|
||||
- [Display](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/js-apis-display.md)
|
||||
|
||||
- [Window](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-window.md)
|
||||
- [Display](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-display.md)
|
||||
## 9. Repositories Involved
|
||||
|
||||
## Repositories Involved
|
||||
|
||||
- [graphic_graphic_2d](https://gitee.com/openharmony/graphic_graphic_2d)
|
||||
- [arkui_ace_engine](https://gitee.com/openharmony/arkui_ace_engine)
|
||||
- [ability_ability_runtime](https://gitee.com/openharmony/ability_ability_runtime)
|
||||
- [multimodalinput_input](https://gitee.com/openharmony/multimodalinput_input)
|
||||
- [graphic_graphic_2d](https://gitcode.com/openharmony/graphic_graphic_2d)
|
||||
- [arkui_ace_engine](https://gitcode.com/openharmony/arkui_ace_engine)
|
||||
- [ability_ability_runtime](https://gitcode.com/openharmony/ability_ability_runtime)
|
||||
- [multimodalinput_input](https://gitcode.com/openharmony/multimodalinput_input)
|
||||
|
||||
@@ -1,59 +1,527 @@
|
||||
# window_manager
|
||||
|
||||
- [简介](#简介)
|
||||
- [目录](#目录)
|
||||
- [约束](#约束)
|
||||
- [接口说明](#接口说明)
|
||||
- [相关仓](#相关仓)
|
||||
- [简介](#1-简介)
|
||||
- [架构说明](#2-架构说明)
|
||||
- [分离架构与合一架构详解](#3-分离架构与合一架构详解)
|
||||
- [各子模块架构详解](#4-各子模块架构详解)
|
||||
- [开发方式](#5-开发方式)
|
||||
- [目录](#6-目录)
|
||||
- [约束](#7-约束)
|
||||
- [接口说明](#8-接口说明)
|
||||
- [相关仓](#9-相关仓)
|
||||
|
||||
## 简介
|
||||
## 1. 简介
|
||||
|
||||
**窗口子系统** 提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统。
|
||||
### 1.1 窗口子系统概述
|
||||
窗口管理子系统为 OpenHarmony 系统提供窗口管理和显示管理的核心能力,是UI显示的基础子系统,负责协调和管理系统中所有窗口的创建、销毁、布局、显示和交互。
|
||||
|
||||
其主要的结构如下图所示:
|
||||
### 1.2 核心能力
|
||||
#### 屏幕管理能力
|
||||
- **Display-Screen映射**:逻辑Display与物理Screen的映射关系管理
|
||||
- **Display管理**:多Display管理、信息查询
|
||||
- **屏幕控制**:屏幕亮灭控制、亮度调节
|
||||
- **屏幕截图**:全屏截图功能
|
||||
|
||||

|
||||
#### 窗口管理能力
|
||||
- **窗口生命周期管理**:窗口的创建、显示、隐藏、销毁
|
||||
- **窗口关系与结构**:父子窗口关系管理,支持窗口嵌套
|
||||
- **窗口布局管理**:窗口的位置、大小、层级控制
|
||||
- **窗口交互能力**:窗口拖拽、缩放、移动等交互操作
|
||||
- **窗口快照**:窗口内容截图能力
|
||||
- **焦点管理**:窗口焦点切换和输入事件分发
|
||||
- **多模态输入支持**:为多模态输入系统提供窗口布局和焦点窗口信息
|
||||
|
||||
- **Window Manager Client**
|
||||
### 1.3 部件与关系
|
||||

|
||||
|
||||
应用进程窗口管理接口层,提供窗口对对象抽象和窗口管理接口,对接原能力和UI框架。
|
||||
窗口子系统共有3个部件,分别是:
|
||||
1. `window_manager`: 当前部件,承载了窗口管理服务与应用层窗口框架。
|
||||
1. 是整个窗口子系统的核心底座。
|
||||
2. `scene_board_core`: 承载了桌面相关系统应用和系统UI与窗口管理服务的中间层框架。
|
||||
1. 是 `window_manager` 与 `scene_board` 的中间层。
|
||||
3. `scene_board`: 承载了桌面相关系统应用和系统UI实现,例如桌面、壁纸、锁屏、状态栏、导航条、控制中心等。
|
||||
1. 是窗口子系统的最上层模块,是用户与系统UI的入口。
|
||||
|
||||
- **Display Manager Client**
|
||||
窗口子系统主要与这些子系统关联,分别是:
|
||||
- **应用**:应用可通过 window 或 display 相关API管理窗口和屏幕
|
||||
- **多模输入子系统**:多模输入系统依赖窗口子系统进行事件分发
|
||||
- **图形渲染子系统**:窗口需要与图形渲染系统协同工作,完成窗口管理和UI渲染。
|
||||
|
||||
应用进程Display管理接口层,提供Display信息抽象和Display管理接口。
|
||||
此外,窗口子系统还为以下对象服务:
|
||||
- **系统应用**:为桌面、壁纸等系统级UI应用提供系统窗口和应用窗口管理的能力。
|
||||
- **UI框架**:`ArkUI` 框架通过窗口实现UI渲染。
|
||||
|
||||
- **Window Manager Server**
|
||||
## 2. 架构说明
|
||||
|
||||
窗口管理服务,提供窗口布局、Z序控制、窗口树结构、窗口拖拽、窗口快照等能力,并提供窗口布局和焦点窗口给多模输入
|
||||
### 2.1 整体架构
|
||||
|
||||
- **Display Manager Server**
|
||||
窗口子系统采用 `Client-Server` 架构,通过IPC(进程间通信)实现客户端和服务端的分离。
|
||||
整体架构图如下:
|
||||
|
||||
Display管理服务,提供Display信息、屏幕截图、屏幕亮灭和亮度处理控制,并处理Display与Screen映射关系
|
||||

|
||||
|
||||
## 架构说明
|
||||
当前部件,即`window_manager`,同时包含了窗口管理服务的两种架构,分别称为“分离架构”和“合一架构”。
|
||||
### 2.2 架构设计原理
|
||||
分层设计:
|
||||
- **接口层**:
|
||||
- 提供 Native API 和 JS/NAPI 接口,供应用调用
|
||||
- **客户端层**:
|
||||
- Window Manager Client 和 Display Manager Client,负责接口层的封装、应用框架实现和 IPC 通信
|
||||
- **服务端层**:
|
||||
- WindowManagerService 和 DisplayManagerService,作为系统服务(ServiceAbility)负责提供窗口管理和屏幕管理的核心业务逻辑
|
||||
- SceneSessionManager 和 ScreenSessionManager,是系统服务层的窗口管理和屏幕管理的核心业务实现模块
|
||||
|
||||
主要区别如下图:
|
||||

|
||||
分层设计下的协同关系:
|
||||
- **应用创建窗口流程**
|
||||
```
|
||||
应用 → window API → Window Manager Client → IPC → WindowManagerService
|
||||
```
|
||||
|
||||
- **分离架构**
|
||||
桌面相关的系统应用,例如桌面、壁纸等,均位于应用层,且各自独立进程。因此在这种架构下,应用的启动退出等管理过程就包含了桌面相关的系统应用到系统服务、系统服务到应用的多次IPC通信过程。
|
||||
- **显示信息查询流程**
|
||||
```
|
||||
应用 → display API → Display Manager Client → IPC → DisplayManagerService
|
||||
```
|
||||
|
||||
- **合一架构**
|
||||
桌面相关的系统应用,和窗口管理服务进程合一,不再是以独立的进程运行,而是转变为一个个系统**窗口控件**。因此,窗口管理子系统提供了[**窗口控件**](https://gitcode.com/openharmony/arkui_ace_engine/blob/master/frameworks/core/components_ng/pattern/window_scene/scene),用于实现窗口的控件化管理和窗口控件的布局管理。
|
||||
此外,也提供了[**屏幕控件**](https://gitcode.com/openharmony/arkui_ace_engine/blob/master/frameworks/core/components_ng/pattern/window_scene/screen)用于屏幕的控件化管理。
|
||||
### 2.3 双架构
|
||||
窗口子系统当前共有两个基础架构,分别是分离架构和合一架构。可通过编译时特性配置进行切换。
|
||||
- **全局特性配置项**:`window_manager_use_sceneboard`
|
||||
- **配置文件**:`product/define.gni` 或系统特性配置文件
|
||||
- **配置方式**:
|
||||
```gni
|
||||
# 选择分离架构
|
||||
window_manager_use_sceneboard = false
|
||||
|
||||
### 切换方式
|
||||
**分离架构**和**合一架构**可以通过全局特性配置项 `window_manager_use_sceneboard` 实现切换。
|
||||
具体配置方式,请参考:[特性配置规则](https://gitcode.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-build-feature.md)
|
||||
# 选择合一架构
|
||||
window_manager_use_sceneboard = true
|
||||
```
|
||||
- **影响范围**:
|
||||
- 分离架构:编译 `window_manager/wmserver` 模块
|
||||
- 合一架构:编译 `window_manager/window_scene` 模块、`scene_board_core` 和 `scene_board`
|
||||
|
||||
### 不同架构的关键区别
|
||||
一方面窗口的管理方式转变为通过窗口控件完成,另一方面桌面相关的系统应用转变为系统窗口控件,所以二者在启动退出等任务管理流程上发生了关键性改变。
|
||||
- **分离架构**
|
||||

|
||||
#### 架构差异
|
||||

|
||||
|
||||
- **合一架构**
|
||||

|
||||
两种架构对外提供完全相同的API接口,应用层无感知,差异主要体现在内部实现和进程模型上。
|
||||
|
||||
## 3. 分离架构与合一架构详解
|
||||
|
||||
### 3.1 分离架构
|
||||
|
||||
#### 3.1.1 架构特点
|
||||
|
||||
分离架构是传统的窗口管理实现方式,具有以下特点:
|
||||
- **独立进程模型**:桌面、壁纸等系统应用作为独立进程运行
|
||||
- **传统IPC通信**:应用启动/退出涉及多次IPC通信
|
||||
|
||||
#### 3.1.2 进程模型
|
||||

|
||||
|
||||
#### 3.1.3 启动流程
|
||||
|
||||

|
||||
|
||||
**应用启动步骤**:
|
||||
1. 点击图标,启动应用。
|
||||
2. 经过IPC,由元能力管理子系统创建应用进程、由窗口管理服务先创建启动窗口并加载启动界面。
|
||||
3. 经过多次IPC,应用和系统服务建连并调度不同的生命周期(例如: `onCreate`,`onForeground`)。
|
||||
4. 应用在启动过程中创建应用窗口,并加载应用UI界面。
|
||||
5. 过程中由桌面以IPC的方式,利用窗口管理服务实现控制应用窗口的启动动画。
|
||||
|
||||
#### 3.1.4 优缺点
|
||||
|
||||
**优点**:
|
||||
- 进程隔离性好,系统应用崩溃不影响窗口服务
|
||||
- 架构清晰,职责分离明确
|
||||
- 适合传统桌面系统
|
||||
|
||||
**缺点**:
|
||||
- IPC通信开销大
|
||||
- 启动流程复杂,涉及多次IPC
|
||||
- 跨进程窗口管理复杂
|
||||
|
||||
### 3.2 合一架构
|
||||
|
||||
#### 3.2.1 架构特点
|
||||
|
||||
合一架构是新的窗口管理实现方式,具有以下特点:
|
||||
- **进程合一**:桌面、壁纸等系统应用与窗口服务合并在同一进程
|
||||
- **控件化管理**:系统应用转变为系统窗口控件
|
||||
- **布局驱动**:通过ArkUI的布局管线驱动窗口布局管理
|
||||
|
||||
#### 3.2.2 进程模型
|
||||

|
||||
|
||||
#### 3.2.3 启动流程
|
||||
|
||||

|
||||
|
||||
**启动步骤**:
|
||||
1. 点击图标,启动应用。
|
||||
2. 由窗口管理服务先创建窗口,并加载启动界面。
|
||||
3. 由窗口管理服务通知元能力管理服务,启动应用并调度不同的生命周期(例如: `onCreate`,`onForeground`)。
|
||||
4. 应用启动后,加载UI界面,并与窗口管理服务建连,替换UI界面。
|
||||
5. 过程中桌面和窗口管理服务同进程,直接控制应用窗口的启动动画。
|
||||
|
||||
#### 3.2.4 核心组件
|
||||
|
||||
**WindowScene组件**:
|
||||
- 负责窗口的控件化管理
|
||||
- 实现窗口控件的布局管理
|
||||
- 提供窗口生命周期控制
|
||||
|
||||
**Screen组件**:
|
||||
- 负责屏幕的控件化管理
|
||||
- 管理物理屏幕和逻辑Display的映射
|
||||
- 提供屏幕控制能力
|
||||
|
||||
#### 3.2.5 优缺点
|
||||
|
||||
**优点**:
|
||||
- 减少IPC通信,性能更好
|
||||
- 启动流程简化,启动速度快
|
||||
- 利用ArkUI布局管线,布局管理更灵活
|
||||
- 适合移动和嵌入式系统
|
||||
|
||||
**缺点**:
|
||||
- 进程耦合度高
|
||||
- 系统应用崩溃可能影响窗口服务
|
||||
- 调试复杂度增加
|
||||
|
||||
## 4. 各子模块架构详解
|
||||
|
||||
### 4.1 Window Manager Client(wm)
|
||||
|
||||
#### 4.1.2 模块职责
|
||||
|
||||
1. **窗口对象抽象**:提供Window类,封装窗口的所有操作
|
||||
2. **接口封装**:将底层IPC通信封装为易用的API
|
||||
3. **生命周期管理**:管理窗口对象的创建和销毁
|
||||
4. **事件回调**:处理窗口状态变化事件
|
||||
5. **IPC通信**:与服务端进行IPC通信
|
||||
|
||||
#### 4.1.3 协同关系
|
||||
|
||||
```
|
||||
应用代码
|
||||
↓
|
||||
Window API (interfaces/kits)
|
||||
↓
|
||||
Window Manager Client (wm)
|
||||
↓
|
||||
IPC通信
|
||||
↓
|
||||
Window Manager Server
|
||||
```
|
||||
|
||||
### 4.2 Display Manager Client(dm)
|
||||
|
||||
#### 4.2.1 模块组成
|
||||
|
||||
```
|
||||
dm/
|
||||
├── include/ # 头文件
|
||||
│ ├── display.h # Display接口定义
|
||||
│ └── display_info.h # Display信息结构
|
||||
└── src/ # 实现文件
|
||||
├── display.cpp # Display实现
|
||||
└── display_manager.cpp # Display管理器
|
||||
```
|
||||
|
||||
#### 4.2.2 模块职责
|
||||
|
||||
1. **Display信息抽象**:提供Display类,封装Display信息查询
|
||||
2. **接口封装**:提供Display管理API
|
||||
3. **IPC通信**:与Display Manager Server通信
|
||||
4. **事件监听**:监听Display变化事件
|
||||
|
||||
#### 4.2.3 协同关系
|
||||
|
||||
```
|
||||
应用代码
|
||||
↓
|
||||
Display API (interfaces/kits)
|
||||
↓
|
||||
Display Manager Client (dm)
|
||||
↓
|
||||
IPC通信
|
||||
↓
|
||||
Display Manager Server
|
||||
```
|
||||
|
||||
### 4.3 Window Manager Server(wmserver)
|
||||
|
||||
#### 4.3.1 模块组成
|
||||
|
||||
```
|
||||
wmserver/
|
||||
├── include/ # 头文件
|
||||
│ ├── window_root.h # 窗口根节点
|
||||
│ ├── window_node.h # 窗口节点
|
||||
│ ├── window_layout.h # 窗口布局管理
|
||||
│ └── ...
|
||||
└── src/ # 实现文件
|
||||
├── window_root.cpp # 窗口根节点实现
|
||||
├── window_node.cpp # 窗口节点实现
|
||||
├── window_layout.cpp # 窗口布局实现
|
||||
└── ...
|
||||
```
|
||||
|
||||
#### 4.3.2 模块职责
|
||||
|
||||
1. **窗口树管理**:维护窗口树结构,管理父子窗口关系
|
||||
2. **窗口布局**:计算窗口位置、大小,处理窗口布局
|
||||
3. **Z序管理**:管理窗口层级,控制窗口显示顺序
|
||||
4. **焦点管理**:管理窗口焦点,处理焦点切换
|
||||
5. **输入分发**:为输入系统提供焦点窗口信息
|
||||
6. **窗口拖拽**:处理窗口拖拽逻辑
|
||||
7. **窗口快照**:提供窗口截图能力
|
||||
|
||||
#### 4.3.3 核心类说明
|
||||
|
||||
- **WindowRoot**:窗口树的根节点,管理所有顶层窗口
|
||||
- **WindowNode**:窗口节点,表示一个窗口实例
|
||||
- **WindowLayout**:窗口布局管理器,负责窗口布局计算
|
||||
- **FocusController**:焦点控制器,管理窗口焦点
|
||||
|
||||
#### 4.3.4 协同关系
|
||||
|
||||
```
|
||||
IPC通信
|
||||
↓
|
||||
Window Manager Service
|
||||
├── WindowRoot (窗口树)
|
||||
├── WindowLayout (布局管理)
|
||||
├── FocusController (焦点管理)
|
||||
└── ...
|
||||
↓
|
||||
图形系统 (RenderService)
|
||||
```
|
||||
|
||||
### 4.4 Display Manager Server(dmserver)
|
||||
|
||||
#### 4.4.1 模块组成
|
||||
|
||||
```
|
||||
dmserver/
|
||||
├── include/ # 头文件
|
||||
│ ├── abstract_display.h # 抽象Display
|
||||
│ ├── abstract_screen.h # 抽象Screen
|
||||
│ ├── display_controller.h # Display控制器
|
||||
│ └── ...
|
||||
└── src/ # 实现文件
|
||||
├── abstract_display.cpp # 抽象Display实现
|
||||
├── abstract_screen.cpp # 抽象Screen实现
|
||||
└── ...
|
||||
```
|
||||
|
||||
#### 4.4.2 模块职责
|
||||
|
||||
1. **Display管理**:管理逻辑Display,提供Display信息查询
|
||||
2. **Screen管理**:管理物理Screen,提供Screen控制
|
||||
3. **映射管理**:维护Display与Screen的映射关系
|
||||
4. **屏幕控制**:控制屏幕亮灭、亮度等
|
||||
5. **屏幕截图**:提供全屏截图功能
|
||||
|
||||
#### 4.4.3 核心类说明
|
||||
|
||||
- **AbstractDisplay**:抽象Display类,表示逻辑显示器
|
||||
- **AbstractScreen**:抽象Screen类,表示物理屏幕
|
||||
- **DisplayController**:Display控制器,管理Display生命周期
|
||||
|
||||
#### 4.4.4 协同关系
|
||||
|
||||
```
|
||||
IPC通信
|
||||
↓
|
||||
Display Manager Service
|
||||
├── AbstractDisplay (逻辑Display)
|
||||
├── AbstractScreen (物理Screen)
|
||||
└── DisplayController (控制器)
|
||||
↓
|
||||
硬件抽象层 (HDI)
|
||||
```
|
||||
|
||||
### 4.5 WindowScene(window_scene)
|
||||
|
||||
#### 4.5.1 模块组成
|
||||
|
||||
```
|
||||
window_scene/
|
||||
├── include/ # 头文件
|
||||
│ ├── scene_root.h # 场景根节点
|
||||
│ ├── scene_board.h # 场景面板
|
||||
│ └── ...
|
||||
└── src/ # 实现文件
|
||||
├── scene_root.cpp # 场景根节点实现
|
||||
└── scene_board.cpp # 场景面板实现
|
||||
```
|
||||
|
||||
#### 4.5.2 模块职责
|
||||
|
||||
1. **场景管理**:管理窗口场景,作为窗口控件的容器
|
||||
2. **控件化管理**:将窗口作为 `ArkUI` 控件进行管理
|
||||
3. **布局集成**:集成 `ArkUI` 布局管线,实现布局管线复用
|
||||
4. **系统控件管理**:管理桌面、壁纸等系统窗口控件
|
||||
|
||||
#### 4.5.4 协同关系
|
||||
|
||||
```
|
||||
IPC通信
|
||||
↓
|
||||
WindowScene (ArkUI Component)
|
||||
├── RootScene (场景根)
|
||||
├── SystemWindowScene - 桌面控件
|
||||
├── SystemWindowScene - 壁纸控件
|
||||
└── WindowScene - 应用窗口控件
|
||||
↓
|
||||
ArkUI布局管线
|
||||
↓
|
||||
图形渲染系统
|
||||
```
|
||||
|
||||
### 4.6 Extension(extension)
|
||||
|
||||
#### 4.6.1 模块组成
|
||||
|
||||
```
|
||||
extension/
|
||||
├── extension_connection/ # ExtensionAbility组件连接部分
|
||||
│ ├── ability_connection.cpp
|
||||
│ └── ...
|
||||
└── window_extension/ # ExtensionAbility组件窗口部分
|
||||
├── window_extension.cpp
|
||||
└── ...
|
||||
```
|
||||
|
||||
#### 4.6.2 模块职责
|
||||
|
||||
1. **Ability绑定**:实现Ability与窗口的绑定关系
|
||||
2. **生命周期同步**:同步Ability和窗口的生命周期
|
||||
3. **属性传递**:在Ability和窗口之间传递属性
|
||||
|
||||
#### 4.6.3 协同关系
|
||||
|
||||
```
|
||||
Ability框架
|
||||
↓
|
||||
Extension
|
||||
├── ExtensionConnection (连接管理)
|
||||
└── WindowExtension (窗口扩展)
|
||||
↓
|
||||
Window Manager
|
||||
```
|
||||
|
||||
## 5. 开发方式
|
||||
|
||||
### 5.1 窗口属性
|
||||
|
||||
**可定制窗口属性**:
|
||||
```cpp
|
||||
// 窗口类型
|
||||
enum class WindowType {
|
||||
TYPE_APP, // 应用窗口
|
||||
TYPE_SYSTEM_ALERT, // 系统提示窗口
|
||||
TYPE_INPUT_METHOD, // 输入法窗口
|
||||
TYPE_STATUS_BAR, // 状态栏窗口
|
||||
TYPE_PANEL, // 面板窗口
|
||||
TYPE_FLOAT, // 浮动窗口
|
||||
// ... 可根据需求扩展
|
||||
};
|
||||
|
||||
// 窗口模式
|
||||
enum class WindowMode {
|
||||
UNDEFINED,
|
||||
FULLSCREEN, // 全屏模式
|
||||
PRIMARY, // 分屏主窗口
|
||||
SECONDARY, // 分屏副窗口
|
||||
FLOATING, // 浮动模式
|
||||
};
|
||||
|
||||
// 窗口布局属性
|
||||
struct WindowLayoutProperty {
|
||||
Rect rect; // 窗口位置和大小
|
||||
uint32_t zOrder; // 窗口层级
|
||||
WindowMode mode; // 窗口模式
|
||||
// ... 可根据需求扩展
|
||||
};
|
||||
```
|
||||
|
||||
**开发方式**:
|
||||
1. 扩展 `WindowType` 枚举,添加自定义窗口类型
|
||||
2. 在Window Manager Server中添加对应的窗口类型处理逻辑
|
||||
3. 修改窗口布局算法,支持新的窗口类型
|
||||
|
||||
#### 添加自定义类型
|
||||
|
||||
**步骤1**:扩展窗口类型枚举
|
||||
```cpp
|
||||
// 在 interfaces/innerkits/native/include/window/window_type.h 中
|
||||
enum class WindowType {
|
||||
// ... 原有类型
|
||||
TYPE_CUSTOM_WINDOW = 1000, // 自定义窗口类型
|
||||
};
|
||||
```
|
||||
|
||||
**步骤2**:添加窗口类型处理逻辑
|
||||
```cpp
|
||||
// 在 wmserver/src/window_type.cpp 中
|
||||
bool IsSystemWindow(WindowType type)
|
||||
{
|
||||
// ... 原有逻辑
|
||||
if (type == WindowType::TYPE_CUSTOM_WINDOW) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
```
|
||||
|
||||
**步骤3**:在布局算法中处理新类型
|
||||
```cpp
|
||||
// 在 wmserver/src/window_layout.cpp 中
|
||||
void WindowLayout::CalculateLayout(WindowNode* node)
|
||||
{
|
||||
if (node->GetType() == WindowType::TYPE_CUSTOM_WINDOW) {
|
||||
// 自定义布局逻辑
|
||||
CalculateCustomWindowLayout(node);
|
||||
} else {
|
||||
// 默认布局逻辑
|
||||
CalculateDefaultLayout(node);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### 5.2 窗口布局算法
|
||||
|
||||
**可定制布局算法**:
|
||||
```cpp
|
||||
// 在 window_layout.h 中
|
||||
class WindowLayout {
|
||||
public:
|
||||
// 可重写的布局计算函数
|
||||
virtual void CalculateLayout(WindowNode* node);
|
||||
virtual void CalculateZOrder(std::vector<WindowNode*>& nodes);
|
||||
|
||||
protected:
|
||||
// 布局策略
|
||||
LayoutStrategy layoutStrategy_;
|
||||
|
||||
// 定制:添加自定义布局策略
|
||||
void ApplyCustomLayout(WindowNode* node);
|
||||
};
|
||||
```
|
||||
|
||||
**定制步骤**:
|
||||
1. 继承 `WindowLayout` 类
|
||||
2. 重写 `CalculateLayout` 方法,实现自定义布局算法
|
||||
3. 在Window Manager Server中使用自定义布局类
|
||||
|
||||
### 5.3 注意事项
|
||||
|
||||
1. **兼容性**:需要保持与原有接口的兼容性
|
||||
2. **性能**:业务逻辑不能影响系统性能
|
||||
3. **稳定性**:代码需要充分测试,确保不影响系统稳定性
|
||||
4. **可维护性**:代码需要良好的注释和文档
|
||||
5. **版本升级**:系统升级时需要考虑兼容性
|
||||
|
||||
## 目录
|
||||
```
|
||||
|
||||
@@ -159,6 +159,7 @@ ohos_shared_library("libdm") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
group("test") {
|
||||
@@ -189,7 +190,7 @@ ohos_shared_library("libdm_ndk") {
|
||||
include_dirs = [
|
||||
".",
|
||||
"${window_base_path}/interfaces/kits/dmndk/dm",
|
||||
"${window_base_path}/interfaces/inner_kits/dm",
|
||||
"${window_base_path}/interfaces/innerkits/dm",
|
||||
]
|
||||
|
||||
sources = [ "src/oh_display_manager.cpp" ]
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
virtual bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId);
|
||||
virtual bool IsFoldable();
|
||||
virtual bool IsCaptured();
|
||||
virtual bool IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList);
|
||||
virtual FoldStatus GetFoldStatus();
|
||||
virtual FoldDisplayMode GetFoldDisplayMode();
|
||||
virtual void SetFoldDisplayMode(const FoldDisplayMode);
|
||||
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId);
|
||||
bool IsFoldable();
|
||||
bool IsCaptured();
|
||||
bool IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList);
|
||||
FoldStatus GetFoldStatus();
|
||||
FoldDisplayMode GetFoldDisplayMode();
|
||||
FoldDisplayMode GetFoldDisplayModeForExternal();
|
||||
@@ -1289,6 +1290,16 @@ bool DisplayManager::Impl::IsCaptured()
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().IsCaptured();
|
||||
}
|
||||
|
||||
bool DisplayManager::IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList)
|
||||
{
|
||||
return pImpl_->IsCapturedByBundleNameList(bundleNameList);
|
||||
}
|
||||
|
||||
bool DisplayManager::Impl::IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().IsCapturedByBundleNameList(bundleNameList);
|
||||
}
|
||||
|
||||
FoldStatus DisplayManager::GetFoldStatus()
|
||||
{
|
||||
return pImpl_->GetFoldStatus();
|
||||
|
||||
@@ -1245,6 +1245,17 @@ bool DisplayManagerAdapter::IsCaptured()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(false);
|
||||
|
||||
if (screenSessionManagerServiceProxy_) {
|
||||
return screenSessionManagerServiceProxy_->IsCapturedByBundleNameList(bundleNameList);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FoldStatus DisplayManagerAdapter::GetFoldStatus()
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(FoldStatus::UNKNOWN);
|
||||
|
||||
@@ -729,6 +729,9 @@ ScreenId ScreenManager::Impl::CreateVirtualScreen(VirtualScreenOption option)
|
||||
if (virtualScreenAgent_ == nullptr) {
|
||||
virtualScreenAgent_ = new DisplayManagerAgentDefault();
|
||||
}
|
||||
if (option.caller_ == VirtualScreenCaller::UNKNOWN) {
|
||||
option.caller_ = VirtualScreenCaller::NATIVE_SCREEN_MANAGER;
|
||||
}
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().CreateVirtualScreen(option, virtualScreenAgent_);
|
||||
}
|
||||
|
||||
|
||||
@@ -1040,6 +1040,18 @@ HWTEST_F(DisplayManagerTest, IsCaptured01, TestSize.Level1)
|
||||
ASSERT_FALSE(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCapturedByBundleNameList01
|
||||
* @tc.desc: IsCapturedByBundleNameList01 fun
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DisplayManagerTest, IsCapturedByBundleNameList01, TestSize.Level1)
|
||||
{
|
||||
std::vector<std::string> bundleNameList;
|
||||
auto ret = DisplayManager::GetInstance().IsCapturedByBundleNameList(bundleNameList);
|
||||
ASSERT_FALSE(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: isinsideof
|
||||
* @tc.desc: isinside0f fun
|
||||
|
||||
@@ -90,6 +90,7 @@ ohos_shared_library("libdm_lite") {
|
||||
if (window_manager_feature_screenless) {
|
||||
defines += [ "SCREENLESS_ENABLE" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
group("test") {
|
||||
|
||||
@@ -137,6 +137,7 @@ ohos_shared_library("libdms") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
group("test") {
|
||||
|
||||
@@ -151,6 +151,7 @@ enum class DisplayManagerMessage : unsigned int {
|
||||
TRANS_ID_GET_DEVICE_SCREEN_CONFIG,
|
||||
TRANS_ID_SET_VIRTUAL_SCREEN_REFRESH_RATE,
|
||||
TRANS_ID_DEVICE_IS_CAPTURE,
|
||||
TRANS_ID_DEVICE_IS_CAPTURE_BY_BUNDLE_LIST,
|
||||
TRANS_ID_GET_SNAPSHOT_BY_PICKER,
|
||||
TRANS_ID_SWITCH_USER,
|
||||
TRANS_ID_SET_VIRTUAL_SCREEN_BLACK_LIST,
|
||||
|
||||
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 66 KiB |
@@ -71,6 +71,7 @@ ohos_shared_library("libwindow_extension_client") {
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -68,4 +68,5 @@ ohos_shared_library("libmodal_system_ui_extension_client") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ ohos_shared_library("libwindow_extension") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
config("window_extension_module_private_config") {
|
||||
@@ -129,6 +130,7 @@ ohos_shared_library("window_extension_module") {
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
relative_install_dir = "extensionability/"
|
||||
subsystem_name = "window"
|
||||
part_name = "window_manager"
|
||||
|
||||
@@ -29,6 +29,12 @@ group("unittest") {
|
||||
}
|
||||
}
|
||||
|
||||
const_deps = [
|
||||
":window_extension_unittest_common",
|
||||
"${window_base_path}/utils:libwmutil_base",
|
||||
"${window_base_path}/window_scene/common:window_scene_common",
|
||||
]
|
||||
|
||||
ohos_unittest("extension_window_extension_proxy_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
@@ -39,11 +45,14 @@ ohos_unittest("extension_window_extension_proxy_test") {
|
||||
|
||||
include_dirs = [ "${window_base_path}/window_scene/test/mock" ]
|
||||
|
||||
deps = [ ":window_extension_unittest_common" ]
|
||||
deps = const_deps
|
||||
|
||||
external_deps = [
|
||||
"accessibility:accessibility_common",
|
||||
"graphic_2d:librender_service_base",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
}
|
||||
@@ -55,12 +64,16 @@ ohos_unittest("extension_window_extension_stub_impl_test") {
|
||||
|
||||
include_dirs = [ "${window_base_path}/test/common/mock" ]
|
||||
|
||||
deps = [ ":window_extension_unittest_common" ]
|
||||
deps = const_deps
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
"accessibility:accessibility_common",
|
||||
"ace_engine:ace_uicontent",
|
||||
"googletest:gmock",
|
||||
"graphic_2d:librender_service_base",
|
||||
"graphic_2d:librender_service_client",
|
||||
"input:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
}
|
||||
@@ -111,6 +124,8 @@ config("window_extension_unittest_common_public_config") {
|
||||
"${window_base_path}/wm/test/mock",
|
||||
"${window_base_path}/wmserver/include",
|
||||
"${window_base_path}/wmserver/include/window_snapshot",
|
||||
"${window_base_path}/interfaces/innerkits",
|
||||
"${window_base_path}/interfaces/innerkits/dm",
|
||||
"${window_base_path}/interfaces/innerkits/wm",
|
||||
"${window_base_path}/utils/include",
|
||||
"${window_base_path}/window_scene",
|
||||
@@ -131,7 +146,7 @@ ohos_static_library("window_extension_unittest_common") {
|
||||
"../../../../resources/config/build:testcase_flags",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
deps = [
|
||||
"${window_base_path}/dm:libdm",
|
||||
"${window_base_path}/dmserver:libdms",
|
||||
"${window_base_path}/utils:libwmutil",
|
||||
@@ -141,37 +156,31 @@ ohos_static_library("window_extension_unittest_common") {
|
||||
"${window_base_path}/wm:libwm_static",
|
||||
"${window_base_path}/wm:libwm_lite",
|
||||
"${window_base_path}/wmserver:libwms",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../..:libwindow_extension",
|
||||
"../../../../interfaces/kits/napi/window_runtime:window_native_kit_static",
|
||||
"../../../../window_scene/session:scene_session_static",
|
||||
"../../../../wm:libwm",
|
||||
"../../../extension_connection:libwindow_extension_client",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock",
|
||||
"googletest:gtest_main",
|
||||
"graphic_2d:librender_service_client",
|
||||
"image_framework:image_native",
|
||||
"input:libmmi-client",
|
||||
"libjpeg-turbo:turbojpeg_static",
|
||||
"${window_base_path}/interfaces/kits/napi/window_runtime:window_native_kit_static",
|
||||
"${window_base_path}/window_scene/session:scene_session_static",
|
||||
"${window_base_path}/wm:libwm",
|
||||
"${window_base_path}/extension/extension_connection:libwindow_extension_client",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_context",
|
||||
"ability_runtime:runtime",
|
||||
"accessibility:accessibility_common",
|
||||
"ace_engine:ace_uicontent",
|
||||
"c_utils:utils",
|
||||
"googletest:gmock",
|
||||
"googletest:gtest_main",
|
||||
"graphic_2d:librender_service_client",
|
||||
"hilog:libhilog",
|
||||
"image_framework:image_native",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_single",
|
||||
"libjpeg-turbo:turbojpeg_static",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -737,6 +737,14 @@ public:
|
||||
*/
|
||||
bool IsCaptured();
|
||||
|
||||
/**
|
||||
* @brief Check whether the device is captured by apps in bundle name list.
|
||||
*
|
||||
* @param bundleNameList The list of bundle names to check.
|
||||
* @return true means the device is captured by apps in the list.
|
||||
*/
|
||||
bool IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList);
|
||||
|
||||
/**
|
||||
* @brief Get the current fold status of the foldable device.
|
||||
*
|
||||
|
||||
@@ -28,6 +28,15 @@
|
||||
namespace OHOS::Rosen {
|
||||
class ScreenInfo;
|
||||
|
||||
enum class VirtualScreenCaller : uint32_t {
|
||||
UNKNOWN = 0,
|
||||
JS_DISPLAY_MANAGER,
|
||||
JS_SCREEN_MANAGER,
|
||||
ANI_DISPLAY_MANAGER,
|
||||
ANI_SCREEN_MANAGER,
|
||||
NATIVE_SCREEN_MANAGER
|
||||
};
|
||||
|
||||
struct VirtualScreenOption {
|
||||
std::string name_;
|
||||
uint32_t width_;
|
||||
@@ -44,11 +53,12 @@ struct VirtualScreenOption {
|
||||
bool supportsInput_ {true};
|
||||
std::string bundleName_;
|
||||
std::string serialNumber_;
|
||||
uint32_t phyWidth_ { 0 };
|
||||
uint32_t phyHeight_ { 0 };
|
||||
int32_t userId_ {INVALID_USERID};
|
||||
int32_t screenId_ {-1};
|
||||
};
|
||||
uint32_t phyWidth_ { 0 };
|
||||
uint32_t phyHeight_ { 0 };
|
||||
int32_t userId_ {INVALID_USERID};
|
||||
int32_t screenId_ {-1};
|
||||
VirtualScreenCaller caller_ {VirtualScreenCaller::UNKNOWN};
|
||||
};
|
||||
|
||||
class Screen : public RefBase {
|
||||
friend class ScreenManager;
|
||||
|
||||
@@ -1691,7 +1691,7 @@ public:
|
||||
/**
|
||||
* @brief Pause window
|
||||
*/
|
||||
virtual void Pause() {}
|
||||
virtual void Pause(bool isGamePreLaunch = false) {}
|
||||
|
||||
/**
|
||||
* @brief Hide window
|
||||
@@ -5444,6 +5444,20 @@ public:
|
||||
return WMError::WM_ERROR_INVALID_WINDOW_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Window PersistentId.
|
||||
*
|
||||
* @return Window PersistentId.
|
||||
*/
|
||||
virtual int32_t GetWindowPersistentId() const { return INVALID_WINDOW_ID; };
|
||||
|
||||
/**
|
||||
* @brief Get whether this window is AtomicService.
|
||||
*
|
||||
* @return True means the window is AtomicService, false means the window is not AtomicService.
|
||||
*/
|
||||
virtual bool GetIsAtomicService() const { return false; };
|
||||
|
||||
/**
|
||||
* @brief notify split ratio changed
|
||||
*
|
||||
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
*
|
||||
* @return the error code of window
|
||||
*/
|
||||
WMError GoPause();
|
||||
WMError GoPause(bool isGamePreLaunch = false);
|
||||
|
||||
/**
|
||||
* Window handle new want.
|
||||
|
||||
@@ -1523,11 +1523,21 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
|
||||
struct AttachOptions : public Parcelable {
|
||||
std::string currentLayoutMode = "";
|
||||
bool isIntersectedHeightLimit = false;
|
||||
bool isIntersectedWidthLimit = false;
|
||||
|
||||
AttachOptions() = default;
|
||||
AttachOptions(std::string currentLayoutMode) : currentLayoutMode(currentLayoutMode) {}
|
||||
AttachOptions(std::string currentLayoutMode, bool isIntersectedHeightLimit,
|
||||
bool isIntersectedWidthLimit) : currentLayoutMode(currentLayoutMode),
|
||||
isIntersectedHeightLimit(isIntersectedHeightLimit),
|
||||
isIntersectedWidthLimit(isIntersectedWidthLimit) {}
|
||||
|
||||
bool operator==(const AttachOptions& other) const
|
||||
{
|
||||
return currentLayoutMode == other.currentLayoutMode;
|
||||
return currentLayoutMode == other.currentLayoutMode &&
|
||||
isIntersectedHeightLimit == other.isIntersectedHeightLimit &&
|
||||
isIntersectedWidthLimit == other.isIntersectedWidthLimit;
|
||||
}
|
||||
|
||||
bool operator!=(const AttachOptions& other) const
|
||||
@@ -1537,7 +1547,12 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
return parcel.WriteString(currentLayoutMode);
|
||||
if (!parcel.WriteString(currentLayoutMode) ||
|
||||
!parcel.WriteBool(isIntersectedHeightLimit) ||
|
||||
!parcel.WriteBool(isIntersectedWidthLimit)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static AttachOptions* Unmarshalling(Parcel& parcel)
|
||||
@@ -1551,6 +1566,11 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
return nullptr;
|
||||
}
|
||||
attachOptions->currentLayoutMode = layoutMode;
|
||||
|
||||
if (!parcel.ReadBool(attachOptions->isIntersectedHeightLimit) ||
|
||||
!parcel.ReadBool(attachOptions->isIntersectedWidthLimit)) {
|
||||
return nullptr;
|
||||
}
|
||||
return attachOptions.release();
|
||||
}
|
||||
};
|
||||
@@ -1603,6 +1623,8 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
}
|
||||
windowAnchorInfo->windowAnchor_ = static_cast<WindowAnchor>(windowAnchorMode);
|
||||
windowAnchorInfo->attachOptions.currentLayoutMode = attachOptions->currentLayoutMode;
|
||||
windowAnchorInfo->attachOptions.isIntersectedHeightLimit = attachOptions->isIntersectedHeightLimit;
|
||||
windowAnchorInfo->attachOptions.isIntersectedWidthLimit = attachOptions->isIntersectedWidthLimit;
|
||||
return windowAnchorInfo;
|
||||
}
|
||||
};
|
||||
@@ -2318,6 +2340,66 @@ struct WindowLimits {
|
||||
<< " " << vpRatio_ << " " << static_cast<uint32_t>(pixelUnit_) << "]";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
bool Marshalling(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteUint32(maxWidth_) && parcel.WriteUint32(maxHeight_) &&
|
||||
parcel.WriteUint32(minWidth_) && parcel.WriteUint32(minHeight_) &&
|
||||
parcel.WriteFloat(maxRatio_) && parcel.WriteFloat(minRatio_) &&
|
||||
parcel.WriteFloat(vpRatio_) && parcel.WriteUint32(static_cast<uint32_t>(pixelUnit_));
|
||||
}
|
||||
|
||||
static WindowLimits* Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
auto windowLimits = std::make_unique<WindowLimits>();
|
||||
if (!windowLimits) {
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t pixelUnit = 0;
|
||||
if (!parcel.ReadUint32(windowLimits->maxWidth_) ||
|
||||
!parcel.ReadUint32(windowLimits->maxHeight_) ||
|
||||
!parcel.ReadUint32(windowLimits->minWidth_) ||
|
||||
!parcel.ReadUint32(windowLimits->minHeight_) ||
|
||||
!parcel.ReadFloat(windowLimits->maxRatio_) ||
|
||||
!parcel.ReadFloat(windowLimits->minRatio_) ||
|
||||
!parcel.ReadFloat(windowLimits->vpRatio_) ||
|
||||
!parcel.ReadUint32(pixelUnit)) {
|
||||
return nullptr;
|
||||
}
|
||||
// Validate pixelUnit: valid values are PX=0 and VP=1
|
||||
if (pixelUnit > static_cast<uint32_t>(PixelUnit::VP)) {
|
||||
return nullptr;
|
||||
}
|
||||
windowLimits->pixelUnit_ = static_cast<PixelUnit>(pixelUnit);
|
||||
return windowLimits.release();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct AttachLimitOptions
|
||||
*
|
||||
* @brief Options for intersecting limits with attached windows.
|
||||
* Used to specify whether to intersect height/width limits.
|
||||
*/
|
||||
struct AttachLimitOptions {
|
||||
bool isIntersectedHeightLimit = false;
|
||||
bool isIntersectedWidthLimit = false;
|
||||
|
||||
AttachLimitOptions() = default;
|
||||
AttachLimitOptions(bool isIntersectedHeightLimit, bool isIntersectedWidthLimit)
|
||||
: isIntersectedHeightLimit(isIntersectedHeightLimit),
|
||||
isIntersectedWidthLimit(isIntersectedWidthLimit) {}
|
||||
|
||||
bool operator==(const AttachLimitOptions& other) const
|
||||
{
|
||||
return isIntersectedHeightLimit == other.isIntersectedHeightLimit &&
|
||||
isIntersectedWidthLimit == other.isIntersectedWidthLimit;
|
||||
}
|
||||
|
||||
bool operator!=(const AttachLimitOptions& other) const
|
||||
{
|
||||
return !this->operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,6 +83,7 @@ ohos_shared_library("displayani_kit") {
|
||||
"runtime_core:ani_helpers",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -26,6 +26,7 @@ const CUTO_ARRAY_LENGTH = 5;
|
||||
const CREASE_RECTS_LENGTH = 10;
|
||||
const DISPLAY_PHYSICAL_RESOLUTION_LENGTH = 15;
|
||||
const ERROR_INVALID_PARAM = 401;
|
||||
const ERROR_ILLEGAL_PARAM = 1400004;
|
||||
const ROUNDED_CORNER_LENGTH = 4;
|
||||
|
||||
export interface Rect {
|
||||
@@ -569,7 +570,22 @@ function minusRoundedCornerArray(cornerArr: Array<RoundedCorner>): void {
|
||||
|
||||
export native function isFoldable(): boolean;
|
||||
|
||||
export native function isCaptured(): boolean;
|
||||
export native function isCapturedWithoutParam(): boolean;
|
||||
|
||||
export native function isCapturedByBundleNameList(bundleNameList: Array<string>): boolean;
|
||||
|
||||
export function isCaptured(): boolean {
|
||||
return isCapturedWithoutParam();
|
||||
}
|
||||
|
||||
export function isCaptured(bundleNameList: Array<string>): boolean {
|
||||
const MAX_BUNDLE_NAME_LIST_SIZE = 100;
|
||||
if (bundleNameList.length > MAX_BUNDLE_NAME_LIST_SIZE) {
|
||||
throw new BusinessError(ERROR_ILLEGAL_PARAM,
|
||||
new Error(`[ANI] The size of bundleNameList is larger than 100, actual size: ${bundleNameList.length}`));
|
||||
}
|
||||
return isCapturedByBundleNameList(bundleNameList);
|
||||
}
|
||||
|
||||
export function getFoldDisplayMode(): FoldDisplayMode {
|
||||
let res = getFoldDisplayModeNative();
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
static ani_boolean IsFoldableAni(ani_env* env);
|
||||
static ani_int GetFoldStatus(ani_env* env);
|
||||
static ani_boolean IsCaptured(ani_env* env);
|
||||
static ani_boolean IsCapturedByBundleNameList(ani_env* env, ani_object bundleNameListObj);
|
||||
static void GetCurrentFoldCreaseRegion(ani_env* env, ani_object obj, ani_long nativeObj);
|
||||
|
||||
static void GetAllDisplaysAni(ani_env* env, ani_object arrayObj);
|
||||
|
||||
@@ -589,14 +589,16 @@ ani_status DisplayAni::NspBindNativeFunctions(ani_env* env, ani_namespace nsp)
|
||||
reinterpret_cast<void *>(DisplayManagerAni::AddVirtualScreenBlocklist)},
|
||||
ani_native_function {"removeVirtualScreenBlocklistNative", nullptr,
|
||||
reinterpret_cast<void *>(DisplayManagerAni::RemoveVirtualScreenBlocklist)},
|
||||
ani_native_function {"isCaptured", nullptr, reinterpret_cast<void *>(DisplayManagerAni::IsCaptured)},
|
||||
ani_native_function {"isCapturedByBundleNameList", nullptr,
|
||||
reinterpret_cast<void *>(DisplayManagerAni::IsCaptured)},
|
||||
ani_native_function {"finalizerDisplayNative", nullptr,
|
||||
reinterpret_cast<void *>(DisplayManagerAni::FinalizerDisplay)},
|
||||
ani_native_function {"onChangeWithAttributeNative", nullptr,
|
||||
reinterpret_cast<void *>(DisplayManagerAni::RegisterDisplayAttributeListener)},
|
||||
ani_native_function {"displayInfoFinalizerCallback", nullptr,
|
||||
reinterpret_cast<void *>(DisplayAni::CleanDisplayInfoMap)},
|
||||
|
||||
ani_native_function {"isCapturedByBundleNameList", nullptr,
|
||||
reinterpret_cast<void *>(DisplayManagerAni::IsCapturedByBundleNameList)},
|
||||
};
|
||||
auto ret = env->Namespace_BindNativeFunctions(nsp, funcs.data(), funcs.size());
|
||||
if (ret != ANI_OK) {
|
||||
|
||||
@@ -119,7 +119,7 @@ void DisplayAniListener::OnCreate(DisplayId id)
|
||||
return;
|
||||
}
|
||||
std::vector<ani_ref> vec = it->second;
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}d", vec.size());
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}zu", vec.size());
|
||||
// find callbacks in vector
|
||||
for (ani_ref oneAniCallback : vec) {
|
||||
if (vm_ == nullptr) {
|
||||
@@ -176,7 +176,7 @@ void DisplayAniListener::OnDestroy(DisplayId id)
|
||||
return;
|
||||
}
|
||||
std::vector<ani_ref> vec = it->second;
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}d", vec.size());
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}zu", vec.size());
|
||||
// find callbacks in vector
|
||||
for (ani_ref oneAniCallback : vec) {
|
||||
if (vm_ == nullptr) {
|
||||
|
||||
@@ -154,6 +154,28 @@ ani_boolean DisplayManagerAni::IsCaptured(ani_env* env)
|
||||
return static_cast<ani_boolean>(isCapture);
|
||||
}
|
||||
|
||||
ani_boolean DisplayManagerAni::IsCapturedByBundleNameList(ani_env* env, ani_object bundleNameListObj)
|
||||
{
|
||||
TLOGI(WmsLogTag::DMS, "[ANI] IsCapturedByBundleNameList begin");
|
||||
if (env == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "[ANI] env is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> bundleNameList;
|
||||
ani_status ret = DisplayAniUtils::GetStdStringVector(env, bundleNameListObj, bundleNameList);
|
||||
if (ret != ANI_OK) {
|
||||
TLOGE(WmsLogTag::DMS, "[ANI] GetStdStringVector fail");
|
||||
AniErrUtils::ThrowBusinessError(env, DmErrorCode::DM_ERROR_INVALID_PARAM, "Failed to convert attributes");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isCapture = SingletonContainer::Get<DisplayManager>().IsCapturedByBundleNameList(bundleNameList);
|
||||
TLOGI(WmsLogTag::DMS, "[ANI] BundleNameList size: %{public}zu, isCapturedByBundleNameList: %{public}u.",
|
||||
bundleNameList.size(), isCapture);
|
||||
return static_cast<ani_boolean>(isCapture);
|
||||
}
|
||||
|
||||
ani_int DisplayManagerAni::GetFoldStatus(ani_env* env)
|
||||
{
|
||||
auto status = SingletonContainer::Get<DisplayManager>().GetFoldStatus();
|
||||
@@ -896,6 +918,7 @@ ani_long DisplayManagerAni::OnCreateVirtualScreen(ani_env* env, ani_object virtu
|
||||
return static_cast<ani_long>(screenId);
|
||||
}
|
||||
VirtualScreenOption option;
|
||||
option.caller_ = VirtualScreenCaller::ANI_DISPLAY_MANAGER;
|
||||
DmErrorCode errCode = DisplayAniUtils::GetVirtualScreenOptionFromAni(env, virtualScreenConfig, option);
|
||||
if (errCode == DmErrorCode::DM_ERROR_INVALID_PARAM) {
|
||||
TLOGE(WmsLogTag::DMS, "[ANI] Get virtual screen option from ani failed");
|
||||
|
||||
@@ -451,7 +451,7 @@ ani_object DisplayAniUtils::CreateAniUndefined(ani_env* env)
|
||||
static DmErrorCode GetFocusFromAni(ani_env* env, ani_object virtualScreenObj, VirtualScreenOption& option)
|
||||
{
|
||||
ani_ref supportsFocus = nullptr;
|
||||
if (env->Object_GetPropertyByName_Ref(virtualScreenObj, "%%property-supportsFocus", &supportsFocus) != ANI_OK) {
|
||||
if (env->Object_GetPropertyByName_Ref(virtualScreenObj, "supportsFocus", &supportsFocus) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::DMS, "Failed to get supportsFocus.");
|
||||
return DmErrorCode::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ ohos_shared_library("embeddablewindowstageani_kit") {
|
||||
"runtime_core:ani_helpers",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
# 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.
|
||||
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("../../../../windowmanager_aafwk.gni")
|
||||
|
||||
|
||||
config("fbwindow_common_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
|
||||
include_dirs = [
|
||||
"../common",
|
||||
"../../../../wm/include",
|
||||
@@ -24,10 +24,10 @@ config("fbwindow_common_config") {
|
||||
"../../arkui/ace_engine/interfaces/inner_api/xcomponent_controller",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
config("fbwindow_kit_public_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
|
||||
include_dirs = [ "floating_ball_ani/include" ]
|
||||
}
|
||||
|
||||
@@ -41,21 +41,21 @@ ohos_shared_library("fbwindowani_kit") {
|
||||
debug = false
|
||||
cfi_policy = "adaptive"
|
||||
}
|
||||
sources = [
|
||||
sources = [
|
||||
"floating_ball_ani/src/ani_fb_window.cpp",
|
||||
"floating_ball_ani/src/ani_fb_window_controller.cpp",
|
||||
"floating_ball_ani/src/ani_fb_window_utils.cpp",
|
||||
"floating_ball_ani/src/ani_fb_window_listener.cpp"
|
||||
]
|
||||
|
||||
|
||||
configs = [
|
||||
":fbwindow_common_config",
|
||||
":fbwindow_kit_public_config",
|
||||
"../../../../resources/config/build:coverage_flags",
|
||||
]
|
||||
|
||||
|
||||
public_configs = [ ":fbwindow_kit_public_config" ]
|
||||
|
||||
|
||||
deps = [
|
||||
"${window_base_path}/wm:libwm",
|
||||
"${window_base_path}/window_scene/interfaces/innerkits:libwsutils",
|
||||
@@ -92,6 +92,7 @@ ohos_shared_library("fbwindowani_kit") {
|
||||
"runtime_core:ani_helpers",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -42,7 +42,7 @@ ohos_shared_library("pipwindowani_kit") {
|
||||
debug = false
|
||||
cfi_policy = "adaptive"
|
||||
}
|
||||
sources = [
|
||||
sources = [
|
||||
"pipwindow_ani/src/ani_pip_window.cpp",
|
||||
"pipwindow_ani/src/ani_pip_controller.cpp",
|
||||
"pipwindow_ani/src/ani_pip_utils.cpp",
|
||||
@@ -90,6 +90,7 @@ ohos_shared_library("pipwindowani_kit") {
|
||||
"runtime_core:ani_helpers",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -96,7 +96,7 @@ void ScreenAniListener::OnConnect(ScreenId id)
|
||||
return;
|
||||
}
|
||||
std::vector<ani_ref> vec = it->second;
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}d", vec.size());
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}zu", vec.size());
|
||||
// find callbacks in vector
|
||||
for (auto oneAniCallback : vec) {
|
||||
if (vm_ == nullptr) {
|
||||
@@ -155,7 +155,7 @@ void ScreenAniListener::OnDisconnect(ScreenId id)
|
||||
return;
|
||||
}
|
||||
std::vector<ani_ref> vec = it->second;
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}d", vec.size());
|
||||
TLOGI(WmsLogTag::DMS, "vec_callback size: %{public}zu", vec.size());
|
||||
// find callbacks in vector
|
||||
for (auto oneAniCallback : vec) {
|
||||
if (vm_ == nullptr) {
|
||||
|
||||
@@ -319,6 +319,7 @@ void ScreenManagerAni::CreateVirtualScreen(ani_env* env, ani_object options, ani
|
||||
}
|
||||
|
||||
VirtualScreenOption option;
|
||||
option.caller_ = VirtualScreenCaller::ANI_SCREEN_MANAGER;
|
||||
auto ret = ScreenAniUtils::GetVirtualScreenOption(env, options, option);
|
||||
if (ret != DmErrorCode::DM_OK) {
|
||||
TLOGE(WmsLogTag::DMS, "[ANI] Get virtual screen options failed");
|
||||
|
||||
@@ -253,7 +253,7 @@ ani_enum_item ScreenAniUtils::CreateAniEnum(ani_env* env, const char* enum_descr
|
||||
static DmErrorCode GetScreenFocusFromAni(ani_env* env, ani_object virtualScreenObj, VirtualScreenOption& option)
|
||||
{
|
||||
ani_ref focus = nullptr;
|
||||
if (env->Object_GetPropertyByName_Ref(virtualScreenObj, "%%property-supportsFocus", &focus) != ANI_OK) {
|
||||
if (env->Object_GetPropertyByName_Ref(virtualScreenObj, "supportsFocus", &focus) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::DMS, "Failed to get supportsFocus.");
|
||||
return DmErrorCode::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ ohos_shared_library("screenshotani_kit") {
|
||||
"runtime_core:ani_helpers",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -61,4 +61,5 @@ ohos_shared_library("ani_window_animation_utils") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ ohos_shared_library("windowstageani_kit") {
|
||||
"runtime_core:ani_helpers",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -568,6 +568,8 @@ namespace window {
|
||||
currentLayoutMode?: string;
|
||||
parentWindowSizeChangeCallback? :Callback<Size>;
|
||||
parentWindowStatusChangeCallback? :Callback<WindowStatusType>;
|
||||
isIntersectedHeightLimit?: boolean;
|
||||
isIntersectedWidthLimit?: boolean;
|
||||
}
|
||||
|
||||
export interface Rect {
|
||||
@@ -982,6 +984,7 @@ export interface WindowInfo {
|
||||
globalRect?: Rect;
|
||||
displayId?: long;
|
||||
bundleName: string;
|
||||
moduleName: string;
|
||||
abilityName: string;
|
||||
windowId: int;
|
||||
windowStatusType: WindowStatusType;
|
||||
@@ -994,6 +997,7 @@ export class WindowInfoInternal implements WindowInfo {
|
||||
globalRect?: Rect;
|
||||
displayId?: long;
|
||||
bundleName: string;
|
||||
moduleName: string;
|
||||
abilityName: string;
|
||||
windowId: int;
|
||||
windowStatusType: WindowStatusType;
|
||||
|
||||
@@ -5416,6 +5416,49 @@ void AniWindow::OnSetRelativePositionToParentWindowEnabled(ani_env* env, ani_boo
|
||||
}
|
||||
}
|
||||
|
||||
static void RegisterAttachOptionCallbacks(sptr<Window> windowToken, ani_env* env, ani_object attachOptions,
|
||||
std::unique_ptr<AniWindowRegisterManager>& registerManager)
|
||||
{
|
||||
auto getPropertyAndCheckUndefined = [env](ani_object obj, const char* propName,
|
||||
ani_ref& outRef, std::string_view errorPrefix) -> bool {
|
||||
if (env->Object_GetPropertyByName_Ref(obj, propName, &outRef) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "%s: Failed to get %s.", errorPrefix.data(), propName);
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
std::string("Failed to get") + propName + ".");
|
||||
return false;
|
||||
}
|
||||
ani_boolean isUndefined;
|
||||
if (env->Reference_IsUndefined(outRef, &isUndefined) != ANI_OK || isUndefined) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "[ANI] Check %s isUndefined fail", propName);
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
ani_ref parentWindowSizeChangeCallback;
|
||||
if (!getPropertyAndCheckUndefined(attachOptions, "parentWindowSizeChangeCallback",
|
||||
parentWindowSizeChangeCallback, "parentWindowSizeChangeCallback")) {
|
||||
return;
|
||||
}
|
||||
if (parentWindowSizeChangeCallback && registerManager->RegisterListener(windowToken, "parentWindowSizeChange",
|
||||
CaseType::CASE_WINDOW, env, parentWindowSizeChangeCallback, 0) != WmErrorCode::WM_OK) {
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
return;
|
||||
}
|
||||
|
||||
ani_ref parentWindowStatusChangeCallback;
|
||||
if (!getPropertyAndCheckUndefined(attachOptions, "parentWindowStatusChangeCallback",
|
||||
parentWindowStatusChangeCallback, "parentWindowStatusChangeCallback")) {
|
||||
return;
|
||||
}
|
||||
if (parentWindowStatusChangeCallback && registerManager->RegisterListener(windowToken, "parentWindowStatusChange",
|
||||
CaseType::CASE_WINDOW, env, parentWindowStatusChangeCallback, 0) != WmErrorCode::WM_OK) {
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AniWindow::AttachLayoutToParentWindow(ani_env* env, ani_object Obj, ani_long nativeObj, ani_object anchorInfo,
|
||||
ani_object attachOptions)
|
||||
{
|
||||
@@ -5432,22 +5475,35 @@ void AniWindow::AttachLayoutToParentWindow(ani_env* env, ani_object Obj, ani_lon
|
||||
static void ParseAttachOptions(sptr<Window> windowToken, ani_env* env, ani_object attachOptions,
|
||||
std::unique_ptr<AniWindowRegisterManager>& registerManager, WindowAnchorInfo::AttachOptions& options)
|
||||
{
|
||||
auto getPropertyAndCheckUndefined = [env](ani_object obj, const char* propName,
|
||||
ani_ref& outRef, std::string_view errorPrefix) -> bool {
|
||||
if (env->Object_GetPropertyByName_Ref(obj, propName, &outRef) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "%s: Failed to get %s.", errorPrefix.data(), propName);
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
std::string("Failed to get") + propName + ".");
|
||||
return false;
|
||||
}
|
||||
ani_boolean isUndefined;
|
||||
if (env->Reference_IsUndefined(outRef, &isUndefined) != ANI_OK || isUndefined) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "[ANI] Check %s isUndefined fail", propName);
|
||||
// Helper lambda to parse boolean property from attachOptions
|
||||
auto parseBooleanProperty = [env, attachOptions](const char* propName, bool& outValue) -> bool {
|
||||
ani_ref valueRet;
|
||||
if (env->Object_GetPropertyByName_Ref(attachOptions, propName, &valueRet) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to get %s.", propName);
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM,
|
||||
std::string("Failed to get ") + propName + ".");
|
||||
return false;
|
||||
}
|
||||
ani_boolean isUndefined;
|
||||
if (env->Reference_IsUndefined(valueRet, &isUndefined) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "[ANI] Check %s isUndefined fail", propName);
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
return false;
|
||||
}
|
||||
if (!isUndefined) {
|
||||
ani_boolean boolValue;
|
||||
if (env->Object_CallMethodByName_Boolean(static_cast<ani_object>(valueRet),
|
||||
"toBoolean", ":z", &boolValue) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to get boolean value for %s.", propName);
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
outValue = static_cast<bool>(boolValue);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// Parse currentLayoutMode
|
||||
ani_ref nameValueRet;
|
||||
if (env->Object_GetPropertyByName_Ref(attachOptions, "currentLayoutMode", &nameValueRet) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to get currentLayoutMode.");
|
||||
@@ -5466,26 +5522,18 @@ static void ParseAttachOptions(sptr<Window> windowToken, ani_env* env, ani_objec
|
||||
static_cast<ani_string>(nameValueRet));
|
||||
options.currentLayoutMode = currentLayoutMode;
|
||||
}
|
||||
ani_ref parentWindowSizeChangeCallback;
|
||||
if (!getPropertyAndCheckUndefined(attachOptions, "parentWindowSizeChangeCallback",
|
||||
parentWindowSizeChangeCallback, "parentWindowSizeChangeCallback")) {
|
||||
|
||||
// Parse isIntersectedHeightLimit
|
||||
if (!parseBooleanProperty("isIntersectedHeightLimit", options.isIntersectedHeightLimit)) {
|
||||
return;
|
||||
}
|
||||
if (parentWindowSizeChangeCallback && registerManager->RegisterListener(windowToken, "parentWindowSizeChange",
|
||||
CaseType::CASE_WINDOW, env, parentWindowSizeChangeCallback, 0) != WmErrorCode::WM_OK) {
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
return;
|
||||
}
|
||||
ani_ref parentWindowStatusChangeCallback;
|
||||
if (!getPropertyAndCheckUndefined(attachOptions, "parentWindowStatusChangeCallback",
|
||||
parentWindowStatusChangeCallback, "parentWindowStatusChangeCallback")) {
|
||||
return;
|
||||
}
|
||||
if (parentWindowStatusChangeCallback && registerManager->RegisterListener(windowToken, "parentWindowStatusChange",
|
||||
CaseType::CASE_WINDOW, env, parentWindowStatusChangeCallback, 0) != WmErrorCode::WM_OK) {
|
||||
AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
|
||||
|
||||
// Parse isIntersectedWidthLimit
|
||||
if (!parseBooleanProperty("isIntersectedWidthLimit", options.isIntersectedWidthLimit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RegisterAttachOptionCallbacks(windowToken, env, attachOptions, registerManager);
|
||||
}
|
||||
|
||||
void AniWindow::OnAttachToParentWindow(ani_env* env, ani_object anchorInfo,
|
||||
@@ -5531,10 +5579,17 @@ void AniWindow::OnAttachToParentWindow(ani_env* env, ani_object anchorInfo,
|
||||
WindowAnchorInfo windowAnchorInfo = { true, true, acceptWindowAnchorInfo.windowAnchor_,
|
||||
acceptWindowAnchorInfo.offsetX_, acceptWindowAnchorInfo.offsetY_};
|
||||
windowAnchorInfo.attachOptions.currentLayoutMode = acceptWindowAnchorInfo.attachOptions.currentLayoutMode;
|
||||
windowAnchorInfo.attachOptions.isIntersectedHeightLimit =
|
||||
acceptWindowAnchorInfo.attachOptions.isIntersectedHeightLimit;
|
||||
windowAnchorInfo.attachOptions.isIntersectedWidthLimit =
|
||||
acceptWindowAnchorInfo.attachOptions.isIntersectedWidthLimit;
|
||||
windowAnchorInfo.isFromAttachOrDetach_ = true;
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "windowAnchorInfo %{public}d, offsetX:%{public}d, offset:%{public}d currentLayoutMode:"
|
||||
"%{public}s", windowAnchorInfo.windowAnchor_, windowAnchorInfo.offsetX_, windowAnchorInfo.offsetY_,
|
||||
windowAnchorInfo.attachOptions.currentLayoutMode.c_str());
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "windowAnchorInfo %{public}d, offsetX:%{public}d, offset:%{public}d "
|
||||
"currentLayoutMode:%{public}s, isIntersectedHeightLimit:%{public}d, isIntersectedWidthLimit:%{public}d",
|
||||
windowAnchorInfo.windowAnchor_, windowAnchorInfo.offsetX_, windowAnchorInfo.offsetY_,
|
||||
windowAnchorInfo.attachOptions.currentLayoutMode.c_str(),
|
||||
windowAnchorInfo.attachOptions.isIntersectedHeightLimit,
|
||||
windowAnchorInfo.attachOptions.isIntersectedWidthLimit);
|
||||
auto setWindowAnchorInfoRet = windowToken_->SetWindowAnchorInfo(windowAnchorInfo);
|
||||
auto it = WM_JS_TO_ERROR_CODE_MAP.find(setWindowAnchorInfoRet);
|
||||
WmErrorCode errorCode = (it != WM_JS_TO_ERROR_CODE_MAP.end()) ? it->second : WmErrorCode::WM_ERROR_STATE_ABNORMALLY;
|
||||
|
||||
@@ -873,6 +873,12 @@ ani_object AniWindowUtils::CreateAniWindowInfo(ani_env* env, const WindowVisibil
|
||||
return AniWindowUtils::CreateAniUndefined(env);
|
||||
}
|
||||
CallAniMethodVoid(env, windowInfo, cls, Builder::BuildSetterName("bundleName").c_str(), nullptr, bundleName);
|
||||
ani_string moduleName;
|
||||
if (GetAniString(env, info.GetModuleName(), &moduleName) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "[ANI] create string failed");
|
||||
return AniWindowUtils::CreateAniUndefined(env);
|
||||
}
|
||||
CallAniMethodVoid(env, windowInfo, cls, Builder::BuildSetterName("moduleName").c_str(), nullptr, moduleName);
|
||||
ani_string abilityName;
|
||||
if (GetAniString(env, info.GetAbilityName(), &abilityName) != ANI_OK) {
|
||||
TLOGE(WmsLogTag::WMS_ATTRIBUTE, "[ANI] create string failed");
|
||||
|
||||
@@ -65,6 +65,7 @@ ohos_shared_library("cj_display_ffi") {
|
||||
sources = [ "display_runtime_mock.cpp" ]
|
||||
external_deps = [ "napi:cj_bind_ffi" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -50,6 +50,7 @@ ohos_shared_library("cj_screenshot_ffi") {
|
||||
sources = [ "display_runtime_mock.cpp" ]
|
||||
external_deps = [ "napi:cj_bind_ffi" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -79,6 +79,7 @@ ohos_shared_library("cj_window_ffi") {
|
||||
sources = [ "window_mock.cpp" ]
|
||||
external_deps = [ "napi:cj_bind_ffi" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -18,6 +18,7 @@ group("napi_packages") {
|
||||
"display_runtime:display_napi",
|
||||
"embeddable_window_stage:embeddablewindowstage_kit",
|
||||
"environmental:windowenv_packages",
|
||||
"environmental/inner:windowenv_napi",
|
||||
"extension:uiextension_napi",
|
||||
"extension_window:extensionwindow_napi",
|
||||
"picture_in_picture_napi:pipwindow_napi",
|
||||
|
||||
@@ -61,7 +61,7 @@ ohos_shared_library("display_napi") {
|
||||
"graphic_surface:surface",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"image_framework:image_native",
|
||||
"image_framework:image_native",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
@@ -111,6 +111,7 @@ ohos_shared_library("display_kit") {
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -46,6 +46,7 @@ constexpr size_t ARGC_TWO = 2;
|
||||
constexpr size_t ARGC_THREE = 3;
|
||||
constexpr size_t ARGS_MAX = 4;
|
||||
constexpr int32_t INDEX_ONE = 1;
|
||||
constexpr size_t BUNDLE_NAME_LIST_MAX_SIZE = 100;
|
||||
class JsDisplayManager {
|
||||
public:
|
||||
explicit JsDisplayManager(napi_env env) {
|
||||
@@ -1026,16 +1027,51 @@ napi_value OnIsFoldable(napi_env env, napi_callback_info info)
|
||||
napi_value OnIsCaptured(napi_env env, napi_callback_info info)
|
||||
{
|
||||
std::string functionName = "isCaptured";
|
||||
size_t argc = 4; // default arg length
|
||||
napi_value argv[4] = { nullptr }; // default arg length
|
||||
size_t argc = ARGC_ONE;
|
||||
napi_value argv[ARGC_ONE] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc >= ARGC_ONE) {
|
||||
napi_throw(env, JsErrUtils::CreateJsError(env, DmErrorCode::DM_ERROR_INVALID_PARAM,
|
||||
GetFormatMsg(functionName, "Input parameter invalid")));
|
||||
return NapiGetUndefined(env);
|
||||
|
||||
if (argc > ARGC_ONE) {
|
||||
return NapiThrowError(env, DmErrorCode::DM_ERROR_ILLEGAL_PARAM,
|
||||
"Input parameter invalid", functionName);
|
||||
}
|
||||
bool isCapture = SingletonContainer::Get<DisplayManager>().IsCaptured();
|
||||
TLOGD(WmsLogTag::DMS, "[NAPI]IsCaptured = %{public}u", isCapture);
|
||||
|
||||
if (argc == 0) {
|
||||
bool isCapture = SingletonContainer::Get<DisplayManager>().IsCaptured();
|
||||
TLOGD(WmsLogTag::DMS, "[NAPI]IsCaptured = %{public}u", isCapture);
|
||||
napi_value result;
|
||||
napi_get_boolean(env, isCapture, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value nativeArray = argv[0];
|
||||
uint32_t size = 0;
|
||||
if (GetType(env, nativeArray) != napi_object ||
|
||||
napi_get_array_length(env, nativeArray, &size) != napi_ok) {
|
||||
return NapiThrowError(env, DmErrorCode::DM_ERROR_ILLEGAL_PARAM,
|
||||
"Failed to convert parameter to bundleNameList array", functionName);
|
||||
}
|
||||
|
||||
if (size > BUNDLE_NAME_LIST_MAX_SIZE) {
|
||||
return NapiThrowError(env, DmErrorCode::DM_ERROR_ILLEGAL_PARAM,
|
||||
"The size of bundleNameList is larger than 100", functionName);
|
||||
}
|
||||
|
||||
std::vector<std::string> bundleNameList;
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
std::string bundleName;
|
||||
napi_value element = nullptr;
|
||||
napi_get_element(env, nativeArray, i, &element);
|
||||
if (!ConvertFromJsValue(env, element, bundleName)) {
|
||||
return NapiThrowError(env, DmErrorCode::DM_ERROR_ILLEGAL_PARAM,
|
||||
"Failed to convert parameter to bundle name", functionName);
|
||||
}
|
||||
bundleNameList.push_back(bundleName);
|
||||
}
|
||||
|
||||
bool isCapture = SingletonContainer::Get<DisplayManager>().IsCapturedByBundleNameList(bundleNameList);
|
||||
TLOGI(WmsLogTag::DMS, "[NAPI] BundleNameList size: %{public}zu, isCapturedByBundleNameList: %{public}u.",
|
||||
bundleNameList.size(), isCapture);
|
||||
napi_value result;
|
||||
napi_get_boolean(env, isCapture, &result);
|
||||
return result;
|
||||
@@ -1194,6 +1230,7 @@ napi_value OnCreateVirtualScreen(napi_env env, napi_callback_info info)
|
||||
TLOGI(WmsLogTag::DMS, "called");
|
||||
DmErrorCode errCode = DmErrorCode::DM_OK;
|
||||
VirtualScreenOption option;
|
||||
option.caller_ = VirtualScreenCaller::JS_DISPLAY_MANAGER;
|
||||
size_t argc = 4;
|
||||
std::string errMsg = "";
|
||||
napi_value argv[4] = {nullptr};
|
||||
|
||||
@@ -127,4 +127,5 @@ ohos_shared_library("embeddablewindowstage_kit") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
@@ -25,6 +25,14 @@ name_mapping = [
|
||||
{
|
||||
js_file = "$target_out_dir/engine/WindowFocusEnv.js"
|
||||
abc_name = "windowfocusenv"
|
||||
},
|
||||
{
|
||||
js_file = "$target_out_dir/engine/SystemDensityEnv.js"
|
||||
abc_name = "systemdensityenv"
|
||||
},
|
||||
{
|
||||
js_file = "$target_out_dir/engine/DisplayIdEnv.js"
|
||||
abc_name = "displayidenv"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
# Copyright (c) 2026 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("../../../../../windowmanager_aafwk.gni")
|
||||
|
||||
config("windowenv_manager_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "../../../../../wm/include" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("windowenv_napi") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcall_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
"js_windowenv_manager.cpp",
|
||||
"js_windowenv_module.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../../../../../utils:libwmutil",
|
||||
"../../../../../utils:libwmutil_base",
|
||||
"../../../../../wm:libwm",
|
||||
"../../extension_window:extensionwindow_napi",
|
||||
"../../window_runtime:window_native_kit",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:runtime",
|
||||
"ace_engine:ace_uicontent",
|
||||
"ace_engine:ace_xcomponent_controller",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
relative_install_dir = "module"
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
defines = []
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2026 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 "js_windowenv_manager.h"
|
||||
|
||||
#include "dm_common.h"
|
||||
#include "js_extension_window.h"
|
||||
#include "js_window.h"
|
||||
#include "ui_content.h"
|
||||
#include "wm_common.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using namespace AbilityRuntime;
|
||||
namespace {
|
||||
const int32_t INVALID_INSTANCEID = -1;
|
||||
constexpr size_t ARGC_ONE = 1;
|
||||
constexpr size_t ARGC_FOUR = 4;
|
||||
}
|
||||
napi_value FindJsExtensionWindowById(napi_env env, int32_t id);
|
||||
|
||||
static napi_value CreateJsNumber(napi_env env, uint64_t value)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
napi_create_int64(env, static_cast<int64_t>(value), &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value NapiGetUndefined(napi_env env)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
napi_get_undefined(env, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
sptr<Window> GetWindowByInstanceId(int32_t instanceId)
|
||||
{
|
||||
int32_t windowId = Ace::UIContent::GetUIContentWindowID(instanceId);
|
||||
auto uicontent = Ace::UIContent::GetUIContent(instanceId);
|
||||
if (!uicontent) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "uicontent nullptr instanceId: %{public}d, windowId: %{public}d",
|
||||
instanceId, windowId);
|
||||
return nullptr;
|
||||
}
|
||||
auto window = sptr<Window>(uicontent->GetUIContentWindow());
|
||||
if (window == nullptr) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "window nullptr %{public}d", windowId);
|
||||
return nullptr;
|
||||
}
|
||||
return window;
|
||||
}
|
||||
|
||||
JsWindowEnvManager::JsWindowEnvManager()
|
||||
{
|
||||
}
|
||||
|
||||
JsWindowEnvManager::~JsWindowEnvManager()
|
||||
{
|
||||
}
|
||||
|
||||
void JsWindowEnvManager::Finalizer(napi_env env, void* data, void* hint)
|
||||
{
|
||||
TLOGD(WmsLogTag::DEFAULT, "Finalizer");
|
||||
std::unique_ptr<JsWindowEnvManager>(static_cast<JsWindowEnvManager*>(data));
|
||||
}
|
||||
|
||||
napi_value JsWindowEnvManager::FindWindowById(napi_env env, napi_callback_info info)
|
||||
{
|
||||
JsWindowEnvManager* me = CheckParamsAndGetThis<JsWindowEnvManager>(env, info);
|
||||
return (me != nullptr) ? me->OnFindWindowById(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsWindowEnvManager::OnFindWindowById(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_FOUR;
|
||||
napi_value argv[ARGC_FOUR] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < ARGC_ONE) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "Invalid param size");
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
int32_t instanceId = INVALID_INSTANCEID;
|
||||
if (!ConvertFromJsValue(env, argv[0], instanceId) || instanceId == INVALID_INSTANCEID) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "invalid instanceId value: %{public}d", instanceId);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
auto window = GetWindowByInstanceId(instanceId);
|
||||
if (window == nullptr) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "window nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (window->GetType() == WindowType::WINDOW_TYPE_UI_EXTENSION) {
|
||||
return FindJsExtensionWindowById(env, window->GetWindowPersistentId());
|
||||
}
|
||||
return CreateJsWindowObject(env, window);
|
||||
}
|
||||
|
||||
|
||||
napi_value JsWindowEnvManager::GetDisplayId(napi_env env, napi_callback_info info)
|
||||
{
|
||||
JsWindowEnvManager* me = CheckParamsAndGetThis<JsWindowEnvManager>(env, info);
|
||||
return (me != nullptr) ? me->OnGetDisplayId(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsWindowEnvManager::OnGetDisplayId(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_FOUR;
|
||||
napi_value argv[ARGC_FOUR] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc < ARGC_ONE) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "Invalid param size");
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
int32_t instanceId = INVALID_INSTANCEID;
|
||||
if (!ConvertFromJsValue(env, argv[0], instanceId) || instanceId == INVALID_INSTANCEID) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "invalid instanceId value: %{public}d", instanceId);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
auto window = GetWindowByInstanceId(instanceId);
|
||||
if (window == nullptr) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "window nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
if (window->GetType() == WindowType::WINDOW_TYPE_UI_EXTENSION && !window->GetIsAtomicService()) {
|
||||
return CreateJsNumber(env, static_cast<uint64_t>(DISPLAY_ID_INVALID));
|
||||
}
|
||||
return CreateJsNumber(env, window->GetDisplayId());
|
||||
}
|
||||
|
||||
napi_value JsWindowEnvManagerInit(napi_env env, napi_value exportObj)
|
||||
{
|
||||
TLOGD(WmsLogTag::DEFAULT, "JsWindowEnvManagerInit");
|
||||
|
||||
if (env == nullptr || exportObj == nullptr) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "JsWindowEnvManagerInit env or exportObj is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<JsWindowEnvManager> jsWinEnvManager = std::make_unique<JsWindowEnvManager>();
|
||||
napi_wrap(env, exportObj, jsWinEnvManager.release(), JsWindowEnvManager::Finalizer, nullptr, nullptr);
|
||||
|
||||
const char *moduleName = "JsWindowEnvManager";
|
||||
BindNativeFunction(env, exportObj, "findWindowById", moduleName, JsWindowEnvManager::FindWindowById);
|
||||
BindNativeFunction(env, exportObj, "getDisplayId", moduleName, JsWindowEnvManager::GetDisplayId);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2026 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_JS_WINDOW_ENV_NAPI_H
|
||||
#define OHOS_JS_WINDOW_ENV_NAPI_H
|
||||
|
||||
#include "js_runtime_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
napi_value JsWindowEnvManagerInit(napi_env env, napi_value exportObj);
|
||||
|
||||
class JsWindowEnvManager {
|
||||
public:
|
||||
JsWindowEnvManager();
|
||||
~JsWindowEnvManager();
|
||||
static void Finalizer(napi_env env, void* data, void* hint);
|
||||
static napi_value FindWindowById(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDisplayId(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
static napi_value OnFindWindowById(napi_env env, napi_callback_info info);
|
||||
static napi_value OnGetDisplayId(napi_env env, napi_callback_info info);
|
||||
};
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_JS_WINDOW_ENV_NAPI_H
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2026 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 "js_windowenv_manager.h"
|
||||
|
||||
static napi_module g_windowenvManagerModule = {
|
||||
.nm_filename = "module/libwindowenv_napi.so/windowenv.js",
|
||||
.nm_register_func = OHOS::Rosen::JsWindowEnvManagerInit,
|
||||
.nm_modname = "windowenv",
|
||||
};
|
||||
|
||||
extern "C" __attribute__((constructor)) void NAPI_application_windowenvmanager_AutoRegister()
|
||||
{
|
||||
napi_module_register(&g_windowenvManagerModule);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2026 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.
|
||||
*/
|
||||
|
||||
const windowenv = requireInternal('windowenv');
|
||||
const hilog = requireInternal('hilog');
|
||||
const HILOG_DOMAIN = 0x04217;
|
||||
const HILOG_TAG = 'WMSAttribute';
|
||||
|
||||
@ObservedV2
|
||||
class DisplayIdEnv implements IEnvironmentValue<window.DisplayId> {
|
||||
@Trace public displayId: number = -1;
|
||||
#win: window.Window | uiExtension.WindowProxy;
|
||||
|
||||
get value(): window.DisplayId {
|
||||
return this;
|
||||
}
|
||||
|
||||
constructor(context: UIContext) {
|
||||
try {
|
||||
this.#win = windowenv.findWindowById(context.getId());
|
||||
this.displayId = windowenv.getDisplayId(context.getId());
|
||||
this.#win.on('displayIdChange', this.#displayIdChangeCallback);
|
||||
} catch (error) {
|
||||
hilog.error(HILOG_DOMAIN, HILOG_TAG, `[env] displayId env constructor failed, ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
#displayIdChangeCallback = (displayId: number): void => {
|
||||
this.displayId = displayId;
|
||||
};
|
||||
|
||||
update(): void {}
|
||||
|
||||
destroy(): void {
|
||||
try {
|
||||
this.#win.off('displayIdChange', this.#displayIdChangeCallback);
|
||||
} catch (error) {
|
||||
hilog.error(HILOG_DOMAIN, HILOG_TAG, `[env] px env destroy failed, ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
DisplayIdEnv
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2026 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.
|
||||
*/
|
||||
|
||||
const windowenv = requireInternal('windowenv');
|
||||
const hilog = requireInternal('hilog');
|
||||
const HILOG_DOMAIN = 0x04217;
|
||||
const HILOG_TAG = 'WMSAttribute';
|
||||
|
||||
@ObservedV2
|
||||
class SystemDensityEnv implements IEnvironmentValue<window.SystemDensity> {
|
||||
@Trace public systemDensity: number = -1.0;
|
||||
#win: window.Window | uiExtension.WindowProxy;
|
||||
|
||||
get value(): window.SystemDensity {
|
||||
return this;
|
||||
}
|
||||
|
||||
constructor(context: UIContext) {
|
||||
try {
|
||||
this.#win = windowenv.findWindowById(context.getId());
|
||||
const windowDensityInfo: window.WindowDensityInfo = this.#win.getWindowDensityInfo();
|
||||
this.systemDensity = windowDensityInfo.systemDensity;
|
||||
this.#win.on('systemDensityChange', this.#systemDensityChangeCallback);
|
||||
} catch (error) {
|
||||
hilog.error(HILOG_DOMAIN, HILOG_TAG, `[env] density env constructor failed, ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
#systemDensityChangeCallback = (systemDensity: number): void => {
|
||||
this.systemDensity = systemDensity;
|
||||
};
|
||||
|
||||
update(): void {}
|
||||
|
||||
destroy(): void {
|
||||
try {
|
||||
this.#win.off('systemDensityChange', this.#systemDensityChangeCallback);
|
||||
} catch (error) {
|
||||
hilog.error(HILOG_DOMAIN, HILOG_TAG, `[env] px env destroy failed, ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
SystemDensityEnv
|
||||
}
|
||||
@@ -72,9 +72,24 @@ declare namespace window {
|
||||
WINDOW_DESTROYED = 7
|
||||
}
|
||||
|
||||
interface WindowDensityInfo {
|
||||
systemDensity: number;
|
||||
defaultDensity: number;
|
||||
customDensity: number;
|
||||
}
|
||||
|
||||
interface SystemDensity {
|
||||
systemDensity: number;
|
||||
}
|
||||
|
||||
interface DisplayId {
|
||||
displayId: number;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
getWindowProperties(): { windowRect: Size };
|
||||
getWindowAvoidArea(type: number): AvoidArea;
|
||||
getWindowDensityInfo(): window.WindowDensityInfo;
|
||||
on(type: 'windowSizeChange', callback: Callback<Size>): void;
|
||||
off(type: 'windowSizeChange', callback?: Callback<Size>): void;
|
||||
on(type: 'avoidAreaChange', callback: Callback<AvoidAreaOptions>): void;
|
||||
@@ -83,13 +98,39 @@ declare namespace window {
|
||||
off(type: 'windowEvent', callback?: Callback<WindowEventType>): void;
|
||||
on(type: 'windowHighlightChange', callback: Callback<boolean>): void;
|
||||
off(type: 'windowHighlightChange', callback?: Callback<boolean>): void;
|
||||
on(type: 'systemDensityChange', callback: Callback<number>): void;
|
||||
off(type: 'systemDensityChange', callback?: Callback<number>): void;
|
||||
on(type: 'displayIdChange', callback: Callback<number>): void;
|
||||
off(type: 'displayIdChange', callback?: Callback<number>): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace uiExtension {
|
||||
interface WindowProxy {
|
||||
getWindowProperties(): { windowRect: window.Size };
|
||||
getWindowAvoidArea(type: number): window.AvoidArea;
|
||||
getWindowDensityInfo(): window.WindowDensityInfo;
|
||||
on(type: 'windowSizeChange', callback: Callback<window.Size>): void;
|
||||
off(type: 'windowSizeChange', callback?: Callback<window.Size>): void;
|
||||
on(type: 'avoidAreaChange', callback: Callback<window.AvoidAreaOptions>): void;
|
||||
off(type: 'avoidAreaChange', callback?: Callback<window.AvoidAreaOptions>): void;
|
||||
on(type: 'systemDensityChange', callback: Callback<number>): void;
|
||||
off(type: 'systemDensityChange', callback?: Callback<number>): void;
|
||||
on(type: 'displayIdChange', callback: Callback<number>): void;
|
||||
off(type: 'displayIdChange', callback?: Callback<number>): void;
|
||||
}
|
||||
}
|
||||
|
||||
interface WindowEnv {
|
||||
findWindowById(value: number): window.Window | uiExtension.WindowProxy;
|
||||
getDisplayId(value: number): number;
|
||||
}
|
||||
|
||||
declare class UIContext {
|
||||
getWindowName(): string;
|
||||
getUIObserver(): UIObserver;
|
||||
px2vp(value: number): number;
|
||||
getId(): number;
|
||||
}
|
||||
|
||||
declare namespace uiObserver {
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
"./src/common.d.ts",
|
||||
"./src/WindowSizeEnv.ts",
|
||||
"./src/WindowAvoidAreaEnv.ts",
|
||||
"./src/WindowFocusEnv.ts"
|
||||
"./src/WindowFocusEnv.ts",
|
||||
"./src/SystemDensityEnv.ts",
|
||||
"./src/DisplayIdEnv.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
|
||||
@@ -59,6 +59,17 @@ const std::unordered_set<std::string> g_unsupportListener = {
|
||||
const std::unordered_set<std::string> g_invalidListener = {
|
||||
"subWindowClose",
|
||||
};
|
||||
const std::unordered_set<std::string> g_emptyProxyListener = {
|
||||
"displayIdChange",
|
||||
"systemDensityChange",
|
||||
};
|
||||
static thread_local std::map<int32_t, std::shared_ptr<NativeReference>> g_jsExtensionWindowMap;
|
||||
static std::mutex g_extensionMutex;
|
||||
|
||||
bool IsEmptyProxyListener(const std::string& type)
|
||||
{
|
||||
return g_emptyProxyListener.find(type) != g_emptyProxyListener.end();
|
||||
}
|
||||
|
||||
bool IsEmptyListener(const std::string& type)
|
||||
{
|
||||
@@ -76,6 +87,33 @@ bool IsInvalidListener(const std::string& type)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void addJsExtensionWindow(napi_env env, napi_value objValue, int32_t id)
|
||||
{
|
||||
std::shared_ptr<NativeReference> jsExtensionWindowRef;
|
||||
napi_ref result = nullptr;
|
||||
napi_create_reference(env, objValue, 1, &result);
|
||||
jsExtensionWindowRef.reset(reinterpret_cast<NativeReference*>(result));
|
||||
std::lock_guard<std::mutex> lock(g_extensionMutex);
|
||||
g_jsExtensionWindowMap[id] = jsExtensionWindowRef;
|
||||
}
|
||||
|
||||
napi_value FindJsExtensionWindowById(napi_env env, int32_t id)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_extensionMutex);
|
||||
if (g_jsExtensionWindowMap.find(id) == g_jsExtensionWindowMap.end()) {
|
||||
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,
|
||||
"The extensionWindow is destroyed."));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
napi_value extensionWindow = g_jsExtensionWindowMap[id]->GetNapiValue();
|
||||
if (!extensionWindow) {
|
||||
napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY,
|
||||
"The extensionWindow is destroyed."));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
return extensionWindow;
|
||||
}
|
||||
|
||||
const std::string& JsExtensionWindow::GetWindowName() const
|
||||
{
|
||||
return windowName_;
|
||||
@@ -134,7 +172,9 @@ napi_value JsExtensionWindow::CreateJsExtensionWindow(napi_env env, sptr<Rosen::
|
||||
BindNativeFunction(env, objValue, "hidePrivacyContentForHost", moduleName,
|
||||
JsExtensionWindow::HidePrivacyContentForHost);
|
||||
BindNativeFunction(env, objValue, "occupyEvents", moduleName, JsExtensionWindow::OccupyEvents);
|
||||
BindNativeFunction(env, objValue, "getWindowDensityInfo", moduleName, JsExtensionWindow::GetWindowDensityInfo);
|
||||
|
||||
addJsExtensionWindow(env, objValue, window->GetWindowPersistentId());
|
||||
return objValue;
|
||||
}
|
||||
|
||||
@@ -206,6 +246,7 @@ napi_value JsExtensionWindow::CreateJsExtensionWindowObject(napi_env env, sptr<R
|
||||
|
||||
RegisterUnsupportFuncs(env, objValue, moduleName);
|
||||
|
||||
addJsExtensionWindow(env, objValue, window->GetWindowPersistentId());
|
||||
return objValue;
|
||||
}
|
||||
|
||||
@@ -1114,6 +1155,10 @@ napi_value JsExtensionWindow::OnRegisterExtensionWindowCallback(napi_env env, na
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT,
|
||||
"[window][on]msg: The device not support");
|
||||
}
|
||||
} else {
|
||||
if (IsEmptyProxyListener(cbType)) {
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
}
|
||||
napi_value value = argv[INDEX_ONE];
|
||||
if (!NapiIsCallable(env, value)) {
|
||||
@@ -1180,6 +1225,10 @@ napi_value JsExtensionWindow::OnUnRegisterExtensionWindowCallback(napi_env env,
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT,
|
||||
"[window][off]msg: The device not support");
|
||||
}
|
||||
} else {
|
||||
if (IsEmptyProxyListener(cbType)) {
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
}
|
||||
|
||||
napi_value value = nullptr;
|
||||
|
||||
@@ -105,6 +105,7 @@ ohos_shared_library("screen_kit") {
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -979,6 +979,7 @@ napi_value OnCreateVirtualScreen(napi_env env, napi_callback_info info)
|
||||
TLOGI(WmsLogTag::DMS, "called");
|
||||
DmErrorCode errCode = DmErrorCode::DM_OK;
|
||||
VirtualScreenOption option;
|
||||
option.caller_ = VirtualScreenCaller::JS_SCREEN_MANAGER;
|
||||
size_t argc = 4;
|
||||
std::string errMsg = "";
|
||||
napi_value argv[4] = {nullptr};
|
||||
|
||||
@@ -61,4 +61,5 @@ ohos_shared_library("window_animation_utils") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ ohos_shared_library("window_native_kit") {
|
||||
}
|
||||
|
||||
version_script = "libwindow_native_kit.map"
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("window_napi") {
|
||||
@@ -257,4 +258,5 @@ ohos_shared_library("windowstage_kit") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
@@ -7769,12 +7769,10 @@ bool JsWindow::ParseWindowAnchorInfo(napi_env env, napi_value jsObject, WindowAn
|
||||
bool JsWindow::ParseWindowAttachOptions(napi_env env, napi_value jsObject,
|
||||
WindowAnchorInfo::AttachOptions& subWindowAttachOptions)
|
||||
{
|
||||
std::string data = "";
|
||||
std::string defaultValue = "";
|
||||
if (GetType(env, jsObject) != napi_object) {
|
||||
return false;
|
||||
}
|
||||
auto parseField = [](napi_env& env, const char* fieldName, std::string& data, auto& field, auto& defValue,
|
||||
auto parseField = [](napi_env& env, const char* fieldName, auto& data, auto& field, const auto& defValue,
|
||||
napi_value& jsObject) -> bool {
|
||||
if (!ParseJsValueOrGetDefault(jsObject, env, fieldName, data, defValue)) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert object to %{public}s", fieldName);
|
||||
@@ -7784,9 +7782,25 @@ bool JsWindow::ParseWindowAttachOptions(napi_env env, napi_value jsObject,
|
||||
return true;
|
||||
};
|
||||
|
||||
std::string data = "";
|
||||
std::string defaultValue = "";
|
||||
if (!parseField(env, "currentLayoutMode", data, subWindowAttachOptions.currentLayoutMode, defaultValue, jsObject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool defaultBoolValue = false;
|
||||
bool boolData = false;
|
||||
if (!parseField(env, "isIntersectedHeightLimit", boolData, subWindowAttachOptions.isIntersectedHeightLimit,
|
||||
defaultBoolValue, jsObject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolData = defaultBoolValue;
|
||||
if (!parseField(env, "isIntersectedWidthLimit", boolData, subWindowAttachOptions.isIntersectedWidthLimit,
|
||||
defaultBoolValue, jsObject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8074,10 +8088,15 @@ napi_value JsWindow::OnAttachToParentWindow(napi_env env, napi_callback_info inf
|
||||
napi_value result = nullptr;
|
||||
std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result);
|
||||
acceptAnchorInfo.attachOptions.currentLayoutMode = windowAttachOptions.currentLayoutMode;
|
||||
acceptAnchorInfo.attachOptions.isIntersectedHeightLimit = windowAttachOptions.isIntersectedHeightLimit;
|
||||
acceptAnchorInfo.attachOptions.isIntersectedWidthLimit = windowAttachOptions.isIntersectedWidthLimit;
|
||||
acceptAnchorInfo.isFromAttachOrDetach_ = true;
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "windowAnchorInfo %{public}d, offsetX:%{public}d, offsetY:%{public}d"
|
||||
"currentLayoutMode:%{public}s", acceptAnchorInfo.windowAnchor_, acceptAnchorInfo.offsetX_,
|
||||
acceptAnchorInfo.offsetY_, acceptAnchorInfo.attachOptions.currentLayoutMode.c_str());
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "windowAnchorInfo %{public}d, offsetX:%{public}d, offsetY:%{public}d, "
|
||||
"currentLayoutMode:%{public}s, isIntersectedHeightLimit:%{public}d, isIntersectedWidthLimit:%{public}d",
|
||||
acceptAnchorInfo.windowAnchor_, acceptAnchorInfo.offsetX_, acceptAnchorInfo.offsetY_,
|
||||
acceptAnchorInfo.attachOptions.currentLayoutMode.c_str(),
|
||||
acceptAnchorInfo.attachOptions.isIntersectedHeightLimit,
|
||||
acceptAnchorInfo.attachOptions.isIntersectedWidthLimit);
|
||||
napi_ref sizeChangeCallbackRef = nullptr;
|
||||
if (sizeChangeCallback != nullptr) {
|
||||
napi_valuetype valueType;
|
||||
|
||||
@@ -1072,11 +1072,12 @@ napi_value CreateJsWindowInfoObject(napi_env env, const sptr<WindowVisibilityInf
|
||||
GetRectAndConvertToJsValue(env, info->GetGlobalDisplayRect()));
|
||||
napi_set_named_property(env, objValue, "globalRect",
|
||||
GetRectAndConvertToJsValue(env, info->GetGlobalRect()));
|
||||
napi_set_named_property(env, objValue, "displayId",
|
||||
CreateJsNumber(env, static_cast<uint64_t>(info->GetDisplayId())));
|
||||
napi_set_named_property(env, objValue, "bundleName", CreateJsValue(env, info->GetBundleName()));
|
||||
napi_set_named_property(env, objValue, "abilityName", CreateJsValue(env, info->GetAbilityName()));
|
||||
napi_set_named_property(env, objValue, "windowId", CreateJsValue(env, info->GetWindowId()));
|
||||
napi_set_named_property(env, objValue, "displayId",
|
||||
CreateJsNumber(env, static_cast<uint64_t>(info->GetDisplayId())));
|
||||
napi_set_named_property(env, objValue, "bundleName", CreateJsValue(env, info->GetBundleName()));
|
||||
napi_set_named_property(env, objValue, "moduleName", CreateJsValue(env, info->GetModuleName()));
|
||||
napi_set_named_property(env, objValue, "abilityName", CreateJsValue(env, info->GetAbilityName()));
|
||||
napi_set_named_property(env, objValue, "windowId", CreateJsValue(env, info->GetWindowId()));
|
||||
napi_set_named_property(env, objValue, "windowStatusType",
|
||||
CreateJsValue(env, static_cast<int32_t>(info->GetWindowStatus())));
|
||||
napi_set_named_property(env, objValue, "isFocused", CreateJsValue(env, info->IsFocused()));
|
||||
@@ -2338,4 +2339,4 @@ std::unique_ptr<WsNapiAsyncTask> CreateEmptyWsNapiAsyncTask(napi_env env,
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1083,11 +1083,21 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
int32_t offsetY_ = 0;
|
||||
struct AttachOptions : public Parcelable {
|
||||
std::string currentLayoutMode = "";
|
||||
bool isIntersectedHeightLimit = false;
|
||||
bool isIntersectedWidthLimit = false;
|
||||
|
||||
AttachOptions() = default;
|
||||
AttachOptions(const std::string&& currentLayoutMode) : currentLayoutMode(currentLayoutMode) {}
|
||||
AttachOptions(std::string currentLayoutMode, bool isIntersectedHeightLimit,
|
||||
bool isIntersectedWidthLimit) : currentLayoutMode(currentLayoutMode),
|
||||
isIntersectedHeightLimit(isIntersectedHeightLimit),
|
||||
isIntersectedWidthLimit(isIntersectedWidthLimit) {}
|
||||
|
||||
bool operator==(const AttachOptions& other) const
|
||||
{
|
||||
return currentLayoutMode == other.currentLayoutMode;
|
||||
return currentLayoutMode == other.currentLayoutMode &&
|
||||
isIntersectedHeightLimit == other.isIntersectedHeightLimit &&
|
||||
isIntersectedWidthLimit == other.isIntersectedWidthLimit;
|
||||
}
|
||||
|
||||
bool operator!=(const AttachOptions& other) const
|
||||
@@ -1097,7 +1107,12 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
return parcel.WriteString(currentLayoutMode);
|
||||
if (!parcel.WriteString(currentLayoutMode) ||
|
||||
!parcel.WriteBool(isIntersectedHeightLimit) ||
|
||||
!parcel.WriteBool(isIntersectedWidthLimit)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static AttachOptions* Unmarshalling(Parcel& parcel)
|
||||
@@ -1111,6 +1126,11 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
return nullptr;
|
||||
}
|
||||
attachOptions->currentLayoutMode = layoutMode;
|
||||
|
||||
if (!parcel.ReadBool(attachOptions->isIntersectedHeightLimit) ||
|
||||
!parcel.ReadBool(attachOptions->isIntersectedWidthLimit)) {
|
||||
return nullptr;
|
||||
}
|
||||
return attachOptions.release();
|
||||
}
|
||||
};
|
||||
@@ -1162,6 +1182,8 @@ struct WindowAnchorInfo : public Parcelable {
|
||||
}
|
||||
windowAnchorInfo->windowAnchor_ = static_cast<WindowAnchor>(windowAnchorMode);
|
||||
windowAnchorInfo->attachOptions.currentLayoutMode = attachOptions->currentLayoutMode;
|
||||
windowAnchorInfo->attachOptions.isIntersectedHeightLimit = attachOptions->isIntersectedHeightLimit;
|
||||
windowAnchorInfo->attachOptions.isIntersectedWidthLimit = attachOptions->isIntersectedWidthLimit;
|
||||
return windowAnchorInfo;
|
||||
}
|
||||
};
|
||||
@@ -1377,6 +1399,66 @@ struct WindowLimits {
|
||||
<< " " << vpRatio_ << " " << static_cast<uint32_t>(pixelUnit_) << "]";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
bool Marshalling(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteUint32(maxWidth_) && parcel.WriteUint32(maxHeight_) &&
|
||||
parcel.WriteUint32(minWidth_) && parcel.WriteUint32(minHeight_) &&
|
||||
parcel.WriteFloat(maxRatio_) && parcel.WriteFloat(minRatio_) &&
|
||||
parcel.WriteFloat(vpRatio_) && parcel.WriteUint32(static_cast<uint32_t>(pixelUnit_));
|
||||
}
|
||||
|
||||
static WindowLimits* Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
auto windowLimits = std::make_unique<WindowLimits>();
|
||||
if (!windowLimits) {
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t pixelUnit = 0;
|
||||
if (!parcel.ReadUint32(windowLimits->maxWidth_) ||
|
||||
!parcel.ReadUint32(windowLimits->maxHeight_) ||
|
||||
!parcel.ReadUint32(windowLimits->minWidth_) ||
|
||||
!parcel.ReadUint32(windowLimits->minHeight_) ||
|
||||
!parcel.ReadFloat(windowLimits->maxRatio_) ||
|
||||
!parcel.ReadFloat(windowLimits->minRatio_) ||
|
||||
!parcel.ReadFloat(windowLimits->vpRatio_) ||
|
||||
!parcel.ReadUint32(pixelUnit)) {
|
||||
return nullptr;
|
||||
}
|
||||
// Validate pixelUnit: valid values are PX=0 and VP=1
|
||||
if (pixelUnit > static_cast<uint32_t>(PixelUnit::VP)) {
|
||||
return nullptr;
|
||||
}
|
||||
windowLimits->pixelUnit_ = static_cast<PixelUnit>(pixelUnit);
|
||||
return windowLimits.release();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct AttachLimitOptions
|
||||
*
|
||||
* @brief Options for intersecting limits with attached windows.
|
||||
* Used to specify whether to intersect height/width limits.
|
||||
*/
|
||||
struct AttachLimitOptions {
|
||||
bool isIntersectedHeightLimit = false;
|
||||
bool isIntersectedWidthLimit = false;
|
||||
|
||||
AttachLimitOptions() = default;
|
||||
AttachLimitOptions(bool isIntersectedHeightLimit, bool isIntersectedWidthLimit)
|
||||
: isIntersectedHeightLimit(isIntersectedHeightLimit),
|
||||
isIntersectedWidthLimit(isIntersectedWidthLimit) {}
|
||||
|
||||
bool operator==(const AttachLimitOptions& other) const
|
||||
{
|
||||
return isIntersectedHeightLimit == other.isIntersectedHeightLimit &&
|
||||
isIntersectedWidthLimit == other.isIntersectedWidthLimit;
|
||||
}
|
||||
|
||||
bool operator!=(const AttachLimitOptions& other) const
|
||||
{
|
||||
return !this->operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,7 @@ ohos_shared_library("libsetresolution_util") {
|
||||
"hitrace:hitrace_meter",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ ohos_shared_library("libsnapshot_util") {
|
||||
"libjpeg-turbo:turbojpeg",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ ohos_fuzztest("Window01FuzzTest") {
|
||||
"${window_base_path}/utils:libwmutil",
|
||||
"${window_base_path}/utils:libwmutil_base",
|
||||
"${window_base_path}/wm:libwm",
|
||||
"${window_base_path}/extension/extension_connection:libwindow_extension_client",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@@ -68,7 +69,6 @@ ohos_fuzztest("Window01FuzzTest") {
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"window_manager:libwindow_extension_client",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ ohos_fuzztest("WindowFuzzTest") {
|
||||
"${window_base_path}/utils:libwmutil",
|
||||
"${window_base_path}/utils:libwmutil_base",
|
||||
"${window_base_path}/wm:libwm",
|
||||
"${window_base_path}/extension/extension_connection:libwindow_extension_client",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@@ -68,7 +69,6 @@ ohos_fuzztest("WindowFuzzTest") {
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"window_manager:libwindow_extension_client",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("../../../windowmanager_aafwk.gni")
|
||||
|
||||
module_out_path = "window_manager/window_manager/extension"
|
||||
|
||||
@@ -52,10 +53,10 @@ ohos_systemtest("modal_system_ui_extension_test") {
|
||||
"../../../resources/config/build:testcase_flags",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"../../../dm:libdm",
|
||||
"../../../extension/modal_system_ui_extension:libmodal_system_ui_extension_client",
|
||||
"../../../window_scene/interfaces/innerkits:libwsutils",
|
||||
deps = [
|
||||
"${window_base_path}/dm:libdm",
|
||||
"${window_base_path}/extension/modal_system_ui_extension:libmodal_system_ui_extension_client",
|
||||
"${window_base_path}/window_scene/interfaces/innerkits:libwsutils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@@ -84,9 +85,9 @@ ohos_systemtest("window_extension_connection_test") {
|
||||
"../../../resources/config/build:testcase_flags",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"../../../extension/extension_connection:libwindow_extension_client",
|
||||
"../../../window_scene/session:scene_session",
|
||||
deps = [
|
||||
"${window_base_path}/extension/extension_connection:libwindow_extension_client",
|
||||
"${window_base_path}/window_scene/session:scene_session",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -202,6 +202,7 @@ ohos_shared_library("libwmutil_base") {
|
||||
"init:libbegetutil",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
@@ -275,12 +276,13 @@ ohos_shared_library("libwmutil") {
|
||||
if (!(host_os == "linux" && host_cpu == "arm64")) {
|
||||
external_deps += [ "preferences:native_preferences" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
if (is_ohos && is_clang && target_cpu == "arm64") {
|
||||
ldflags = [
|
||||
ldflags += [
|
||||
"-Wl,--emit-relocs",
|
||||
"-Wl,--no-relax",
|
||||
"-mno-fix-cortex-a53-843419"
|
||||
|
||||
@@ -89,11 +89,15 @@ public:
|
||||
|
||||
const Rect& GetRect() const { return rect_; }
|
||||
|
||||
const std::string& GetBundleName() const { return bundleName_; }
|
||||
|
||||
void SetBundleName(const std::string& bundleName) { bundleName_ = bundleName; }
|
||||
|
||||
const std::string& GetAbilityName() const { return abilityName_; }
|
||||
const std::string& GetBundleName() const { return bundleName_; }
|
||||
|
||||
void SetBundleName(const std::string& bundleName) { bundleName_ = bundleName; }
|
||||
|
||||
const std::string& GetModuleName() const { return moduleName_; }
|
||||
|
||||
void SetModuleName(const std::string& moduleName) { moduleName_ = moduleName; }
|
||||
|
||||
const std::string& GetAbilityName() const { return abilityName_; }
|
||||
|
||||
void SetAbilityName(const std::string& abilityName) { abilityName_ = abilityName; }
|
||||
|
||||
@@ -152,10 +156,11 @@ public:
|
||||
WindowType windowType_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
|
||||
WindowStatus windowStatus_ = WindowStatus::WINDOW_STATUS_UNDEFINED;
|
||||
Rect rect_ = {0, 0, 0, 0};
|
||||
Rect globalDisplayRect_ { 0, 0, 0, 0 };
|
||||
Rect globalRect_ { 0, 0, 0, 0 };
|
||||
std::string bundleName_;
|
||||
std::string abilityName_;
|
||||
Rect globalDisplayRect_ { 0, 0, 0, 0 };
|
||||
Rect globalRect_ { 0, 0, 0, 0 };
|
||||
std::string bundleName_;
|
||||
std::string moduleName_;
|
||||
std::string abilityName_;
|
||||
bool isFocused_ = false;
|
||||
int32_t appIndex_ { 0 };
|
||||
bool isSystem_ = false;
|
||||
@@ -167,4 +172,4 @@ public:
|
||||
ControlAppType controlAppType_ = ControlAppType::CONTROL_APP_TYPE_BEGIN;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H
|
||||
#endif // OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H
|
||||
|
||||
@@ -26,12 +26,13 @@ bool WindowVisibilityInfo::Marshalling(Parcel& parcel) const
|
||||
return parcel.WriteUint32(windowId_) && parcel.WriteInt32(pid_) &&
|
||||
parcel.WriteInt32(uid_) && parcel.WriteUint32(static_cast<uint32_t>(visibilityState_)) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(windowType_)) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(windowStatus_)) && parcel.WriteInt32(rect_.posX_) &&
|
||||
parcel.WriteInt32(rect_.posY_) && parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
|
||||
parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_) && parcel.WriteBool(isFocused_) &&
|
||||
parcel.WriteInt32(appIndex_) && parcel.WriteBool(isSystem_) && parcel.WriteUint32(zOrder_) &&
|
||||
parcel.WriteInt32(callingPid_) && parcel.WriteInt32(globalDisplayRect_.posX_) &&
|
||||
parcel.WriteInt32(globalDisplayRect_.posY_) && parcel.WriteUint32(globalDisplayRect_.width_) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(windowStatus_)) && parcel.WriteInt32(rect_.posX_) &&
|
||||
parcel.WriteInt32(rect_.posY_) && parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
|
||||
parcel.WriteString(bundleName_) && parcel.WriteString(moduleName_) &&
|
||||
parcel.WriteString(abilityName_) && parcel.WriteBool(isFocused_) &&
|
||||
parcel.WriteInt32(appIndex_) && parcel.WriteBool(isSystem_) && parcel.WriteUint32(zOrder_) &&
|
||||
parcel.WriteInt32(callingPid_) && parcel.WriteInt32(globalDisplayRect_.posX_) &&
|
||||
parcel.WriteInt32(globalDisplayRect_.posY_) && parcel.WriteUint32(globalDisplayRect_.width_) &&
|
||||
parcel.WriteUint32(globalDisplayRect_.height_) && parcel.WriteInt32(collaboratorType_) &&
|
||||
parcel.WriteUint64(displayId_) && parcel.WriteInt32(globalRect_.posX_) &&
|
||||
parcel.WriteInt32(globalRect_.posY_) && parcel.WriteUint32(globalRect_.width_) &&
|
||||
@@ -55,12 +56,13 @@ WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel)
|
||||
return nullptr;
|
||||
}
|
||||
windowVisibilityInfo->visibilityState_ = static_cast<WindowVisibilityState>(visibilityState);
|
||||
windowVisibilityInfo->windowType_ = static_cast<WindowType>(parcel.ReadUint32());
|
||||
windowVisibilityInfo->windowStatus_ = static_cast<WindowStatus>(parcel.ReadUint32());
|
||||
windowVisibilityInfo->rect_ = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
|
||||
windowVisibilityInfo->bundleName_ = parcel.ReadString();
|
||||
windowVisibilityInfo->abilityName_ = parcel.ReadString();
|
||||
windowVisibilityInfo->isFocused_ = parcel.ReadBool();
|
||||
windowVisibilityInfo->windowType_ = static_cast<WindowType>(parcel.ReadUint32());
|
||||
windowVisibilityInfo->windowStatus_ = static_cast<WindowStatus>(parcel.ReadUint32());
|
||||
windowVisibilityInfo->rect_ = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
|
||||
windowVisibilityInfo->bundleName_ = parcel.ReadString();
|
||||
windowVisibilityInfo->moduleName_ = parcel.ReadString();
|
||||
windowVisibilityInfo->abilityName_ = parcel.ReadString();
|
||||
windowVisibilityInfo->isFocused_ = parcel.ReadBool();
|
||||
windowVisibilityInfo->appIndex_ = parcel.ReadInt32();
|
||||
windowVisibilityInfo->isSystem_ = parcel.ReadBool();
|
||||
windowVisibilityInfo->zOrder_ = parcel.ReadUint32();
|
||||
|
||||
@@ -88,4 +88,5 @@ ohos_shared_library("window_scene_common") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
void SetWindowLimitsVP(const WindowLimits& windowLimits);
|
||||
void SetUserWindowLimits(const WindowLimits& windowLimits);
|
||||
void SetConfigWindowLimitsVP(const WindowLimits& windowLimitsVP);
|
||||
void SetLimitsForAttachedWindows(const WindowLimits& windowLimits);
|
||||
void SetLastLimitsVpr(float vpr);
|
||||
void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
|
||||
void SetKeyboardLayoutParams(const KeyboardLayoutParams& params);
|
||||
@@ -166,6 +167,7 @@ public:
|
||||
WindowLimits GetWindowLimitsVP() const;
|
||||
WindowLimits GetUserWindowLimits() const;
|
||||
WindowLimits GetConfigWindowLimitsVP() const;
|
||||
WindowLimits GetLimitsForAttachedWindows() const;
|
||||
float GetLastLimitsVpr() const;
|
||||
uint32_t GetWindowModeSupportType() const;
|
||||
std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const;
|
||||
@@ -213,6 +215,8 @@ public:
|
||||
static void UnmarshallingShadowsInfo(Parcel& parcel, WindowSessionProperty* property);
|
||||
bool MarshallingWindowAnchorInfo(Parcel& parcel) const;
|
||||
static void UnmarshallingWindowAnchorInfo(Parcel& parcel, WindowSessionProperty* property);
|
||||
bool MarshallingHookWindowInfo(Parcel& parcel) const;
|
||||
static void UnmarshallingHookWindowInfo(Parcel& parcel, WindowSessionProperty* property);
|
||||
|
||||
void SetTextFieldPositionY(double textFieldPositionY);
|
||||
void SetTextFieldHeight(double textFieldHeight);
|
||||
@@ -256,6 +260,22 @@ public:
|
||||
bool IsSubWindowZLevelAboveParentLoosened() const;
|
||||
void SetWindowAnchorInfo(const WindowAnchorInfo& windowAnchorInfo);
|
||||
WindowAnchorInfo GetWindowAnchorInfo() const;
|
||||
// Set attached window limits from a specific source window (by persistentId)
|
||||
void SetAttachedWindowLimits(int32_t sourcePersistentId, const WindowLimits& attachedWindowLimits);
|
||||
// Remove attached window limits from a specific source window
|
||||
void RemoveAttachedWindowLimits(int32_t sourcePersistentId);
|
||||
// Get all attached window limits (preserving insertion order)
|
||||
std::vector<std::pair<int32_t, WindowLimits>> GetAttachedWindowLimitsList() const;
|
||||
void ClearAttachedWindowLimitsList();
|
||||
// Set limit options for a specific attached window
|
||||
void SetAttachedLimitOptions(int32_t sourcePersistentId, const AttachLimitOptions& options);
|
||||
// Get limit options for a specific attached window
|
||||
AttachLimitOptions GetAttachedLimitOptions(int32_t sourcePersistentId) const;
|
||||
// Remove limit options for a specific attached window
|
||||
void RemoveAttachedLimitOptions(int32_t sourcePersistentId);
|
||||
// Get all attached limit options (preserving insertion order)
|
||||
std::vector<std::pair<int32_t, AttachLimitOptions>> GetAttachedLimitOptionsList() const;
|
||||
void ClearAttachedLimitOptionsList();
|
||||
|
||||
/*
|
||||
* Window Hierarchy
|
||||
@@ -282,6 +302,10 @@ public:
|
||||
bool GetPcAppInpadOrientationLandscape() const;
|
||||
void SetMobileAppInPadLayoutFullScreen(bool isMobileAppInPadLayoutFullScreen);
|
||||
bool GetMobileAppInPadLayoutFullScreen() const;
|
||||
void SetForceSplitEnable(bool isForceSplitEnabled);
|
||||
bool GetForceSplitEnable() const;
|
||||
void SetHookWindowInfo(const HookWindowInfo& hookWindowInfo);
|
||||
HookWindowInfo GetHookWindowInfo() const;
|
||||
void SetRotationLocked(bool locked);
|
||||
bool GetRotationLocked() const;
|
||||
|
||||
@@ -528,6 +552,7 @@ private:
|
||||
WindowLimits limitsVP_ = WindowLimits::DEFAULT_VP_LIMITS();
|
||||
WindowLimits userLimits_ = WindowLimits::DEFAULT_VP_LIMITS();
|
||||
WindowLimits configLimitsVP_ = WindowLimits::DEFAULT_VP_LIMITS();
|
||||
WindowLimits limitsForAttachedWindows_ = WindowLimits::DEFAULT_VP_LIMITS();
|
||||
float lastVpr_ = 0.0f;
|
||||
PiPTemplateInfo pipTemplateInfo_ = {};
|
||||
FloatingBallTemplateInfo fbTemplateInfo_ = {};
|
||||
@@ -593,6 +618,14 @@ private:
|
||||
bool subWindowOutlineEnabled_ = false;
|
||||
bool zLevelAboveParentLoosened_ = false;
|
||||
WindowAnchorInfo windowAnchorInfo_;
|
||||
// Store window limits from attached windows (preserving insertion order for priority)
|
||||
// Parent window stores limits from its sub windows, sub window stores limits from its parent
|
||||
// Earlier attached windows have higher priority in intersection calculation
|
||||
std::vector<std::pair<int32_t, WindowLimits>> attachedWindowLimitsList_;
|
||||
// Store limit options for each attached window (preserving insertion order to match limits list)
|
||||
// Parent window stores options from its sub windows (which limits to intersect)
|
||||
// Each pair contains: <sourceWindowId, AttachLimitOptions>
|
||||
std::vector<std::pair<int32_t, AttachLimitOptions>> attachedLimitOptionsList_;
|
||||
|
||||
/*
|
||||
* Window Hierarchy
|
||||
@@ -668,10 +701,14 @@ private:
|
||||
mutable std::mutex shadowsInfoMutex_;
|
||||
mutable std::mutex globalDisplayRectMutex_;
|
||||
Rect globalDisplayRect_ { 0, 0, 0, 0 };
|
||||
mutable std::mutex hookWindowInfoMutex_;
|
||||
HookWindowInfo hookWindowInfo_;
|
||||
bool isPcAppInpadCompatibleMode_ = false;
|
||||
bool isPcAppInpadSpecificSystemBarInvisible_ = false;
|
||||
bool isPcAppInpadOrientationLandscape_ = false;
|
||||
bool isMobileAppInPadLayoutFullScreen_ = false;
|
||||
mutable std::mutex isForceSplitEnabledMutex_;
|
||||
bool isForceSplitEnabled_ = false;
|
||||
bool isRotationLock_ = false;
|
||||
|
||||
/*
|
||||
@@ -844,9 +881,6 @@ struct FreeMultiWindowConfig : public Parcelable {
|
||||
};
|
||||
|
||||
struct AppForceLandscapeConfig : public Parcelable {
|
||||
int32_t mode_ = 0;
|
||||
int32_t supportSplit_ = -1;
|
||||
bool ignoreOrientation_ = false;
|
||||
std::string sysConfigJsonStr_ = "";
|
||||
std::string appConfigJsonStr_ = "";
|
||||
std::string sysHomePage_ = "";
|
||||
@@ -857,20 +891,15 @@ struct AppForceLandscapeConfig : public Parcelable {
|
||||
bool hasChanged_ = true;
|
||||
bool configEnable_ = false;
|
||||
AppForceLandscapeConfig() {}
|
||||
AppForceLandscapeConfig(int32_t mode, int32_t supportSplit, bool ignoreOrientation,
|
||||
const std::string& sysConfigJsonStr, const std::string& appConfigJsonStr,
|
||||
AppForceLandscapeConfig(const std::string& sysConfigJsonStr, const std::string& appConfigJsonStr,
|
||||
const std::string& sysHomePage, bool isSysRouter, bool isAppRouter,
|
||||
bool containsSysConfig, bool containsAppConfig) : mode_(mode), supportSplit_(supportSplit),
|
||||
ignoreOrientation_(ignoreOrientation), sysConfigJsonStr_(sysConfigJsonStr),
|
||||
bool containsSysConfig, bool containsAppConfig) : sysConfigJsonStr_(sysConfigJsonStr),
|
||||
appConfigJsonStr_(appConfigJsonStr), sysHomePage_(sysHomePage), isSysRouter_(isSysRouter),
|
||||
isAppRouter_(isAppRouter), containsSysConfig_(containsSysConfig), containsAppConfig_(containsAppConfig) {}
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
if (!parcel.WriteInt32(mode_) ||
|
||||
!parcel.WriteInt32(supportSplit_) ||
|
||||
!parcel.WriteBool(ignoreOrientation_) ||
|
||||
!parcel.WriteString(sysConfigJsonStr_) ||
|
||||
if (!parcel.WriteString(sysConfigJsonStr_) ||
|
||||
!parcel.WriteString(appConfigJsonStr_) ||
|
||||
!parcel.WriteString(sysHomePage_) ||
|
||||
!parcel.WriteBool(isSysRouter_) ||
|
||||
@@ -888,10 +917,7 @@ struct AppForceLandscapeConfig : public Parcelable {
|
||||
if (config == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!parcel.ReadInt32(config->mode_) ||
|
||||
!parcel.ReadInt32(config->supportSplit_) ||
|
||||
!parcel.ReadBool(config->ignoreOrientation_) ||
|
||||
!parcel.ReadString(config->sysConfigJsonStr_) ||
|
||||
if (!parcel.ReadString(config->sysConfigJsonStr_) ||
|
||||
!parcel.ReadString(config->appConfigJsonStr_) ||
|
||||
!parcel.ReadString(config->sysHomePage_) ||
|
||||
!parcel.ReadBool(config->isSysRouter_) ||
|
||||
@@ -905,10 +931,7 @@ struct AppForceLandscapeConfig : public Parcelable {
|
||||
|
||||
static bool IsSameForceSplitConfig(const AppForceLandscapeConfig& preconfig, const AppForceLandscapeConfig& config)
|
||||
{
|
||||
if (preconfig.mode_ != config.mode_ ||
|
||||
preconfig.supportSplit_ != config.supportSplit_ ||
|
||||
preconfig.ignoreOrientation_ != config.ignoreOrientation_ ||
|
||||
preconfig.containsSysConfig_ != config.containsSysConfig_ ||
|
||||
if (preconfig.containsSysConfig_ != config.containsSysConfig_ ||
|
||||
preconfig.containsAppConfig_ != config.containsAppConfig_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1007,7 +1007,8 @@ bool WindowSessionProperty::MarshallingWindowLimits(Parcel& parcel) const
|
||||
|
||||
return writeWindowLimits(limits_) &&
|
||||
writeWindowLimits(limitsVP_) &&
|
||||
writeWindowLimits(userLimits_);
|
||||
writeWindowLimits(userLimits_) &&
|
||||
writeWindowLimits(limitsForAttachedWindows_);
|
||||
}
|
||||
|
||||
void WindowSessionProperty::UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property)
|
||||
@@ -1028,6 +1029,7 @@ void WindowSessionProperty::UnmarshallingWindowLimits(Parcel& parcel, WindowSess
|
||||
property->SetWindowLimits(readWindowLimits());
|
||||
property->SetWindowLimitsVP(readWindowLimits());
|
||||
property->SetUserWindowLimits(readWindowLimits());
|
||||
property->SetLimitsForAttachedWindows(readWindowLimits());
|
||||
}
|
||||
|
||||
bool WindowSessionProperty::MarshallingSystemBarMap(Parcel& parcel) const
|
||||
@@ -1419,6 +1421,90 @@ WindowAnchorInfo WindowSessionProperty::GetWindowAnchorInfo() const
|
||||
return windowAnchorInfo_;
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionProperty::SetAttachedWindowLimits(int32_t sourcePersistentId,
|
||||
const WindowLimits& attachedWindowLimits)
|
||||
{
|
||||
// Check if this sourceId already exists, if so, update it; otherwise, append
|
||||
for (auto& [id, limits] : attachedWindowLimitsList_) {
|
||||
if (id == sourcePersistentId) {
|
||||
limits = attachedWindowLimits;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Not found, append to the end (later attached, lower priority)
|
||||
attachedWindowLimitsList_.push_back({sourcePersistentId, attachedWindowLimits});
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionProperty::RemoveAttachedWindowLimits(int32_t sourcePersistentId)
|
||||
{
|
||||
auto it = std::remove_if(attachedWindowLimitsList_.begin(), attachedWindowLimitsList_.end(),
|
||||
[sourcePersistentId](const auto& item) {
|
||||
return item.first == sourcePersistentId;
|
||||
});
|
||||
attachedWindowLimitsList_.erase(it, attachedWindowLimitsList_.end());
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
std::vector<std::pair<int32_t, WindowLimits>> WindowSessionProperty::GetAttachedWindowLimitsList() const
|
||||
{
|
||||
return attachedWindowLimitsList_;
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionProperty::ClearAttachedWindowLimitsList()
|
||||
{
|
||||
attachedWindowLimitsList_.clear();
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionProperty::SetAttachedLimitOptions(int32_t sourcePersistentId, const AttachLimitOptions& options)
|
||||
{
|
||||
// Find existing entry and update in-place to preserve order
|
||||
for (auto& entry : attachedLimitOptionsList_) {
|
||||
if (entry.first == sourcePersistentId) {
|
||||
entry.second = options; // In-place update, preserves position in vector
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Not found, add new entry at the end
|
||||
attachedLimitOptionsList_.emplace_back(sourcePersistentId, options);
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
AttachLimitOptions WindowSessionProperty::GetAttachedLimitOptions(int32_t sourcePersistentId) const
|
||||
{
|
||||
for (const auto& [id, options] : attachedLimitOptionsList_) {
|
||||
if (id == sourcePersistentId) {
|
||||
return options;
|
||||
}
|
||||
}
|
||||
return AttachLimitOptions{}; // Return default options if not found
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionProperty::RemoveAttachedLimitOptions(int32_t sourcePersistentId)
|
||||
{
|
||||
auto it = std::remove_if(attachedLimitOptionsList_.begin(), attachedLimitOptionsList_.end(),
|
||||
[sourcePersistentId](const auto& entry) {
|
||||
return entry.first == sourcePersistentId;
|
||||
});
|
||||
attachedLimitOptionsList_.erase(it, attachedLimitOptionsList_.end());
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
std::vector<std::pair<int32_t, AttachLimitOptions>> WindowSessionProperty::GetAttachedLimitOptionsList() const
|
||||
{
|
||||
return attachedLimitOptionsList_;
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionProperty::ClearAttachedLimitOptionsList()
|
||||
{
|
||||
attachedLimitOptionsList_.clear();
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetZIndex(int32_t zIndex)
|
||||
{
|
||||
zIndex_ = zIndex;
|
||||
@@ -1532,6 +1618,8 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const
|
||||
parcel.WriteString(ancoRealBundleName_) &&
|
||||
parcel.WriteBool(isShowDecorInFreeMultiWindow_) &&
|
||||
parcel.WriteBool(isMobileAppInPadLayoutFullScreen_) &&
|
||||
parcel.WriteBool(isForceSplitEnabled_) &&
|
||||
MarshallingHookWindowInfo(parcel) &&
|
||||
parcel.WriteBool(isFullScreenInForceSplitMode_) &&
|
||||
parcel.WriteInt32(static_cast<int32_t>(pageCompatibleMode_)) &&
|
||||
parcel.WriteFloat(aspectRatio_) &&
|
||||
@@ -1659,6 +1747,8 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetAncoRealBundleName(parcel.ReadString());
|
||||
property->SetIsShowDecorInFreeMultiWindow(parcel.ReadBool());
|
||||
property->SetMobileAppInPadLayoutFullScreen(parcel.ReadBool());
|
||||
property->SetForceSplitEnable(parcel.ReadBool());
|
||||
UnmarshallingHookWindowInfo(parcel, property);
|
||||
property->SetIsFullScreenInForceSplitMode(parcel.ReadBool());
|
||||
property->SetPageCompatibleMode(static_cast<CompatibleStyleMode>(parcel.ReadInt32()));
|
||||
property->SetAspectRatio(parcel.ReadFloat());
|
||||
@@ -2315,6 +2405,18 @@ WindowLimits WindowSessionProperty::GetConfigWindowLimitsVP() const
|
||||
return configLimitsVP_;
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
void WindowSessionProperty::SetLimitsForAttachedWindows(const WindowLimits& windowLimits)
|
||||
{
|
||||
limitsForAttachedWindows_ = windowLimits;
|
||||
}
|
||||
|
||||
/** @note @window.layout */
|
||||
WindowLimits WindowSessionProperty::GetLimitsForAttachedWindows() const
|
||||
{
|
||||
return limitsForAttachedWindows_;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetLastLimitsVpr(float vpr)
|
||||
{
|
||||
lastVpr_ = vpr;
|
||||
@@ -2602,6 +2704,30 @@ void WindowSessionProperty::SetMobileAppInPadLayoutFullScreen(bool isMobileAppIn
|
||||
isMobileAppInPadLayoutFullScreen_ = isMobileAppInPadLayoutFullScreen;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetForceSplitEnable(bool isForceSplitEnabled)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(isForceSplitEnabledMutex_);
|
||||
isForceSplitEnabled_ = isForceSplitEnabled;
|
||||
}
|
||||
|
||||
bool WindowSessionProperty::GetForceSplitEnable() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(isForceSplitEnabledMutex_);
|
||||
return isForceSplitEnabled_;
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetHookWindowInfo(const HookWindowInfo& hookWindowInfo)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(hookWindowInfoMutex_);
|
||||
hookWindowInfo_ = hookWindowInfo;
|
||||
}
|
||||
|
||||
HookWindowInfo WindowSessionProperty::GetHookWindowInfo() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(hookWindowInfoMutex_);
|
||||
return hookWindowInfo_;
|
||||
}
|
||||
|
||||
bool WindowSessionProperty::GetPcAppInpadCompatibleMode() const
|
||||
{
|
||||
return isPcAppInpadCompatibleMode_;
|
||||
@@ -2868,6 +2994,21 @@ void WindowSessionProperty::UnmarshallingWindowAnchorInfo(Parcel& parcel, Window
|
||||
property->SetWindowAnchorInfo(*windowAnchorInfo);
|
||||
}
|
||||
|
||||
bool WindowSessionProperty::MarshallingHookWindowInfo(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteParcelable(&hookWindowInfo_);
|
||||
}
|
||||
|
||||
void WindowSessionProperty::UnmarshallingHookWindowInfo(Parcel& parcel, WindowSessionProperty* property)
|
||||
{
|
||||
sptr<HookWindowInfo> hookWindowInfo = parcel.ReadParcelable<HookWindowInfo>();
|
||||
if (hookWindowInfo == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "hookWindowInfo is nullptr!");
|
||||
return;
|
||||
}
|
||||
property->SetHookWindowInfo(*hookWindowInfo);
|
||||
}
|
||||
|
||||
void WindowSessionProperty::SetMissionInfo(const MissionInfo& missionInfo)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(missionInfoMutex_);
|
||||
|
||||
@@ -86,4 +86,5 @@ ohos_shared_library("libintention_event") {
|
||||
if (build_variant == "user") {
|
||||
defines += [ "IS_RELEASE_VERSION" ]
|
||||
}
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ ohos_shared_library("libwsutils") {
|
||||
sources = [ "src/scene_board_judgement.cpp" ]
|
||||
|
||||
public_configs = [ ":libwsutils_public_config" ]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -78,6 +78,7 @@ ohos_shared_library("scenesessionmanagerani_kit") {
|
||||
"runtime_core:ani",
|
||||
]
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -714,6 +714,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c
|
||||
JsSceneSession::UpdateSceneAnimationConfig);
|
||||
BindNativeFunction(env, objValue, "setMobileAppInPadLayoutFullScreen",
|
||||
moduleName, JsSceneSession::SetMobileAppInPadLayoutFullScreen);
|
||||
BindNativeFunction(env, objValue, "setForceSplitEnable", moduleName, JsSceneSession::SetForceSplitEnable);
|
||||
BindNativeFunction(env, objValue, "updateHookWindowInfo", moduleName, JsSceneSession::UpdateHookWindowInfo);
|
||||
BindNativeFunction(env, objValue, "notifyOrientationExecutionResult", moduleName,
|
||||
JsSceneSession::NotifyOrientationExecutionResult);
|
||||
BindNativeFunction(env, objValue, "getSceneNodeCount", moduleName,
|
||||
@@ -3239,6 +3241,20 @@ napi_value JsSceneSession::SetMobileAppInPadLayoutFullScreen(napi_env env, napi_
|
||||
return (me != nullptr) ? me->OnSetMobileAppInPadLayoutFullScreen(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::SetForceSplitEnable(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_COMPAT, "[NAPI]");
|
||||
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
|
||||
return (me != nullptr) ? me->OnSetForceSplitEnable(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::UpdateHookWindowInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_COMPAT, "[NAPI]");
|
||||
JsSceneSession* me = CheckParamsAndGetThis<JsSceneSession>(env, info);
|
||||
return (me != nullptr) ? me->OnUpdateHookWindowInfo(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::SetPcAppInpadSpecificSystemBarInvisible(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_PC, "[NAPI]");
|
||||
@@ -7595,6 +7611,77 @@ napi_value JsSceneSession::OnSetMobileAppInPadLayoutFullScreen(napi_env env, nap
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetForceSplitEnable(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_THREE;
|
||||
napi_value argv[ARG_INDEX_3] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_THREE) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
bool isForceSplitEnabled = false;
|
||||
if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForceSplitEnabled)) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Failed to convert parameter to isForceSplitEnabled");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
bool needUpdateViewport = false;
|
||||
if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], needUpdateViewport)) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Failed to convert parameter to needUpdateViewport");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
SelectMode selectMode = SelectMode::WIDE_MODE;
|
||||
if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], selectMode)) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Failed to convert parameter to selectMode");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "session is nullptr, id:%{public}d", persistentId_);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
session->SetForceSplitEnable(isForceSplitEnabled, needUpdateViewport, selectMode);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnUpdateHookWindowInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_TWO;
|
||||
napi_value argv[ARG_INDEX_2] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_ONE) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
HookWindowInfo hookWindowInfo{};
|
||||
if (!ConvertHookWindowInfoFromJs(env, argv[ARG_INDEX_0], hookWindowInfo)) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Failed to convert parameter to hookWindowInfo");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
auto session = weakSession_.promote();
|
||||
if (session == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "session is nullptr, id:%{public}d", persistentId_);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
session->UpdateHookWindowInfo(hookWindowInfo);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSession::OnSetPcAppInpadSpecificSystemBarInvisible(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_FOUR;
|
||||
|
||||
@@ -288,6 +288,8 @@ private:
|
||||
static napi_value SetPcAppInpadOrientationLandscape(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateSceneAnimationConfig(napi_env env, napi_callback_info info);
|
||||
static napi_value SetMobileAppInPadLayoutFullScreen(napi_env env, napi_callback_info info);
|
||||
static napi_value SetForceSplitEnable(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateHookWindowInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value NotifyOrientationExecutionResult(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSceneNodeCount(napi_env env, napi_callback_info info);
|
||||
static napi_value NotifyPreCalcWindowProperty(napi_env env, napi_callback_info info);
|
||||
@@ -400,6 +402,8 @@ private:
|
||||
napi_value OnUpdateSceneAnimationConfig(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetUid(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetMobileAppInPadLayoutFullScreen(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetForceSplitEnable(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateHookWindowInfo(napi_env env, napi_callback_info info);
|
||||
napi_value OnNotifyOrientationExecutionResult(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetSceneNodeCount(napi_env env, napi_callback_info info);
|
||||
napi_value OnNotifyPreCalcWindowProperty(napi_env env, napi_callback_info info);
|
||||
|
||||
@@ -294,16 +294,12 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj)
|
||||
JsSceneSessionManager::InitScheduleUtils);
|
||||
BindNativeFunction(env, exportObj, "setAppForceLandscapeConfig", moduleName,
|
||||
JsSceneSessionManager::SetAppForceLandscapeConfig);
|
||||
BindNativeFunction(env, exportObj, "setAppForceLandscapeConfigEnable", moduleName,
|
||||
JsSceneSessionManager::SetAppForceLandscapeConfigEnable);
|
||||
BindNativeFunction(env, exportObj, "setSelectMode", moduleName,
|
||||
JsSceneSessionManager::SetSelectMode);
|
||||
BindNativeFunction(env, exportObj, "isScbCoreEnabled", moduleName,
|
||||
JsSceneSessionManager::IsScbCoreEnabled);
|
||||
BindNativeFunction(env, exportObj, "updateAppHookDisplayInfo", moduleName,
|
||||
JsSceneSessionManager::UpdateAppHookDisplayInfo);
|
||||
BindNativeFunction(env, exportObj, "updateAppHookWindowInfo", moduleName,
|
||||
JsSceneSessionManager::UpdateAppHookWindowInfo);
|
||||
BindNativeFunction(env, exportObj, "notifyHookOrientationChange", moduleName,
|
||||
JsSceneSessionManager::NotifyHookOrientationChange);
|
||||
BindNativeFunction(env, exportObj, "refreshPcZOrder", moduleName,
|
||||
@@ -1499,14 +1495,6 @@ napi_value JsSceneSessionManager::UpdateAppHookDisplayInfo(napi_env env, napi_ca
|
||||
return (me != nullptr) ? me->OnUpdateAppHookDisplayInfo(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::UpdateAppHookWindowInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_COMPAT, "[NAPI]");
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnUpdateAppHookWindowInfo(env, info) : nullptr;
|
||||
}
|
||||
|
||||
|
||||
napi_value JsSceneSessionManager::NotifyHookOrientationChange(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::WMS_COMPAT, "[NAPI]");
|
||||
@@ -4796,38 +4784,6 @@ napi_value JsSceneSessionManager::OnUpdateAppHookDisplayInfo(napi_env env, napi_
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnUpdateAppHookWindowInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_TWO;
|
||||
napi_value argv[ARGC_TWO] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
|
||||
if (argc < ARGC_TWO) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[ARG_INDEX_ZERO], bundleName)) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Failed to convert parameter to bundleName");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
HookWindowInfo hookWindowInfo{};
|
||||
if (!ConvertHookWindowInfoFromJs(env, argv[ARG_INDEX_ONE], hookWindowInfo)) {
|
||||
TLOGE(WmsLogTag::WMS_COMPAT, "Failed to convert parameter to hookWindowInfo");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
SceneSessionManager::GetInstance().UpdateAppHookWindowInfo(bundleName, hookWindowInfo);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnNotifyHookOrientationChange(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_ONE;
|
||||
@@ -4879,16 +4835,6 @@ napi_value JsSceneSessionManager::OnSetAppForceLandscapeConfig(napi_env env, nap
|
||||
}
|
||||
|
||||
AppForceLandscapeConfig config;
|
||||
napi_value jsMode = nullptr;
|
||||
napi_get_named_property(env, argv[ARG_INDEX_ONE], "mode", &jsMode);
|
||||
RETURN_IF_CONVERT_FAIL(env, jsMode, config.mode_, "mode", WmsLogTag::DEFAULT);
|
||||
napi_value jsSupportSplit = nullptr;
|
||||
napi_get_named_property(env, argv[ARG_INDEX_ONE], "supportSplit", &jsSupportSplit);
|
||||
RETURN_IF_CONVERT_FAIL(env, jsSupportSplit, config.supportSplit_, "supportSplit", WmsLogTag::DEFAULT);
|
||||
napi_value jsIgnoreOrient = nullptr;
|
||||
napi_get_named_property(env, argv[ARG_INDEX_ONE], "ignoreOrientation", &jsIgnoreOrient);
|
||||
RETURN_IF_CONVERT_FAIL(env, jsIgnoreOrient, config.ignoreOrientation_, "ignoreOrientation",
|
||||
WmsLogTag::DEFAULT);
|
||||
napi_value jsContainsSysConfig = nullptr;
|
||||
napi_get_named_property(env, argv[ARG_INDEX_ONE], "containsSysConfig", &jsContainsSysConfig);
|
||||
RETURN_IF_CONVERT_FAIL(env, jsContainsSysConfig, config.containsSysConfig_, "containsSysConfig",
|
||||
@@ -4913,66 +4859,16 @@ napi_value JsSceneSessionManager::OnSetAppForceLandscapeConfig(napi_env env, nap
|
||||
napi_get_named_property(env, argv[ARG_INDEX_THREE], "configJsonStr", &jsAppConfigJsonStr);
|
||||
ConvertFromJsValue(env, jsAppConfigJsonStr, config.appConfigJsonStr_);
|
||||
|
||||
TLOGI(WmsLogTag::DEFAULT, "SetAppForceLandscapeConfig bundleName: %{public}s, mode: %{public}d, "
|
||||
"supportSplit: %{public}d, ignoreOrientation: %{public}d, containsSysConfig: %{public}d, "
|
||||
"containsAppConfig: %{public}d, isSysRouter: %{public}d, sysConfigJsonStr: %{public}s,"
|
||||
TLOGI(WmsLogTag::DEFAULT, "SetAppForceLandscapeConfig bundleName: %{public}s, containsSysConfig: %{public}d, "
|
||||
"containsAppConfig: %{public}d, isSysRouter: %{public}d, sysConfigJsonStr: %{public}s, "
|
||||
"sysHomePage: %{public}s, isAppRouter: %{public}d, appConfigJsonStr: %{public}s",
|
||||
bundleName.c_str(), config.mode_, config.supportSplit_, config.ignoreOrientation_,
|
||||
config.containsSysConfig_, config.containsAppConfig_, config.isSysRouter_,
|
||||
bundleName.c_str(), config.containsSysConfig_, config.containsAppConfig_, config.isSysRouter_,
|
||||
config.sysConfigJsonStr_.c_str(), config.sysHomePage_.c_str(), config.isAppRouter_,
|
||||
config.appConfigJsonStr_.c_str());
|
||||
SceneSessionManager::GetInstance().SetAppForceLandscapeConfig(bundleName, config);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::SetAppForceLandscapeConfigEnable(napi_env env, napi_callback_info info)
|
||||
{
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnSetAppForceLandscapeConfigEnable(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::OnSetAppForceLandscapeConfigEnable(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGC_FOUR;
|
||||
napi_value argv[ARGC_FOUR] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != OHOS::Rosen::ARGC_FOUR) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[ARG_INDEX_ZERO], bundleName)) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "Failed to convert parameter to bundleName");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
bool enableForceSplit = false;
|
||||
if (GetType(env, argv[ARG_INDEX_ONE]) == napi_boolean) {
|
||||
RETURN_IF_CONVERT_FAIL(env, argv[ARG_INDEX_ONE], enableForceSplit, "enableForceSplit", WmsLogTag::DEFAULT);
|
||||
}
|
||||
bool needUpdateViewport = false;
|
||||
if (GetType(env, argv[ARG_INDEX_TWO]) == napi_boolean) {
|
||||
RETURN_IF_CONVERT_FAIL(env, argv[ARG_INDEX_TWO], needUpdateViewport, "needUpdateViewport", WmsLogTag::DEFAULT);
|
||||
}
|
||||
SelectMode selectMode = SelectMode::WIDE_MODE;
|
||||
if (GetType(env, argv[ARG_INDEX_THREE]) == napi_number) {
|
||||
RETURN_IF_CONVERT_FAIL(env, argv[ARG_INDEX_THREE], selectMode, "selectMode", WmsLogTag::DEFAULT);
|
||||
}
|
||||
|
||||
TLOGI(WmsLogTag::DEFAULT, "SetAppForceLandscapeConfigEnable bundleName: %{public}s, enable: %{public}d, "
|
||||
"needUpdateViewport: %{public}d, selectMode: %{public}u", bundleName.c_str(),
|
||||
enableForceSplit, needUpdateViewport, static_cast<uint32_t>(selectMode));
|
||||
|
||||
SceneSessionManager::GetInstance().SetAppForceLandscapeConfigEnable(bundleName, enableForceSplit,
|
||||
needUpdateViewport, selectMode);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsSceneSessionManager::SetSelectMode(napi_env env, napi_callback_info info)
|
||||
{
|
||||
JsSceneSessionManager* me = CheckParamsAndGetThis<JsSceneSessionManager>(env, info);
|
||||
|
||||
@@ -118,7 +118,6 @@ public:
|
||||
static napi_value NotifySCBRecentStateChange(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateDisplayHookInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateAppHookDisplayInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateAppHookWindowInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value NotifyHookOrientationChange(napi_env env, napi_callback_info info);
|
||||
static napi_value InitScheduleUtils(napi_env env, napi_callback_info info);
|
||||
static napi_value SetAppForceLandscapeConfig(napi_env env, napi_callback_info info);
|
||||
@@ -148,7 +147,6 @@ public:
|
||||
static napi_value NotifySupportRotationChange(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAllJsonProfile(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJsonProfile(napi_env env, napi_callback_info info);
|
||||
static napi_value SetAppForceLandscapeConfigEnable(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSelectMode(napi_env env, napi_callback_info info);
|
||||
|
||||
/*
|
||||
@@ -274,7 +272,6 @@ private:
|
||||
napi_value OnNotifySCBRecentStateChange(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateDisplayHookInfo(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateAppHookDisplayInfo(napi_env env, napi_callback_info info);
|
||||
napi_value OnUpdateAppHookWindowInfo(napi_env env, napi_callback_info info);
|
||||
napi_value OnNotifyHookOrientationChange(napi_env env, napi_callback_info info);
|
||||
napi_value OnInitScheduleUtils(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetAppForceLandscapeConfig(napi_env env, napi_callback_info info);
|
||||
@@ -300,7 +297,6 @@ private:
|
||||
napi_value OnNotifySupportRotationChange(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetAllJsonProfile(napi_env env, napi_callback_info info);
|
||||
napi_value OnGetJsonProfile(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetAppForceLandscapeConfigEnable(napi_env env, napi_callback_info info);
|
||||
napi_value OnSetSelectMode(napi_env env, napi_callback_info info);
|
||||
|
||||
/*
|
||||
|
||||
@@ -42,6 +42,7 @@ constexpr int32_t INVALID_ID = -1;
|
||||
namespace {
|
||||
const std::string ON_SCREEN_CONNECTION_CHANGE_CALLBACK = "screenConnectChange";
|
||||
const std::string ON_TENT_MODE_CHANGE_CALLBACK = "tentModeChange";
|
||||
const std::string ON_EXT_SCREEN_UNSUPPORT_CALLBACK = "extScreenUnsupport";
|
||||
const std::map<ScbScreenPowerState, ScreenPowerState> POWER_STATE_MAP {
|
||||
{ ScbScreenPowerState::POWER_OFF, ScreenPowerState::POWER_OFF },
|
||||
{ ScbScreenPowerState::POWER_DOZE, ScreenPowerState::POWER_DOZE },
|
||||
@@ -90,6 +91,7 @@ napi_value JsScreenSessionManager::Init(napi_env env, napi_value exportObj)
|
||||
|
||||
const char* moduleName = "JsScreenSessionManager";
|
||||
BindNativeFunction(env, exportObj, "on", moduleName, JsScreenSessionManager::RegisterCallback);
|
||||
BindNativeFunction(env, exportObj, "off", moduleName, JsScreenSessionManager::UnRegisterCallback);
|
||||
BindNativeFunction(env, exportObj, "updateScreenRotationProperty", moduleName,
|
||||
JsScreenSessionManager::UpdateScreenRotationProperty);
|
||||
BindNativeFunction(env, exportObj, "updateServerScreenProperty", moduleName,
|
||||
@@ -190,6 +192,13 @@ napi_value JsScreenSessionManager::RegisterCallback(napi_env env, napi_callback_
|
||||
return (me != nullptr) ? me->OnRegisterCallback(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsScreenSessionManager::UnRegisterCallback(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::DMS, "[NAPI]UnRegisterCallback");
|
||||
JsScreenSessionManager* me = CheckParamsAndGetThis<JsScreenSessionManager>(env, info);
|
||||
return (me != nullptr) ? me->OnUnRegisterCallback(env, info) : nullptr;
|
||||
}
|
||||
|
||||
napi_value JsScreenSessionManager::UpdateScreenRotationProperty(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::DMS, "[NAPI]UpdateScreenRotationProperty");
|
||||
@@ -534,6 +543,145 @@ void JsScreenSessionManager::OnTentModeChange(const TentMode tentMode)
|
||||
}
|
||||
}
|
||||
|
||||
void JsScreenSessionManager::RegisterTransRSEventCallback(napi_env env, napi_ref& callback, RSExposedEventType type)
|
||||
{
|
||||
TLOGI(WmsLogTag::DMS, "[NAPI]Register, type:%{public}u", static_cast<uint32_t>(type));
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(rsEventCallbacksMutex_);
|
||||
auto it = rsEventCallbacks_.find(type);
|
||||
if (it != rsEventCallbacks_.end()) {
|
||||
napi_value callbackNapi;
|
||||
napi_get_reference_value(env, callback, &callbackNapi);
|
||||
|
||||
for (auto* callbackItem : it->second) {
|
||||
if (!callbackItem) {
|
||||
continue;
|
||||
}
|
||||
bool isEquals = false;
|
||||
napi_strict_equals(env, callbackItem->GetNapiValue(), callbackNapi, &isEquals);
|
||||
if (isEquals) {
|
||||
TLOGW(WmsLogTag::DMS, "[NAPI]Callback already registered for type:%{public}u",
|
||||
static_cast<uint32_t>(type));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NativeReference* callbackRef = reinterpret_cast<NativeReference*>(callback);
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(rsEventCallbacksMutex_);
|
||||
rsEventCallbacks_[type].emplace_back(callbackRef);
|
||||
}
|
||||
|
||||
bool isFirstCallback = false;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(rsEventCallbacksMutex_);
|
||||
isFirstCallback = (rsEventCallbacks_[type].size() == 1);
|
||||
}
|
||||
if (isFirstCallback) {
|
||||
ScreenSessionManagerClient::GetInstance().RegisterTransRSEventListener(type, this);
|
||||
}
|
||||
|
||||
TLOGI(WmsLogTag::DMS, "[NAPI]Success to register type:%{public}u", static_cast<uint32_t>(type));
|
||||
}
|
||||
|
||||
void JsScreenSessionManager::UnRegisterTransRSEventCallback(napi_env env, napi_ref& callback, RSExposedEventType type)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock(rsEventCallbacksMutex_);
|
||||
auto it = rsEventCallbacks_.find(type);
|
||||
if (it == rsEventCallbacks_.end()) {
|
||||
TLOGE(WmsLogTag::DMS, "[NAPI] No callbacks registered for type:%{public}u", static_cast<uint32_t>(type));
|
||||
return;
|
||||
}
|
||||
|
||||
auto& callbacks = it->second;
|
||||
auto iter = std::find_if(callbacks.begin(), callbacks.end(),
|
||||
[&](NativeReference* callbackItem) {
|
||||
if (!callbackItem) return false;
|
||||
napi_value callbackNapi;
|
||||
napi_get_reference_value(env, callback, &callbackNapi);
|
||||
bool isEquals = false;
|
||||
napi_strict_equals(env, callbackItem->GetNapiValue(), callbackNapi, &isEquals);
|
||||
return isEquals;
|
||||
});
|
||||
if (iter != callbacks.end()) {
|
||||
napi_delete_reference(env, reinterpret_cast<napi_ref>(*iter));
|
||||
callbacks.erase(iter);
|
||||
TLOGI(WmsLogTag::DMS, "[NAPI] Unregistered callback for type:%{public}u", static_cast<uint32_t>(type));
|
||||
if (callbacks.empty()) {
|
||||
rsEventCallbacks_.erase(it);
|
||||
ScreenSessionManagerClient::GetInstance().UnRegisterTransRSEventListener(type, this);
|
||||
}
|
||||
} else {
|
||||
TLOGE(WmsLogTag::DMS, "[NAPI]Callback not registered for type:%{public}u", static_cast<uint32_t>(type));
|
||||
}
|
||||
}
|
||||
|
||||
napi_value JsScreenSessionManager::ConvertRsEventToNapiValue(napi_env env, const sptr<RSEventDataBase>& event)
|
||||
{
|
||||
if (!event) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value obj;
|
||||
napi_create_object(env, &obj);
|
||||
|
||||
switch (event->GetEventType()) {
|
||||
case RSExposedEventType::EXT_SCREEN_UNSUPPORT: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void JsScreenSessionManager::OnTransRSEvent(const sptr<RSEventDataBase>& data)
|
||||
{
|
||||
if (!data) {
|
||||
TLOGE(WmsLogTag::DMS, "[NAPI] data is null");
|
||||
return;
|
||||
}
|
||||
|
||||
RSExposedEventType type = data->GetEventType();
|
||||
std::vector<NativeReference*> callbacks;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(rsEventCallbacksMutex_);
|
||||
auto it = rsEventCallbacks_.find(type);
|
||||
if (it == rsEventCallbacks_.end() || it->second.empty()) {
|
||||
TLOGW(WmsLogTag::DMS, "[NAPI] callbacks empty for type:%{public}u", static_cast<uint32_t>(type));
|
||||
return;
|
||||
}
|
||||
callbacks = it->second;
|
||||
}
|
||||
|
||||
for (auto& callback : callbacks) {
|
||||
TLOGI(WmsLogTag::DMS, "[NAPI] OnRSEvent begin, type:%{public}u", static_cast<uint32_t>(type));
|
||||
auto asyncTask = [this, callback, data, env = env_]() {
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsScreenSessionManager::OnRSEvent");
|
||||
|
||||
napi_value jsEvent = ConvertRsEventToNapiValue(env, data);
|
||||
napi_value argv[] = { jsEvent };
|
||||
napi_value method = callback->GetNapiValue();
|
||||
if (method == nullptr) {
|
||||
TLOGNE(WmsLogTag::DMS, "Failed to get method callback from object!");
|
||||
return;
|
||||
}
|
||||
napi_call_function(env, NapiGetUndefined(env), method, ArraySize(argv), argv, nullptr);
|
||||
};
|
||||
|
||||
if (env_ != nullptr) {
|
||||
napi_status ret = napi_send_event(env_, asyncTask, napi_eprio_vip, "OnRSEvent");
|
||||
if (ret != napi_status::napi_ok) {
|
||||
TLOGE(WmsLogTag::DMS, "Failed to SendEvent.");
|
||||
}
|
||||
} else {
|
||||
TLOGE(WmsLogTag::DMS, "env is nullptr");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
napi_value JsScreenSessionManager::SetCameraStatus(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TLOGD(WmsLogTag::DMS, "[NAPI]SetCameraStatus");
|
||||
@@ -684,6 +832,8 @@ napi_value JsScreenSessionManager::OnRegisterCallback(napi_env env, const napi_c
|
||||
RegisterScreenConnectionCallback(env, callbackRef);
|
||||
} else if (callbackType == ON_TENT_MODE_CHANGE_CALLBACK) {
|
||||
RegisterTentModeCallback(env, callbackRef);
|
||||
} else if (callbackType == ON_EXT_SCREEN_UNSUPPORT_CALLBACK) {
|
||||
RegisterTransRSEventCallback(env, callbackRef, RSExposedEventType::EXT_SCREEN_UNSUPPORT);
|
||||
} else {
|
||||
TLOGE(WmsLogTag::DMS, "Unsupported callback type: %{public}s.", callbackType.c_str());
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM)));
|
||||
@@ -691,6 +841,25 @@ napi_value JsScreenSessionManager::OnRegisterCallback(napi_env env, const napi_c
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsScreenSessionManager::OnUnRegisterCallback(napi_env env, const napi_callback_info info)
|
||||
{
|
||||
std::string callbackType;
|
||||
napi_ref callbackRef;
|
||||
if (!ObtainCallBackInfo(env, info, callbackType, callbackRef)) {
|
||||
TLOGE(WmsLogTag::DMS, "[NAPI] param check fail");
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM)));
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
if (callbackType == ON_EXT_SCREEN_UNSUPPORT_CALLBACK) {
|
||||
UnRegisterTransRSEventCallback(env, callbackRef, RSExposedEventType::EXT_SCREEN_UNSUPPORT);
|
||||
} else {
|
||||
TLOGE(WmsLogTag::DMS, "Unsupported callback type: %{public}s.", callbackType.c_str());
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM)));
|
||||
}
|
||||
napi_delete_reference(env, callbackRef);
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
|
||||
void JsScreenSessionManager::RegisterScreenConnectionCallback(napi_env env, napi_ref& callback)
|
||||
{
|
||||
TLOGI(WmsLogTag::DMS, "[NAPI] begin");
|
||||
@@ -1534,7 +1703,7 @@ napi_value JsScreenSessionManager::OnGetScreenSnapshotWithAllWindows(napi_env en
|
||||
std::array<double, ARGC_TWO> scaleParam;
|
||||
for (size_t i = 0; i < ARGC_TWO; i++) {
|
||||
if (!ConvertFromJsValue(env, argv[i + 1], scaleParam[i])) {
|
||||
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to scale[%d]", i + 1);
|
||||
TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to scale[%zu]", i + 1);
|
||||
napi_throw(env, CreateJsError(env, static_cast<int32_t>(WSErrorCode::WS_ERROR_INVALID_PARAM),
|
||||
"Input parameter is missing or invalid"));
|
||||
return NapiGetUndefined(env);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
class JsScreenSessionManager final : public IScreenConnectionListener, public ITentModeListener,
|
||||
public PowerMgr::TakeOverShutdownCallbackStub {
|
||||
public ITransRSEventListener, public PowerMgr::TakeOverShutdownCallbackStub {
|
||||
public:
|
||||
explicit JsScreenSessionManager(napi_env env);
|
||||
~JsScreenSessionManager();
|
||||
@@ -40,9 +40,11 @@ public:
|
||||
void OnScreenDisconnected(const sptr<ScreenSession>& screenSession) override;
|
||||
void OnTentModeChange(const TentMode tentMode) override;
|
||||
bool OnTakeOverShutdown(const PowerMgr::TakeOverInfo& info) override;
|
||||
void OnTransRSEvent(const sptr<RSEventDataBase>& data) override;
|
||||
|
||||
private:
|
||||
static napi_value RegisterCallback(napi_env env, napi_callback_info info);
|
||||
static napi_value UnRegisterCallback(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateScreenRotationProperty(napi_env env, napi_callback_info info);
|
||||
static napi_value UpdateServerScreenProperty(napi_env env, napi_callback_info info);
|
||||
static napi_value GetCurvedCompressionArea(napi_env env, napi_callback_info info);
|
||||
@@ -83,8 +85,12 @@ private:
|
||||
static napi_value RegisterSwitchUserAnimationNotification(napi_env env, napi_callback_info info);
|
||||
|
||||
napi_value OnRegisterCallback(napi_env env, const napi_callback_info info);
|
||||
napi_value OnUnRegisterCallback(napi_env env, const napi_callback_info info);
|
||||
void RegisterScreenConnectionCallback(napi_env env, napi_ref& callbackRef);
|
||||
void RegisterTentModeCallback(napi_env env, napi_ref& callbackRef);
|
||||
void RegisterTransRSEventCallback(napi_env env, napi_ref& callback, RSExposedEventType type);
|
||||
void UnRegisterTransRSEventCallback(napi_env env, napi_ref& callback, RSExposedEventType type);
|
||||
napi_value ConvertRsEventToNapiValue(napi_env env, const sptr<RSEventDataBase>& data);
|
||||
napi_value OnUpdateScreenRotationProperty(napi_env env, const napi_callback_info info);
|
||||
napi_value OnUpdateServerScreenProperty(napi_env env, const napi_callback_info info);
|
||||
napi_value OnGetCurvedCompressionArea(napi_env env, const napi_callback_info info);
|
||||
@@ -134,6 +140,8 @@ private:
|
||||
napi_env env_;
|
||||
std::map<uint64_t, napi_ref> jsScreenSessionMap_;
|
||||
std::shared_mutex tentModeChangeCallbackMutex_;
|
||||
std::shared_mutex rsEventCallbacksMutex_;
|
||||
std::unordered_map<RSExposedEventType, std::vector<NativeReference*>> rsEventCallbacks_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
||||
@@ -90,7 +90,8 @@ ohos_shared_library("screen_session_manager") {
|
||||
"src/setting_observer.cpp",
|
||||
"src/setting_provider.cpp",
|
||||
"src/zidl/screen_session_manager_stub.cpp",
|
||||
"src/screen_session_manager_adapter.cpp"
|
||||
"src/screen_session_manager_adapter.cpp",
|
||||
"src/rs_event_data_manager.cpp"
|
||||
]
|
||||
|
||||
cflags_cc = [ "-std=c++17" ]
|
||||
@@ -283,6 +284,7 @@ ohos_shared_library("screen_session_manager") {
|
||||
print("window manager screen multi usr ability is disabled.")
|
||||
}
|
||||
|
||||
ldflags = [ "-Wl,-Bsymbolic-functions" ]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "window_manager"
|
||||
subsystem_name = "window"
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2026 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 SCREEN_RS_EVENT_DATA_MANAGER_H
|
||||
#define SCREEN_RS_EVENT_DATA_MANAGER_H
|
||||
|
||||
#include <string>
|
||||
#include <iremote_broker.h>
|
||||
#include <transaction/rs_interfaces.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
class RSEventDataBase : public Parcelable {
|
||||
public:
|
||||
virtual ~RSEventDataBase() = default;
|
||||
virtual RSExposedEventType GetEventType() const = 0;
|
||||
virtual bool Unmarshalling(Parcel& parcel) = 0;
|
||||
};
|
||||
|
||||
class RSExtScreenUnsupportEventData : public RSEventDataBase {
|
||||
public:
|
||||
~RSExtScreenUnsupportEventData() override = default;
|
||||
RSExposedEventType GetEventType() const override;
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
bool Unmarshalling(Parcel& parcel) override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* SCREEN_RS_EVENT_DATA_MANAGER_H */
|
||||
@@ -333,6 +333,7 @@ public:
|
||||
|
||||
bool IsFoldable() override;
|
||||
bool IsCaptured() override;
|
||||
bool IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList) override;
|
||||
|
||||
FoldStatus GetFoldStatus() override;
|
||||
SuperFoldStatus GetSuperFoldStatus() override;
|
||||
@@ -396,7 +397,7 @@ public:
|
||||
void OnDisconnect(ScreenId screenId) override {}
|
||||
void OnPropertyChange(const ScreenProperty& newProperty, ScreenPropertyChangeReason reason,
|
||||
ScreenId screenId) override;
|
||||
void UpdateDisplayOrientationWhenBootAnimation(ScreenId screenId);
|
||||
void UpdateDisplayOrientationWhenBootAnimation(ScreenId screenId, const ScreenProperty& screenProperty);
|
||||
void OnFoldPropertyChange(ScreenId screenId, const ScreenProperty& newProperty, ScreenPropertyChangeReason reason,
|
||||
FoldDisplayMode displayMode) override;
|
||||
void OnPowerStatusChange(DisplayPowerEvent event, EventStatus status,
|
||||
@@ -646,6 +647,7 @@ public:
|
||||
MultiScreenPositionOptions& dynamicScreenOptions, uint32_t adjacentPercentage, uint32_t staticHeight,
|
||||
uint32_t staticWidth, uint32_t dynamicHeight);
|
||||
void GetStaticAndDynamicSession();
|
||||
const std::map<FoldDisplayMode, RRect>& GetScreenActiveModeRectMap();
|
||||
|
||||
static bool GetScreenSessionMngSystemAbility();
|
||||
void RunFinishTask();
|
||||
@@ -713,6 +715,11 @@ private:
|
||||
void ConfigureWaterfallDisplayCompressionParams();
|
||||
void ConfigureScreenSnapshotParams();
|
||||
void RegisterScreenChangeListener();
|
||||
void RegisterRSListeners();
|
||||
void DoRegisterRSListeners();
|
||||
void OnTransRSEvent(const std::shared_ptr<RSExposedEventDataBase>& rsRawData);
|
||||
sptr<RSEventDataBase> ConvertRSExposedEventDataBase(
|
||||
const std::shared_ptr<RSExposedEventDataBase>& rsRawData);
|
||||
void RegisterFoldNotSwitchingListener();
|
||||
void RegisterBrightnessInfoChangeListener();
|
||||
void UnregisterBrightnessInfoChangeListener();
|
||||
@@ -1240,6 +1247,7 @@ private:
|
||||
void SetOptionConfig(ScreenId screenId, VirtualScreenOption option);
|
||||
void DoSetScreenPowerStatus(ScreenId rsScreenId, ScreenPowerStatus status);
|
||||
void ClearScreenPowerStatus(ScreenId rsScreenId);
|
||||
void InitScreenActiveModeRectMap();
|
||||
|
||||
std::map<ScreenId, ScreenPowerStatus> screenPowerStatusMap_;
|
||||
std::mutex screenPowerStatusMapMutex_;
|
||||
@@ -1250,6 +1258,9 @@ private:
|
||||
std::atomic<FoldDisplayMode> foldDisplayModeAfterRotation_ = FoldDisplayMode::UNKNOWN;
|
||||
std::atomic<bool> onBootAnimation_ = false;
|
||||
bool isBoot_ = false;
|
||||
int32_t retryCount_ = 50;
|
||||
std::mutex screenActiveModeRectMapMutex_;
|
||||
std::map<FoldDisplayMode, RRect> screenActiveModeRectMap_ = {};
|
||||
|
||||
private:
|
||||
class ScbClientListenerDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
|
||||
@@ -282,6 +282,7 @@ public:
|
||||
|
||||
virtual bool IsFoldable() { return false; }
|
||||
virtual bool IsCaptured() { return false; }
|
||||
virtual bool IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList) { return false; }
|
||||
|
||||
virtual FoldStatus GetFoldStatus() { return FoldStatus::UNKNOWN; }
|
||||
virtual SuperFoldStatus GetSuperFoldStatus() { return SuperFoldStatus::UNKNOWN; }
|
||||
|
||||
@@ -184,6 +184,7 @@ public:
|
||||
|
||||
bool IsFoldable() override;
|
||||
bool IsCaptured() override;
|
||||
bool IsCapturedByBundleNameList(const std::vector<std::string>& bundleNameList) override;
|
||||
|
||||
FoldStatus GetFoldStatus() override;
|
||||
SuperFoldStatus GetSuperFoldStatus() override;
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
virtual void NotifyRunSensorFoldStateManager();
|
||||
virtual float GetSpecialVirtualPixelRatio();
|
||||
virtual void PowerkeySetScreenActiveRect();
|
||||
virtual const std::map<FoldDisplayMode, RRect>& GetScreenActiveModeRectMap() const;
|
||||
private:
|
||||
std::vector<FoldCreaseRegionItem> foldCreaseRegionItems_;
|
||||
};
|
||||
|
||||
@@ -142,6 +142,7 @@ public:
|
||||
FoldStatus targetFoldStatus) const;
|
||||
virtual float GetSpecialVirtualPixelRatio();
|
||||
virtual void PowerkeySetScreenActiveRect() {};
|
||||
const std::map<FoldDisplayMode, RRect>& GetScreenActiveModeRectMap() const;
|
||||
|
||||
protected:
|
||||
FoldScreenBasePolicy();
|
||||
|
||||
@@ -262,4 +262,9 @@ void FoldScreenBaseController::PowerkeySetScreenActiveRect()
|
||||
{
|
||||
FoldScreenBasePolicy::GetInstance().PowerkeySetScreenActiveRect();
|
||||
}
|
||||
|
||||
const std::map<FoldDisplayMode, RRect>& FoldScreenBaseController::GetScreenActiveModeRectMap() const
|
||||
{
|
||||
return FoldScreenBasePolicy::GetInstance().GetScreenActiveModeRectMap();
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||