WIP: Add support for wlr-screencopy-unstable#85
Conversation
The buffer file descriptor is retained until there are no references, but it is closed immediately upon creation, which is inaccurate.
Allows a user to know when a view buffer has been changed.
|
Currently, wlr-screencopy-unstable-v1 is preferred over ext-image-capture-source-v1 for simplicity reasons, as the upstreamed protocol is much more complex, and includes toplevel capture, which requires another protocol. Additionally, not alot of existing wayland utilities support only the standardized protocol, both are typically supported. |
There was a problem hiding this comment.
I don't see why we need to keep the fd around. Once we map the region, we don't need it anymore, and nothing in your PR seems to use it either.
If you are worried about what happens to the map after the file descriptor is closed, note the following from the mmap spec:
The mmap() function shall add an extra reference to the file associated with the file descriptor fildes which is not removed by a subsequent close() on that file descriptor. This reference shall be removed when there are no more mappings to the file.
There was a problem hiding this comment.
Without it, screenshotting is an immediate segfault.
There was a problem hiding this comment.
I think you might be misdiagnosing the problem. I reverted the commit for testing and it still works.
There was a problem hiding this comment.
Oh. Yeah the allowing writing is the trick.
Currently segfaults after making a successful screenshot and trying to open the screenshot in an image viewer, and the screenshotting itself takes a few seconds, with the reason being unknown, copying the buffer seems to be instant, so something else is the cause.
To test, you can rebase with #84 or build the screenshotter from master - for this patch. To test, you may use grim.
I am aware of the formatting and the global object destruction being ignored, I will fix that upon a review that hopefully makes this actually work.