Skip to content
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

x11: Check visuals for validity #185

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Conversation

psychon
Copy link
Contributor

@psychon psychon commented Dec 10, 2023

A visual describes how colors are laid out by the X11 server. So far, softbuffer did not do anything with visuals and just passed them around. This commit adds checks that should ensure that a given visual actually lays out pixels in the only format supported by softbuffer:

  • 32 bit per pixel
  • 00RRGGBB byte order

In this patch, I also try to handle big endian systems and mixed endian situations where we are e.g. running on a big endian system and talking to a little endian X11 server. However, this is all theoretical and completely untested. I only tested my X11 server's default visual works and some ARGB visual is rejected.

Fixes: #184

@psychon psychon requested a review from notgull as a code owner December 10, 2023 17:23
A visual describes how colors are laid out by the X11 server. So far,
softbuffer did not do anything with visuals and just passed them around.
This commit adds checks that should ensure that a given visual actually
lays out pixels in the only format supported by softbuffer:

- 32 bit per pixel
- 00RRGGBB byte order

In this patch, I also try to handle big endian systems and mixed endian
situations where we are e.g. running on a big endian system and talking
to a little endian X11 server. However, this is all theoretical and
completely untested. I only tested my X11 server's default visual works
and some ARGB visual is rejected.

Fixes: rust-windowing#184
Signed-off-by: Uli Schlachter <[email protected]>
src/x11.rs Show resolved Hide resolved
src/x11.rs Outdated Show resolved Hide resolved
Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

Run rustfmt and we should be good to go

This applies a suggestion by @notgull

Co-authored-by: John Nunley <[email protected]>
Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

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

Thanks!

@notgull notgull merged commit 09b8126 into rust-windowing:master Dec 11, 2023
39 checks passed
@psychon psychon deleted the check-visual branch December 11, 2023 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

X11: Wrong behaviour for "weird" visuals?
2 participants