Skip to content

Add Buffer::width and Buffer::height #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

madsmtm
Copy link
Member

@madsmtm madsmtm commented Jun 5, 2025

Part of #237.

I've decided to return these in pixels corresponding to the surface/buffer itself, as that's what Softbuffer concerns itself with. If the user wants to render at the current screen DPI, they either need to multiply by a scaling factor themselves, or size the buffer using logical sizes and rely on the compositor to upscale it (which we don't yet expose knobs to control, but which we could in the future).

@madsmtm madsmtm added the enhancement New feature or request label Jun 5, 2025
@@ -205,6 +205,28 @@ pub struct Buffer<'a, D, W> {
}

impl<D: HasDisplayHandle, W: HasWindowHandle> Buffer<'_, D, W> {
/// The amount of pixels wide the buffer is.
pub fn width(&self) -> usize {
Copy link
Member Author

Choose a reason for hiding this comment

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

I went with usize here, since it was just much more usable in examples.

I'd like to change resize to follow this direction as well, see:
#238

@@ -205,6 +205,28 @@ pub struct Buffer<'a, D, W> {
}

impl<D: HasDisplayHandle, W: HasWindowHandle> Buffer<'_, D, W> {
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit unsure whether these should go on the buffer or the surface? Or does it make sense both places?

@madsmtm madsmtm force-pushed the madsmtm/width-height branch from 6789eff to 344f8b7 Compare June 5, 2025 17:21
@madsmtm madsmtm force-pushed the madsmtm/width-height branch from 344f8b7 to 3f255f4 Compare June 5, 2025 17:41
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.

2 participants