diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26811d6..60f7858 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,17 +91,14 @@ jobs: shell: bash run: cargo $CMD build --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES - - name: Pin versions of dev-deps - if: matrix.rust_version == '1.65.0' - run: cargo update -p half --precise 2.2.1 - - name: Build tests shell: bash if: > !((matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686')) && !contains(matrix.platform.target, 'redox') && !contains(matrix.platform.target, 'freebsd') && - !contains(matrix.platform.target, 'netbsd') + !contains(matrix.platform.target, 'netbsd') && + matrix.rust_version != '1.65.0' run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES - name: Run tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a3f7c57..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Release - -permissions: - contents: write - -on: - push: - tags: - - v[0-9]+.* - -jobs: - create-release: - if: github.repository_owner == 'rust-windowing' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: taiki-e/create-gh-release-action@v1 - with: - changelog: CHANGELOG.md - branch: master - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} - - name: Publish to crates.io - run: cargo publish --token ${{ secrets.CRATES_IO_API_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 76aab18..8c350ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,7 @@ # Unreleased -- On MacOS, Fix double-free of `NSWindow`. (#180) -- On Web, add support for more `RawWindowHandle` variants. (#188) -- On Wayland, fix buffer age. (#191) -- Update `drm` to 0.11 (#178) - * Fixes build on architectures where drm-rs did not have generated bindings. -- Update x11rb to v0.13 (#183) -- On Orbital, fix window resize. +- On MacOS, Fix double-free of `NSWindow`. +- On Web, add support for more `RawWindowHandle` variants. # 0.4.0 diff --git a/Cargo.toml b/Cargo.toml index 08ee95d..9fd5f0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "softbuffer" -version = "0.4.1" +version = "0.4.0" edition = "2021" license = "MIT OR Apache-2.0" description = "Cross-platform software buffer" @@ -70,7 +70,7 @@ features = [ ] [target.'cfg(target_os = "redox")'.dependencies] -redox_syscall = "0.5" +redox_syscall = "0.4" [build-dependencies] cfg_aliases = "0.2.0" diff --git a/src/cg.rs b/src/cg.rs index ef96fb9..9f6035a 100644 --- a/src/cg.rs +++ b/src/cg.rs @@ -30,7 +30,7 @@ pub struct CGImpl { window: id, color_space: CGColorSpace, size: Option<(NonZeroU32, NonZeroU32)>, - window_handle: W, + _window_source: W, _display: PhantomData, } @@ -62,16 +62,10 @@ impl CGImpl { color_space, size: None, _display: PhantomData, - window_handle: window_src, + _window_source: window_src, }) } - /// Get the inner window handle. - #[inline] - pub fn window(&self) -> &W { - &self.window_handle - } - pub fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Result<(), SoftBufferError> { self.size = Some((width, height)); Ok(()) diff --git a/src/kms.rs b/src/kms.rs index 2761843..6e041e6 100644 --- a/src/kms.rs +++ b/src/kms.rs @@ -73,7 +73,7 @@ pub(crate) struct KmsImpl { buffer: Option, /// Window handle that we are keeping around. - window_handle: W, + _window: W, } #[derive(Debug)] @@ -200,16 +200,10 @@ impl KmsImpl { connectors, display, buffer: None, - window_handle: window, + _window: window, }) } - /// Get the inner window handle. - #[inline] - pub fn window(&self) -> &W { - &self.window_handle - } - /// Resize the internal buffer to the given size. pub(crate) fn resize( &mut self, diff --git a/src/lib.rs b/src/lib.rs index 14191ca..6ec267c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,15 +86,6 @@ macro_rules! make_dispatch { } impl SurfaceDispatch { - fn window(&self) -> &W { - match self { - $( - $(#[$attr])* - Self::$name(inner) => inner.window(), - )* - } - } - pub fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Result<(), SoftBufferError> { match self { $( @@ -320,11 +311,6 @@ impl Surface { }) } - /// Get a reference to the underlying window handle. - pub fn window(&self) -> &W { - self.surface_impl.window() - } - /// Set the size of the buffer that will be returned by [`Surface::buffer_mut`]. /// /// If the size of the buffer does not match the size of the window, the buffer is drawn @@ -364,22 +350,6 @@ impl Surface { } } -impl AsRef for Surface { - #[inline] - fn as_ref(&self) -> &W { - self.window() - } -} - -impl HasWindowHandle for Surface { - #[inline] - fn window_handle( - &self, - ) -> Result, raw_window_handle::HandleError> { - self.window().window_handle() - } -} - /// A buffer that can be written to by the CPU and presented to the window. /// /// This derefs to a `[u32]`, which depending on the backend may be a mapping into shared memory diff --git a/src/orbital.rs b/src/orbital.rs index 50428ab..3495b89 100644 --- a/src/orbital.rs +++ b/src/orbital.rs @@ -59,7 +59,7 @@ pub struct OrbitalImpl { width: u32, height: u32, presented: bool, - window_handle: W, + _window_source: W, _display: PhantomData, } @@ -76,21 +76,15 @@ impl OrbitalImpl { width: 0, height: 0, presented: false, - window_handle: window, + _window_source: window, _display: PhantomData, }) } - /// Get the inner window handle. - #[inline] - pub fn window(&self) -> &W { - &self.window_handle - } - pub fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Result<(), SoftBufferError> { let width = width.get(); let height = height.get(); - if width != self.width || height != self.height { + if width != self.width && height != self.height { self.presented = false; self.width = width; self.height = height; @@ -163,6 +157,9 @@ impl OrbitalImpl { // Window buffer map is dropped here } + + // Tell orbital to show the latest window data + syscall::fsync(self.window_fd()).expect("failed to sync orbital window"); } /// Fetch the buffer from the window. @@ -206,13 +203,10 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferImpl<'a, D, W> { } pub fn present(self) -> Result<(), SoftBufferError> { - self.present_with_damage(&[]) - } - - pub fn present_with_damage(self, damage: &[Rect]) -> Result<(), SoftBufferError> { match self.pixels { Pixels::Mapping(mapping) => { drop(mapping); + syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window"); self.imp.presented = true; } Pixels::Buffer(buffer) => { @@ -221,19 +215,10 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferImpl<'a, D, W> { } } - // Tell orbital to show the latest window data - if damage.is_empty() { - syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window"); - } else { - use std::fmt::Write; - let mut damage_buf = "Y".to_string(); - for m in damage { - let _ = write!(damage_buf, ",{},{},{},{}", m.x, m.y, m.width, m.height); - } - syscall::write(self.imp.window_fd(), damage_buf.as_bytes()) - .expect("failed to sync orbital window"); - } - Ok(()) } + + pub fn present_with_damage(self, _damage: &[Rect]) -> Result<(), SoftBufferError> { + self.present() + } } diff --git a/src/wayland/buffer.rs b/src/wayland/buffer.rs index 06abbfc..0c8bf86 100644 --- a/src/wayland/buffer.rs +++ b/src/wayland/buffer.rs @@ -98,7 +98,7 @@ impl WaylandBuffer { width, height, width * 4, - wl_shm::Format::Argb8888, + wl_shm::Format::Xrgb8888, qh, released.clone(), ); @@ -138,7 +138,7 @@ impl WaylandBuffer { width, height, width * 4, - wl_shm::Format::Argb8888, + wl_shm::Format::Xrgb8888, &self.qh, self.released.clone(), ); diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index d61a5f1..8984872 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -83,7 +83,7 @@ pub struct WaylandImpl { /// /// This has to be dropped *after* the `surface` field, because the `surface` field implicitly /// borrows this. - window_handle: W, + _window: W, } impl WaylandImpl { @@ -109,16 +109,10 @@ impl WaylandImpl { surface: Some(surface), buffers: Default::default(), size: None, - window_handle: window, + _window: window, }) } - /// Get the inner window handle. - #[inline] - pub fn window(&self) -> &W { - &self.window_handle - } - pub fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Result<(), SoftBufferError> { self.size = Some( (|| { diff --git a/src/web.rs b/src/web.rs index 595073d..7b78fca 100644 --- a/src/web.rs +++ b/src/web.rs @@ -57,7 +57,7 @@ pub struct WebImpl { size: Option<(NonZeroU32, NonZeroU32)>, /// The underlying window handle. - window_handle: W, + _window: W, /// The underlying display handle. _display: PhantomData, @@ -114,7 +114,7 @@ impl WebImpl { buffer: Vec::new(), buffer_presented: false, size: None, - window_handle: window, + _window: window, _display: PhantomData, }) } @@ -130,17 +130,11 @@ impl WebImpl { buffer: Vec::new(), buffer_presented: false, size: None, - window_handle: window, + _window: window, _display: PhantomData, }) } - /// Get the inner window handle. - #[inline] - pub fn window(&self) -> &W { - &self.window_handle - } - /// De-duplicates the error handling between `HtmlCanvasElement` and `OffscreenCanvas`. fn resolve_ctx( result: Option>, diff --git a/src/win32.rs b/src/win32.rs index 7055b44..4263d1d 100644 --- a/src/win32.rs +++ b/src/win32.rs @@ -142,7 +142,7 @@ pub struct Win32Impl { /// The handle for the window. /// /// This should be kept alive in order to keep `window` valid. - handle: W, + _window: W, /// The display handle. /// @@ -184,17 +184,11 @@ impl Win32Impl { dc, window: hwnd, buffer: None, - handle: window, + _window: window, _display: PhantomData, }) } - /// Get the inner window handle. - #[inline] - pub fn window(&self) -> &W { - &self.handle - } - pub fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Result<(), SoftBufferError> { let (width, height) = (|| { let width = NonZeroI32::new(i32::try_from(width.get()).ok()?)?; diff --git a/src/x11.rs b/src/x11.rs index 31b2325..a5baa82 100644 --- a/src/x11.rs +++ b/src/x11.rs @@ -150,7 +150,7 @@ pub struct X11Impl { size: Option<(NonZeroU16, NonZeroU16)>, /// Keep the window alive. - window_handle: W, + _window_handle: W, } /// The buffer that is being drawn to. @@ -292,16 +292,10 @@ impl X11Impl { buffer, buffer_presented: false, size: None, - window_handle: window_src, + _window_handle: window_src, }) } - /// Get the inner window handle. - #[inline] - pub fn window(&self) -> &W { - &self.window_handle - } - /// Resize the internal buffer to the given width and height. pub(crate) fn resize( &mut self,