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

Improvements to wayland backend, and build on FreeBSD #35

Closed
wants to merge 2 commits into from

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Dec 20, 2022

  • Use wayland-client 0.30.0-beta.14
  • Use memfd instead of temporary file
  • Make sure buffer and buffer pool objects are destroyed
  • Build on FreeBSD
    • Apparently other BSDs don't support memfd? Not sure what the best solution is there.

- Use wayland-client `0.30.0-beta.14`
- Use `memfd` instead of temporary file
- Make sure buffer and buffer pool objects are destroyed
@ids1024 ids1024 changed the title Improvments to wayland backend, and build on FreeBSD Improvements to wayland backend, and build on FreeBSD Dec 20, 2022
@ids1024
Copy link
Member Author

ids1024 commented Dec 23, 2022

This was merged into https://github.com/rust-windowing/swbuf, which is now incorporated into this repository.

@ids1024 ids1024 closed this Dec 23, 2022
"Failed to instantiate Wayland Shm",
)?;
let name = CStr::from_bytes_with_nul_unchecked("softbuffer\0".as_bytes());
let tempfile_fd = unwrap(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a fallback or else this only works on Freebsd and Linux. See sctk for the fallback.

surface, shm, tempfile,
buffer: None
impl WaylandImpl {
pub unsafe fn new<W: HasRawWindowHandle>(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should deny unsafe_op_in_unsafe_fn in the whole crate.

_: &Connection,
_: &QueueHandle<State>,
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to handle release in the future, this needs a todo comment.

globals.bind(&qh, 1..=1, ()),
"Failed to instantiate Wayland Shm",
)?;
let name = CStr::from_bytes_with_nul_unchecked("softbuffer\0".as_bytes());
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't this fail if a file of the same name exists?

let shm: wl_shm::WlShm = unwrap(
globals.bind(&qh, 1..=1, ()),
"Failed to instantiate Wayland Shm",
)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should do a roundtrip after this to ensure it is initialized.

self.buffer = Some(WaylandBuffer{
fn ensure_buffer_size(&mut self, width: i32, height: i32) {
if !self.check_buffer_size_equals(width, height) {
let pool =
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause an fd leak, we don't destroy the old pool of it did exist.

)?;
let name = CStr::from_bytes_with_nul_unchecked("softbuffer\0".as_bytes());
let tempfile_fd = unwrap(
memfd_create(name, MemFdCreateFlag::MFD_CLOEXEC),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we seal the file if supported by the platform to be nice to compositors?

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.

2 participants