Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Decodetalkers
Copy link
Collaborator

@Decodetalkers Decodetalkers commented May 25, 2023

fix: #8


let frame_copy: libwayshot::FrameCopy = if args.is_present("slurp") {
let frame_copy: (Vec<libwayshot::FrameCopy>, Option<(i32, i32)>) = if args.is_present("slurp") {
let mut copies = Vec::new();
Copy link
Member

Choose a reason for hiding this comment

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

What does copies signify in this patch? Can we possibly try a better name?


if !(width <= 0 || height <= 0) {
intersecting_outputs.push(output);
let truex = region.x_coordinate - output.dimensions.x;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let truex = region.x_coordinate - output.dimensions.x;
let true_x = region.x_coordinate - output.dimensions.x;

if !(width <= 0 || height <= 0) {
intersecting_outputs.push(output);
let truex = region.x_coordinate - output.dimensions.x;
let truey = region.y_coordinate - output.dimensions.y;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let truey = region.y_coordinate - output.dimensions.y;
let true_y = region.y_coordinate - output.dimensions.y;

intersecting_outputs.push(output);
let truex = region.x_coordinate - output.dimensions.x;
let truey = region.y_coordinate - output.dimensions.y;
let trueregion = CaptureRegion {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let trueregion = CaptureRegion {
let true_region = CaptureRegion {

};
intersecting_outputs.push(MutiCaptureMessage {
output: output.wl_output.clone(),
region: trueregion,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
region: trueregion,
region: true_region,

&mut globals,
&mut conn,
cursor_overlay,
ouputinfos.output.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ouputinfos.output.clone(),
output_info.output.clone(),

&mut conn,
cursor_overlay,
ouputinfos.output.clone(),
Some(ouputinfos.region),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Some(ouputinfos.region),
Some(output_info.region),

&mut conn,
cursor_overlay,
output,
None,
Copy link
Member

Choose a reason for hiding this comment

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

Would it be efficient to capture the entire wl_output? Maybe we should consider passing in the intersecting region only.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you mean about entire wl_output? maybe combining all screens together to one image?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mstoekcl one just concat the screens, if you want to capture the whole region, just caculate the biggest region, from the min (x, y) to the max (x, y), make every screen capture once, resize and overlay the images together, then we get the whole screens image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

output,
None,
)?],
None,
Copy link
Member

Choose a reason for hiding this comment

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

Once again, maybe we should consider exporting the intersecting capture region and then blit the resulting output to the final buffer.

@Shinyzenith
Copy link
Member

For reference: https://github.com/mstoeckl/wayshot/tree/multi-output
The following patch also adds the same functionality. It is however from before the libwayshot split hence might be hard to follow along with but the logic remains untouched.

Shinyzenith
Shinyzenith previously approved these changes Jun 1, 2023
@Shinyzenith
Copy link
Member

Apart from some minor style issues ( which I will fix after merging ), the code seems to be fine. We can do a better job of abstracting some areas which I'll also take upon myself.

Waiting to merge before I can actually test the patch or have someone test it locally.

@mstoeckl
Copy link
Contributor

Waiting to merge before I can actually test the patch or have someone test it locally.

I finally had some time to look at and test this. (Inside sway, I ran WLR_WL_OUTPUTS=2 sway to create a two-output nested instance, and then made a number of screenshots, using commands like swaymsg output WL-2 scale 1.5 and swaymsg output WL-2 transform flipped-180 to change output scales and apply output transforms.)

I've only noticed one issue so far: transformed outputs are not properly handled; the screenshot buffers need to be untransformed and composited in the right location. However, transformed outputs also having rotated screenshot images may also be an issue with the original wayshot -- or possibly even the protocol https://wayland.app/protocols/wlr-screencopy-unstable-v1 itself, which does not appear to explain whether the buffers received are transformed. Either way, I still consider this PR to be a strict improvement.

@Shinyzenith
Copy link
Member

I finally had some time to look at and test this. (Inside sway, I ran WLR_WL_OUTPUTS=2 sway to create a two-output nested instance, and then made a number of screenshots, using commands like swaymsg output WL-2 scale 1.5 and swaymsg output WL-2 transform flipped-180 to change output scales and apply output transforms.)

Hey! Thanks once again for taking a look ❤️.

I've only noticed one issue so far: transformed outputs are not properly handled; the screenshot buffers need to be untransformed and composited in the right location. However, transformed outputs also having rotated screenshot images may also be an issue with the original wayshot -- or possibly even the protocol https://wayland.app/protocols/wlr-screencopy-unstable-v1 itself, which does not appear to explain whether the buffers received are transformed. Either way, I still consider this PR to be a strict improvement.

This makes me curious, does this issue occur on grim too? Would you mind testing it out? 😅 I sadly don't have access to anything apart from my laptop at the moment.

@mstoeckl
Copy link
Contributor

This makes me curious, does this issue occur on grim too? Would you mind testing it out?

It does not happen with grim. Under Sway, running swaymsg output '*' transform 180 to rotate the display, and capturing a screenshot with grim, produces an image which displays windows right-side-up; doing the same with Wayshot (either original, my test branch, or this PR) produces an image whose windows are upside-down.

@Decodetalkers
Copy link
Collaborator Author

Decodetalkers commented Jun 27, 2023

This makes me curious, does this issue occur on grim too? Would you mind testing it out?

It does not happen with grim. Under Sway, running swaymsg output '*' transform 180 to rotate the display, and capturing a screenshot with grim, produces an image which displays windows right-side-up; doing the same with Wayshot (either original, my test branch, or this PR) produces an image whose windows are upside-down.

I think we need to get the rotation of the screen, before make them one image, it need to rotate the image to the right place

https://docs.rs/wayland-client/0.30.2/wayland_client/protocol/wl_output/enum.Event.html#variant.Geometry.field.transform

Here, transfrom message need to collected

https://wayland.app/protocols/wayland#wl_output:enum:transform

introduction is here, but I do not know what is a good way to save them in OutputInfo, because they are all in wl_output. so ..

If transform is done, then before https://github.com/waycrate/wayshot/pull/40/files#diff-07c5f12242ede0fe1716dbe6393d6cd3a4eb49b4e440dbfed36a1e4bbc1e0651R266 this line, we need to rotate the image to the right place with the transform we get, then make them together, after that , I think all is done

so this pr just support when all screen is in normal translation

@Decodetalkers
Copy link
Collaborator Author

Decodetalkers commented Jun 27, 2023

I try to solve transform in my repo,

Decodetalkers/haruhishot@8bc7f4d

but there is still some problem , when rotate with 90 and 270, it cannot shot the right place, I need to see how grim handle it

it seems something wrong with capture_region, I think it is the bug of sway, because rotate 90 degree, capture region from 0, 0, 100, 100, it captures from 2400, 1000, -100, -100, and grim does not use capture_region. it capture all the screens, and caculate where to cut, finally makes an image

let mut buff = Cursor::new(Vec::new());

let mut writer = BufWriter::new(stdout.lock());
image_bottom.write_to(&mut buff, image::ImageFormat::Png)?;
Copy link
Member

Choose a reason for hiding this comment

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

I think I didn't notice this line, but should we not take the users defined extension format into consideration here instead of hardcoding png or am I mistaken? @Decodetalkers

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sorry, I have missed that

@Shinyzenith
Copy link
Member

it seems something wrong with capture_region, I think it is the bug of sway, because rotate 90 degree, capture region from 0, 0, 100, 100, it captures from 2400, 1000, -100, -100, and grim does not use capture_region. it capture all the screens, and caculate where to cut, finally makes an image

I see I'll try and test this theory.

@Shinyzenith
Copy link
Member

Shinyzenith commented Jun 27, 2023

introduction is here, but I do not know what is a good way to save them in OutputInfo, because they are all in wl_output. so ..

I think we can query the transform and keep it in a transform field in OutputInfo right?

@Shinyzenith
Copy link
Member

This makes me curious, does this issue occur on grim too? Would you mind testing it out?

It does not happen with grim. Under Sway, running swaymsg output '*' transform 180 to rotate the display, and capturing a screenshot with grim, produces an image which displays windows right-side-up; doing the same with Wayshot (either original, my test branch, or this PR) produces an image whose windows are upside-down.

I can reproduce this issue under swayfx.

Shinyzenith added a commit that referenced this pull request Jun 27, 2023
Closes: #7
Closes: #8
Supercedes: #40
Signed-off-by: Decodetalkers <[email protected]>
Signed-off-by: Shinyzenith <[email protected]>
Shinyzenith added a commit that referenced this pull request Jul 2, 2023
Closes: #7
Closes: #8
Supercedes: #40
Signed-off-by: Decodetalkers <[email protected]>
Signed-off-by: Shinyzenith <[email protected]>
@Shinyzenith
Copy link
Member

Completed in: #41

@Shinyzenith
Copy link
Member

Thank you for all your help and contributions ❤️

@Shinyzenith Shinyzenith closed this Jul 3, 2023
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.

Can't screenshot both screens

3 participants