Skip to content

WIP: Add support for wlr-screencopy-unstable#85

Open
sewnie wants to merge 5 commits into
michaelforney:masterfrom
sewnie:screencopy
Open

WIP: Add support for wlr-screencopy-unstable#85
sewnie wants to merge 5 commits into
michaelforney:masterfrom
sewnie:screencopy

Conversation

@sewnie

@sewnie sewnie commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

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.

sewnie added 5 commits March 14, 2026 13:04
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.
@sewnie

sewnie commented Mar 14, 2026

Copy link
Copy Markdown
Contributor Author

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.

Comment thread libswc/shm.c

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without it, screenshotting is an immediate segfault.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think you might be misdiagnosing the problem. I reverted the commit for testing and it still works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh. Yeah the allowing writing is the trick.

@sewnie sewnie mentioned this pull request Apr 27, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants