Apply screencopy transform to subsurfaces
Fixes https://github.com/pop-os/cosmic-workspaces-epoch/issues/17.
This commit is contained in:
parent
8c4e66691c
commit
764b4ae5f8
4 changed files with 12 additions and 3 deletions
|
|
@ -60,6 +60,7 @@ fn create_solid_capture_image(r: u8, g: u8, b: u8) -> CaptureImage {
|
||||||
.into(),
|
.into(),
|
||||||
))
|
))
|
||||||
.0,
|
.0,
|
||||||
|
transform: wl_output::Transform::Normal,
|
||||||
#[cfg(feature = "no-subsurfaces")]
|
#[cfg(feature = "no-subsurfaces")]
|
||||||
image: cosmic::widget::image::Handle::from_rgba(512, 512, [r, g, b, 255].repeat(512 * 512)),
|
image: cosmic::widget::image::Handle::from_rgba(512, 512, [r, g, b, 255].repeat(512 * 512)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ pub struct CaptureImage {
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
pub wl_buffer: SubsurfaceBuffer,
|
pub wl_buffer: SubsurfaceBuffer,
|
||||||
|
pub transform: wl_output::Transform,
|
||||||
#[cfg(feature = "no-subsurfaces")]
|
#[cfg(feature = "no-subsurfaces")]
|
||||||
pub image: cosmic::widget::image::Handle,
|
pub image: cosmic::widget::image::Handle,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ impl ScreencopyHandler for AppData {
|
||||||
conn: &Connection,
|
conn: &Connection,
|
||||||
qh: &QueueHandle<Self>,
|
qh: &QueueHandle<Self>,
|
||||||
screencopy_frame: &zcosmic_screencopy_frame_v2::ZcosmicScreencopyFrameV2,
|
screencopy_frame: &zcosmic_screencopy_frame_v2::ZcosmicScreencopyFrameV2,
|
||||||
_frame: Frame,
|
frame: Frame,
|
||||||
) {
|
) {
|
||||||
let session = &screencopy_frame.data::<FrameData>().unwrap().session;
|
let session = &screencopy_frame.data::<FrameData>().unwrap().session;
|
||||||
let Some(capture) = Capture::for_session(session) else {
|
let Some(capture) = Capture::for_session(session) else {
|
||||||
|
|
@ -207,6 +207,10 @@ impl ScreencopyHandler for AppData {
|
||||||
wl_buffer: buffer,
|
wl_buffer: buffer,
|
||||||
width: front.size.0,
|
width: front.size.0,
|
||||||
height: front.size.1,
|
height: front.size.1,
|
||||||
|
transform: match frame.transform {
|
||||||
|
WEnum::Value(value) => value,
|
||||||
|
WEnum::Unknown(value) => panic!("invalid capture transform: {}", value),
|
||||||
|
},
|
||||||
#[cfg(feature = "no-subsurfaces")]
|
#[cfg(feature = "no-subsurfaces")]
|
||||||
image: cosmic::widget::image::Handle::from_rgba(
|
image: cosmic::widget::image::Handle::from_rgba(
|
||||||
front.size.0,
|
front.size.0,
|
||||||
|
|
|
||||||
|
|
@ -423,12 +423,15 @@ fn capture_image(image: Option<&CaptureImage>, alpha: f32) -> cosmic::Element<'s
|
||||||
if let Some(image) = image {
|
if let Some(image) = image {
|
||||||
#[cfg(feature = "no-subsurfaces")]
|
#[cfg(feature = "no-subsurfaces")]
|
||||||
{
|
{
|
||||||
// TODO alpha
|
// TODO alpha, transform
|
||||||
widget::Image::new(image.image.clone()).into()
|
widget::Image::new(image.image.clone()).into()
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "no-subsurfaces"))]
|
#[cfg(not(feature = "no-subsurfaces"))]
|
||||||
{
|
{
|
||||||
Subsurface::new(image.wl_buffer.clone()).alpha(alpha).into()
|
Subsurface::new(image.wl_buffer.clone())
|
||||||
|
.alpha(alpha)
|
||||||
|
.transform(image.transform)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
widget::Image::new(widget::image::Handle::from_rgba(1, 1, vec![0, 0, 0, 255])).into()
|
widget::Image::new(widget::image::Handle::from_rgba(1, 1, vec![0, 0, 0, 255])).into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue