Unable to copy to buffer using ZwlrScreencopyFrameV1
laycookie opened this issue · 1 comments
Hello, my assumption is that this is just my misunderstanding of how ZwlrScreencopyFrameV1.copy works as the documentation on it is pretty limited.
The documentation make it seem that if I want to get the image to display I need to use ZwlrScreencopyFrameV1.copy(buffer);
which will copy the screen data to WlBuffer which will result into my screen appearing in the window.
This puts me under the assumption that if I write this code it will act as follows.
frame.copy(&buffer); // copies the frame to the buffer
surrface.attach(Some(&buffer), 0, 0); // Attaches the buffer to the surface
surface.commit(); // Commits the change which results into the screen being shown
However this is not the case and I'm not exactly sure how would I debug this issue. I have attempted to read the contents of the file which stores the WlBuffer data however it returns me a bunch of zeros (The files isn't empty as the size was set to the accumulative amount of pixels on all of the displays.)
P.S. The copy process does not fail as I do receive Flag, and Ready events.
If you call surface.attach(Some(&buffer), 0, 0)
immediately after frame.copy(&buffer)
, there's no guarantee what buffer contents will be committed to the surface. The commit might happen before the frame.copy
is complete.
You should call frame.copy
, and then not access the contents of the buffer until you get a ready
event. Then you can try reading it or attaching it to a surface.