Skip to content

Conversation

@madsmtm
Copy link
Member

@madsmtm madsmtm commented Nov 24, 2025

Use u32 in our public API instead of NonZeroU32, and handle width == 0 || height == 0 internally. This resolves #238. Note that there are still a few inconsistencies between platforms in how things are rendered when the buffer is smaller than the window, but that is pre-existing, see #177.

We can now also default to a 0-sized buffer instead of panicking in buffer_mut, which resolves #106.

Tested on:

  • Android
  • CoreGraphics
  • KMS/DRM
  • Orbital
  • Wayland
  • Web
  • Win32
  • X11

@madsmtm madsmtm added the enhancement New feature or request label Nov 24, 2025
@madsmtm madsmtm added DS - Android NDK DS - CoreGraphics macOS/iOS/tvOS/watchOS/visionOS backend DS - Orbital DS - Wayland DS - Web WebAssembly / WASM backend DS - Win32 Windows backend DS - X11 Xlib / Xcb backend DS - DRM/KMS labels Jan 14, 2026
@madsmtm madsmtm force-pushed the madsmtm/support-zero-sized branch 2 times, most recently from 5806393 to 76304d2 Compare January 14, 2026 04:49
@madsmtm madsmtm removed DS - Android NDK DS - CoreGraphics macOS/iOS/tvOS/watchOS/visionOS backend DS - Orbital DS - Wayland DS - Web WebAssembly / WASM backend DS - Win32 Windows backend DS - X11 Xlib / Xcb backend DS - DRM/KMS labels Jan 14, 2026
@madsmtm madsmtm added this to the Softbuffer v0.5 milestone Jan 14, 2026
@madsmtm madsmtm changed the base branch from master to madsmtm/web-niceties January 15, 2026 07:20
Base automatically changed from madsmtm/web-niceties to master January 17, 2026 07:22
@madsmtm madsmtm force-pushed the madsmtm/support-zero-sized branch 7 times, most recently from e557e78 to 2d34da5 Compare January 19, 2026 08:50
@madsmtm madsmtm force-pushed the madsmtm/support-zero-sized branch from 2d34da5 to 2f274d7 Compare January 19, 2026 17:06
And default to a 0-sized buffer instead of panicking in `buffer_mut`.
@madsmtm madsmtm force-pushed the madsmtm/support-zero-sized branch from 2f274d7 to 13c5cee Compare January 19, 2026 17:25
self.released.clone(),
))
} else {
None
Copy link
Member

@ids1024 ids1024 Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can attach a null buffer to a surface on Wayland, but this has the effect of unmapping the surface, rather than having a surface with a 0x0 size. If that isn't how this behaves on other platforms, it may be better to use a 1x1 (transparent?) buffer to approximate the effect of having the surface mapped but with a 0x0 size.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've been kinda going back and forth between what would be best here.

On macOS, if you don't provide any CALayer contents, whatever is behind the surface is rendered (usually the window backdrop). If the window is marked as transparent (the window backdrop is made transparent), only the title bar will remain.

IIUC that's basically what using a 1x1 buffer would do on Wayland, whereas unmapping the surface also means that the window decorations etc. are removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

Handle zero-sized buffers internally Initial Window Size

3 participants