feat(gpui): Allow building gpui against ohos (#64579)

# Objective

This PR will allow to develop and use gpui ohos platform's crate.We need
to use ohos instead of linux logic.

## Solution

- Avoid linux logic when target is ohos.
- Add gesture for ohos.

## Testing

I've already test it in HarmonyOS emulator and physical HarmonyOS
device.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

I made a gpui backend crate for OpenHarmony
[gpui-ohos](https://github.com/ohos-rs/gpui-ohos) and Using it to
develop an application which already publish into Huawei store for a
long time.

Here is [source code](https://github.com/richerfu/nearsend/pull/14)

Here is a video to show it.



https://github.com/user-attachments/assets/26efe4f7-d5ef-473f-8dbd-e30ab14ec186


---

Release Notes:

- [GPUI] N/A
This commit is contained in:
richerfu
2026-10-26 15:29:14 +00:00
committed by GitHub
parent bed9563afc
commit 484bcbfea6
2 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ gpui_ios.workspace = true
gpui_windows.workspace = true
gpui = { workspace = true, features = ["windows-manifest"] }
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
[target.'cfg(all(any(target_os = "linux", target_os = "freebsd"), not(target_env = "ohos")))'.dependencies]
gpui_linux.workspace = true
[target.'cfg(target_os = "linux")'.dependencies]
+16 -2
View File
@@ -29,7 +29,10 @@ pub fn headless() -> gpui::Application {
/// It starts windowed in the process's own environment, or headless if that names no allowed
/// display server. Set another initial mode with [`gpui::Application::with_windowing`], and
/// switch later with [`gpui::App::request_windowing`].
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(all(
any(target_os = "linux", target_os = "freebsd"),
not(target_env = "ohos")
))]
pub fn linux(allowed_modes: gpui::WindowingModes) -> gpui::Application {
gpui::Application::with_platform(gpui_linux::linux_platform(allowed_modes))
}
@@ -83,7 +86,18 @@ pub fn current_platform(headless: bool) -> Rc<dyn Platform> {
)
}
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(target_env = "ohos")]
{
let _ = headless;
panic!(
"gpui_platform does not select an OpenHarmony backend; inject gpui-ohos with Application::with_platform"
)
}
#[cfg(all(
any(target_os = "linux", target_os = "freebsd"),
not(target_env = "ohos")
))]
{
gpui_linux::current_platform(headless)
}