Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ loro-protocol = "0.3"
# translucent compositing, plus blur-aware scene batching (#10).
# Per-pixel rounded clipping (`Window::with_rounded_clip`, 361ff20).
# Drags need the button held and 4px of travel (0dc69aa).
gpui = { git = "https://github.com/zeronsh/zui", rev = "0dc69aa254841738b1e84ac743fa0aa435ad71b1" }
gpui_platform = { git = "https://github.com/zeronsh/zui", rev = "0dc69aa254841738b1e84ac743fa0aa435ad71b1", features = [
# Atlas tiles updated in place from pixels or imported dma-bufs, display-rate
# frame callbacks in inactive windows, and Wayland frames that no longer stop
# after a forced draw (b564a34, zeronsh/zui#18).
gpui = { git = "https://github.com/zeronsh/zui", rev = "b564a34413bb7ef1da04121c4a287758f94993d9" }
gpui_platform = { git = "https://github.com/zeronsh/zui", rev = "b564a34413bb7ef1da04121c4a287758f94993d9", features = [
"wayland",
"x11",
"font-kit",
"runtime_shaders",
] }
gpui_tokio = { git = "https://github.com/zeronsh/zui", rev = "0dc69aa254841738b1e84ac743fa0aa435ad71b1" }
gpui-base = { git = "https://github.com/zeronsh/gpui-component", rev = "6ffe5e575bd0db31d69764773a823cdeb8913d8e" }
gpui_tokio = { git = "https://github.com/zeronsh/zui", rev = "b564a34413bb7ef1da04121c4a287758f94993d9" }
gpui-base = { git = "https://github.com/zeronsh/gpui-component", rev = "59f89243cea79dd70eb7a619b3930c374ef6958a" }

# diffs
similar = "2"
Expand Down
1 change: 1 addition & 0 deletions crates/ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ foreign-types = "0.5"
block = "0.1"

[target.'cfg(target_os = "linux")'.dependencies]
libc.workspace = true
ashpd = { version = "0.13.13", default-features = false, features = ["async-io", "global_shortcuts", "screenshot", "settings"] }
atspi = { version = "0.30.0", features = ["zbus"] }
async-io = "2"
Expand Down
60 changes: 60 additions & 0 deletions crates/ui/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ fn main() {
}

println!("cargo:rerun-if-changed=src/browser/linux/helper.c");
println!("cargo:rerun-if-changed=src/browser/linux/wpe.c");
println!("cargo:rerun-if-env-changed=ZERON_WPE");
println!("cargo:rerun-if-env-changed=PKG_CONFIG_PATH");
if env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("linux") {
return;
}
build_wpe_helper();
let output = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("zeron-webkit");
let flags = Command::new("pkg-config")
.args(["--cflags", "--libs", "webkit2gtk-4.1", "json-glib-1.0"])
Expand Down Expand Up @@ -59,3 +63,59 @@ fn main() {
.expect("C compiler is required to build the Linux browser helper");
assert!(status.success(), "Linux browser helper compilation failed");
}

/// The WPE WebKit helper is optional: without WPE WebKit 2.50+ development
/// files, with ones it does not compile against (an older GBM), or with
/// `ZERON_WPE=0`, the build embeds an empty helper and the browser uses
/// WebKitGTK.
fn build_wpe_helper() {
let output = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("zeron-wpe");
let packages = [
"wpe-webkit-2.0 >= 2.50",
"wpe-platform-2.0",
"json-glib-1.0",
"gbm",
"egl",
"glesv2",
"xkbcommon",
];
let flags = (env::var("ZERON_WPE").as_deref() != Ok("0"))
.then(|| {
Command::new("pkg-config")
.arg("--cflags")
.arg("--libs")
.args(packages)
.output()
.ok()
})
.flatten()
.filter(|flags| flags.status.success());
let Some(flags) = flags else {
println!(
"cargo:warning=WPE WebKit 2.50+ development files not found; the Linux browser will use WebKitGTK"
);
std::fs::write(&output, []).unwrap();
return;
};
let status = Command::new(env::var("CC").unwrap_or_else(|_| "cc".into()))
.args([
"-std=gnu11",
"-O2",
"-Wall",
"-Wextra",
"-Wno-unused-parameter",
"src/browser/linux/wpe.c",
"-o",
])
.arg(&output)
.args(String::from_utf8(flags.stdout).unwrap().split_whitespace())
.arg("-lm")
.status()
.expect("C compiler is required to build the Linux browser helper");
if !status.success() {
println!(
"cargo:warning=WPE WebKit helper compilation failed; the Linux browser will use WebKitGTK"
);
std::fs::write(&output, []).unwrap();
}
}
22 changes: 21 additions & 1 deletion crates/ui/examples/browser-fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ fn capture(directory: &std::path::Path, name: &str) -> anyhow::Result<()> {
.arg(&path)
.status()?
};
// A nested Wayland compositor whose only output is this window: `grim`.
#[cfg(not(target_os = "macos"))]
let status = {
let status = if let Ok(command) = std::env::var("ZERON_BROWSER_CAPTURE_COMMAND") {
std::process::Command::new(command).arg(&path).status()?
} else {
let capture_window = std::env::var("ZERON_BROWSER_CAPTURE_WINDOW").ok();
let windows = std::process::Command::new("xdotool")
.args([
Expand Down Expand Up @@ -170,6 +173,18 @@ fn main() -> anyhow::Result<()> {
let mut request = [0; 4096];
let n = stream.read(&mut request).unwrap_or(0);
let request = String::from_utf8_lossy(&request[..n]);
// The bench's video, from `ZERON_BROWSER_BENCH_VIDEO`.
if request.starts_with("GET /bench.mp4 ")
&& let Some(video) = std::env::var_os("ZERON_BROWSER_BENCH_VIDEO").and_then(|path| std::fs::read(path).ok())
{
let _ = write!(
stream,
"HTTP/1.1 200 OK\r\nContent-Type: video/mp4\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
video.len()
);
let _ = stream.write_all(&video);
continue;
}
let (title, html) = if request.starts_with("GET /two ") {
(
"Details",
Expand Down Expand Up @@ -222,6 +237,7 @@ fn main() -> anyhow::Result<()> {
window_bounds: Some(WindowBounds::Windowed(Bounds::new(gpui::point(px(12.),px(30.)), size(px(1000.),px(680.))))),
titlebar: Some(gpui::TitlebarOptions { title: None, appears_transparent: true, traffic_light_position: Some(gpui::point(px(14.),px(14.))) }),
app_owns_titlebar_drag: true,
app_id: Some("zeron-browser-fixture".into()),
..Default::default()
}, |_, cx| cx.new(|cx| shell::Shell::new(state.clone(), boot, cx))).unwrap();
state.update(cx, |_, cx| cx.notify());
Expand Down Expand Up @@ -258,6 +274,10 @@ fn main() -> anyhow::Result<()> {
pause(cx, 50).await;
}
pause(cx, 500).await;
#[cfg(target_os = "linux")]
if let Some(seconds) = std::env::var("ZERON_BROWSER_BENCH").ok().and_then(|s| s.parse().ok()) {
return linux::bench(window, first.clone(), &_origin, &output, seconds, cx).await;
}
capture_frame(window, &output, "browser-preview-dark", cx).await?;
// Real DOM click, native navigation and history.
first.read_with(cx, |b, _| b.fixture_eval("document.getElementById('details').click()"));
Expand Down
Loading
Loading