From cc7d1bc754fa50d6185464b57b55ed1763cfc9e2 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 14 Nov 2023 08:39:00 -0800 Subject: [PATCH 1/2] Update `winit_test` and re-enable `tests/present_and_fetch` --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 2 +- tests/present_and_fetch.rs | 5 ----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60f7858..27bddef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,9 +79,9 @@ jobs: targets: ${{ matrix.platform.target }} components: clippy, rust-src - - name: Install libwayland + - name: Install libwayland and xkbcommon if: (matrix.platform.os == 'ubuntu-latest') - run: sudo apt-get update && sudo apt-get install libwayland-dev + run: sudo apt-get update && sudo apt-get install libwayland-dev libxkbcommon-x11-dev - name: Install GCC Multilib if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686') diff --git a/Cargo.toml b/Cargo.toml index de77299..708ee57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ colorous = "1.0.12" criterion = { version = "0.4.0", default-features = false, features = ["cargo_bench_support"] } instant = "0.1.12" winit = "0.29.2" -winit-test = "0.1.0" +winit-test = "0.2.0" [dev-dependencies.image] version = "0.24.6" diff --git a/tests/present_and_fetch.rs b/tests/present_and_fetch.rs index 9e87c04..bdb188e 100644 --- a/tests/present_and_fetch.rs +++ b/tests/present_and_fetch.rs @@ -1,5 +1,3 @@ -// TODO: Once winit is updated again, restore this test. -/* use softbuffer::{Context, Surface}; use std::num::NonZeroU32; use winit::event_loop::EventLoopWindowTarget; @@ -56,6 +54,3 @@ fn all_red(elwt: &EventLoopWindowTarget<()>) { } winit_test::main!(all_red); -*/ - -fn main() {} From 40aafa51ef7fe06fda3b53e0894f01a5ff6e4db2 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Wed, 15 Nov 2023 12:03:25 +0100 Subject: [PATCH 2/2] Fix Wasm build --- tests/present_and_fetch.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/present_and_fetch.rs b/tests/present_and_fetch.rs index bdb188e..f86633b 100644 --- a/tests/present_and_fetch.rs +++ b/tests/present_and_fetch.rs @@ -3,25 +3,18 @@ use std::num::NonZeroU32; use winit::event_loop::EventLoopWindowTarget; fn all_red(elwt: &EventLoopWindowTarget<()>) { - let window = winit::window::WindowBuilder::new() - .with_title("all_red") - .build(elwt) - .unwrap(); + #[cfg_attr(not(target_arch = "wasm32"), allow(unused_mut))] + let mut builder = winit::window::WindowBuilder::new().with_title("all_red"); #[cfg(target_arch = "wasm32")] { - use winit::platform::web::WindowExtWebSys; - - web_sys::window() - .unwrap() - .document() - .unwrap() - .body() - .unwrap() - .append_child(&window.canvas()) - .unwrap(); + use winit::platform::web::WindowBuilderExtWebSys; + + builder = builder.with_append(true); } + let window = builder.build(elwt).unwrap(); + // winit does not wait for the window to be mapped... sigh #[cfg(not(target_arch = "wasm32"))] std::thread::sleep(std::time::Duration::from_millis(1));