Use Wayland subsurfaces, dmabuf screencopy

More efficient than shm screencopy, and rendering an iced image into the
window. Done right, should espeically help with multiple GPUs, but more
testing and work is needed there.

Removes mmapping of dmabuf, which errored... I guess not allocated with
right options for that. Relevant only if we want a fallback/test that
involves reading dmabufs.

Using `OnDamage` doesn't seem to work correctly currently. Likely a
compositor issue.
This commit is contained in:
Ian Douglas Scott 2023-11-08 16:59:29 -08:00
parent 1bfcd50383
commit 78b7bfe957
4 changed files with 79 additions and 50 deletions

View file

@ -20,7 +20,7 @@ use cctk::{
toplevel_management::ToplevelManagerState,
wayland_client::{
globals::registry_queue_init,
protocol::{wl_output, wl_seat},
protocol::{wl_buffer, wl_output, wl_seat},
Connection, QueueHandle,
},
workspace::WorkspaceState,
@ -30,6 +30,7 @@ use cosmic::iced::{
self,
futures::{executor::block_on, FutureExt, SinkExt},
};
use cosmic::iced_sctk::subsurface_widget::SubsurfaceBuffer;
use futures_channel::mpsc;
use std::{
cell::RefCell,
@ -83,7 +84,9 @@ pub enum Event {
#[derive(Clone, Debug)]
pub struct CaptureImage {
pub img: iced::widget::image::Handle,
pub width: u32,
pub height: u32,
pub wl_buffer: SubsurfaceBuffer,
}
pub fn subscription(conn: Connection) -> iced::Subscription<Event> {