autocommit 2022-04-28 19:49:51 CEST
This commit is contained in:
parent
bd63f3f5f1
commit
1242a6c1e1
31 changed files with 707 additions and 64 deletions
|
|
@ -85,6 +85,10 @@ pub enum MetalError {
|
|||
Framebuffer(#[source] DrmError),
|
||||
#[error("Could not import a framebuffer into EGL")]
|
||||
ImportFb(#[source] RenderError),
|
||||
#[error("Could not import a texture into EGL")]
|
||||
ImportTexture(#[source] RenderError),
|
||||
#[error("Could not import an image into EGL")]
|
||||
ImportImage(#[source] RenderError),
|
||||
#[error("Could not perform modeset")]
|
||||
Modeset(#[source] DrmError),
|
||||
#[error("Could not enable atomic modesetting")]
|
||||
|
|
|
|||
|
|
@ -7,9 +7,13 @@ use {
|
|||
backends::metal::{DrmId, MetalBackend, MetalError},
|
||||
edid::Descriptor,
|
||||
format::{Format, XRGB8888},
|
||||
ifs::wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC},
|
||||
render::{Framebuffer, RenderContext, RenderResult},
|
||||
ifs::{
|
||||
wl_buffer::WlBufferStorage,
|
||||
wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC},
|
||||
},
|
||||
render::{Framebuffer, RenderContext, RenderResult, Texture},
|
||||
state::State,
|
||||
time::Time,
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, bitflags::BitflagsExt, clonecell::CloneCell,
|
||||
debug_fn::debug_fn, errorfmt::ErrorFmt, numcell::NumCell, oserror::OsError,
|
||||
|
|
@ -33,6 +37,7 @@ use {
|
|||
cell::{Cell, RefCell},
|
||||
ffi::CString,
|
||||
fmt::{Debug, Formatter},
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
},
|
||||
uapi::c,
|
||||
|
|
@ -183,7 +188,7 @@ impl MetalConnector {
|
|||
let buffer = &buffers[self.next_buffer.fetch_add(1) % buffers.len()];
|
||||
if let Some(node) = self.state.root.outputs.get(&self.connector_id) {
|
||||
let mut rr = self.render_result.borrow_mut();
|
||||
buffer.egl.render(
|
||||
buffer.fb.render(
|
||||
&*node,
|
||||
&self.state,
|
||||
Some(node.global.pos.get()),
|
||||
|
|
@ -194,6 +199,64 @@ impl MetalConnector {
|
|||
fr.send_done();
|
||||
let _ = fr.client.remove_obj(&*fr);
|
||||
}
|
||||
if !node.global.pending_captures.is_empty() {
|
||||
let now = Time::now().unwrap();
|
||||
let mut captures = vec![];
|
||||
for capture in node.global.pending_captures.iter() {
|
||||
captures.push(capture.deref().clone());
|
||||
let wl_buffer = match capture.buffer.take() {
|
||||
Some(b) => b,
|
||||
_ => {
|
||||
log::warn!("Capture frame is pending but has no buffer attached");
|
||||
capture.send_failed();
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if wl_buffer.destroyed() {
|
||||
capture.send_failed();
|
||||
continue;
|
||||
}
|
||||
let rect = capture.rect;
|
||||
if let WlBufferStorage::Shm { mem, .. } = &wl_buffer.storage {
|
||||
let res = mem.access(|mem| {
|
||||
buffer.fb.copy_to_shm(
|
||||
rect.x1(),
|
||||
rect.y1(),
|
||||
rect.width(),
|
||||
rect.height(),
|
||||
XRGB8888,
|
||||
mem,
|
||||
);
|
||||
});
|
||||
if let Err(e) = res {
|
||||
capture.client.error(e);
|
||||
}
|
||||
// capture.send_flags(FLAGS_Y_INVERT);
|
||||
} else {
|
||||
let fb = match wl_buffer.famebuffer.get() {
|
||||
Some(fb) => fb,
|
||||
_ => {
|
||||
log::warn!("Capture buffer has no framebuffer");
|
||||
capture.send_failed();
|
||||
continue;
|
||||
}
|
||||
};
|
||||
fb.copy_texture(
|
||||
&self.state,
|
||||
&buffer.tex,
|
||||
-capture.rect.x1(),
|
||||
-capture.rect.y1(),
|
||||
);
|
||||
}
|
||||
if capture.with_damage.get() {
|
||||
capture.send_damage();
|
||||
}
|
||||
capture.send_ready(now.0.tv_sec as _, now.0.tv_nsec as _);
|
||||
}
|
||||
for capture in captures {
|
||||
capture.output_link.take();
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut changes = self.master.change();
|
||||
changes.change_object(plane.id, |c| {
|
||||
|
|
@ -1025,14 +1088,23 @@ impl MetalBackend {
|
|||
Ok(fb) => Rc::new(fb),
|
||||
Err(e) => return Err(MetalError::Framebuffer(e)),
|
||||
};
|
||||
let egl_fb = match dev.dev.egl.dmabuf_fb(bo.dmabuf()) {
|
||||
let egl_img = match dev.dev.egl.dmabuf_img(bo.dmabuf()) {
|
||||
Ok(img) => img,
|
||||
Err(e) => return Err(MetalError::ImportImage(e)),
|
||||
};
|
||||
let egl_fb = match egl_img.to_framebuffer() {
|
||||
Ok(fb) => fb,
|
||||
Err(e) => return Err(MetalError::ImportFb(e)),
|
||||
};
|
||||
let egl_tex = match egl_img.to_texture() {
|
||||
Ok(fb) => fb,
|
||||
Err(e) => return Err(MetalError::ImportTexture(e)),
|
||||
};
|
||||
egl_fb.clear();
|
||||
Ok(RenderBuffer {
|
||||
drm: drm_fb,
|
||||
egl: egl_fb,
|
||||
fb: egl_fb,
|
||||
tex: egl_tex,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -1158,7 +1230,8 @@ impl MetalBackend {
|
|||
#[derive(Debug)]
|
||||
pub struct RenderBuffer {
|
||||
drm: Rc<DrmFramebuffer>,
|
||||
egl: Rc<Framebuffer>,
|
||||
fb: Rc<Framebuffer>,
|
||||
tex: Rc<Texture>,
|
||||
}
|
||||
|
||||
fn modes_equal(a: &DrmModeInfo, b: &DrmModeInfo) -> bool {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use {
|
|||
wp_presentation::WpPresentationGlobal,
|
||||
xdg_wm_base::XdgWmBaseGlobal,
|
||||
zwlr_layer_shell_v1::ZwlrLayerShellV1Global,
|
||||
zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1Global,
|
||||
zwp_idle_inhibit_manager_v1::ZwpIdleInhibitManagerV1Global,
|
||||
zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1Global,
|
||||
zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Global,
|
||||
|
|
@ -132,6 +133,7 @@ impl Globals {
|
|||
add_singleton!(ZwlrLayerShellV1Global);
|
||||
add_singleton!(ZxdgOutputManagerV1Global);
|
||||
add_singleton!(JayCompositorGlobal);
|
||||
add_singleton!(ZwlrScreencopyManagerV1Global);
|
||||
|
||||
if backend.supports_idle() {
|
||||
add_singleton!(ZwpIdleInhibitManagerV1Global);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ pub mod wp_presentation_feedback;
|
|||
pub mod xdg_positioner;
|
||||
pub mod xdg_wm_base;
|
||||
pub mod zwlr_layer_shell_v1;
|
||||
pub mod zwlr_screencopy_frame_v1;
|
||||
pub mod zwlr_screencopy_manager_v1;
|
||||
pub mod zwp_idle_inhibit_manager_v1;
|
||||
pub mod zwp_linux_buffer_params_v1;
|
||||
pub mod zwp_linux_dmabuf_v1;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,10 @@ impl WlDataDeviceManagerGlobal {
|
|||
}
|
||||
|
||||
impl WlDataDeviceManager {
|
||||
fn create_data_source(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceManagerError> {
|
||||
fn create_data_source(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDataDeviceManagerError> {
|
||||
let req: CreateDataSource = self.client.parse(self, parser)?;
|
||||
let res = Rc::new(WlDataSource::new(req.id, &self.client));
|
||||
track!(self.client, res);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,10 @@ impl ZwpPrimarySelectionDeviceManagerV1Global {
|
|||
}
|
||||
|
||||
impl ZwpPrimarySelectionDeviceManagerV1 {
|
||||
fn create_source(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
fn create_source(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let req: CreateSource = self.client.parse(self, parser)?;
|
||||
let res = Rc::new(ZwpPrimarySelectionSourceV1::new(req.id, &self.client));
|
||||
track!(self.client, res);
|
||||
|
|
@ -58,7 +61,10 @@ impl ZwpPrimarySelectionDeviceManagerV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_data_device(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
fn get_data_device(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let req: GetDevice = self.client.parse(&**self, parser)?;
|
||||
let seat = self.client.lookup(req.seat)?;
|
||||
let dev = Rc::new(ZwpPrimarySelectionDeviceV1::new(req.id, self, &seat));
|
||||
|
|
@ -68,7 +74,10 @@ impl ZwpPrimarySelectionDeviceManagerV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
fn destroy(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -61,7 +61,10 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
})
|
||||
}
|
||||
|
||||
fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceV1Error> {
|
||||
fn set_selection(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceV1Error> {
|
||||
let req: SetSelection = self.manager.client.parse(self, parser)?;
|
||||
if !self.manager.client.valid_serial(req.serial) {
|
||||
log::warn!("Client tried to set_selection with an invalid serial");
|
||||
|
|
|
|||
|
|
@ -46,7 +46,10 @@ impl OrgKdeKwinServerDecoration {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn request_mode(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), OrgKdeKwinServerDecorationError> {
|
||||
fn request_mode(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), OrgKdeKwinServerDecorationError> {
|
||||
let req: RequestMode = self.client.parse(&**self, parser)?;
|
||||
if req.mode > SERVER {
|
||||
return Err(OrgKdeKwinServerDecorationError::InvalidMode(req.mode));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ use {
|
|||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecoration,
|
||||
ifs::org_kde_kwin_server_decoration::{
|
||||
OrgKdeKwinServerDecoration, OrgKdeKwinServerDecorationError,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
|
|
@ -11,7 +13,6 @@ use {
|
|||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
use crate::ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecorationError;
|
||||
|
||||
#[allow(dead_code)]
|
||||
const NONE: u32 = 0;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
render::{Image, RenderError, Texture},
|
||||
render::{Framebuffer, Image, RenderError, Texture},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
|
|
@ -28,8 +28,9 @@ pub struct WlBuffer {
|
|||
pub client: Rc<Client>,
|
||||
pub rect: Rect,
|
||||
pub format: &'static Format,
|
||||
storage: WlBufferStorage,
|
||||
pub storage: WlBufferStorage,
|
||||
pub texture: CloneCell<Option<Rc<Texture>>>,
|
||||
pub famebuffer: CloneCell<Option<Rc<Framebuffer>>>,
|
||||
width: i32,
|
||||
height: i32,
|
||||
pub tracker: Tracker<Self>,
|
||||
|
|
@ -58,6 +59,7 @@ impl WlBuffer {
|
|||
width,
|
||||
height,
|
||||
texture: CloneCell::new(None),
|
||||
famebuffer: Default::default(),
|
||||
storage: WlBufferStorage::Dmabuf(img.clone()),
|
||||
tracker: Default::default(),
|
||||
}
|
||||
|
|
@ -95,6 +97,7 @@ impl WlBuffer {
|
|||
height,
|
||||
texture: CloneCell::new(None),
|
||||
tracker: Default::default(),
|
||||
famebuffer: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +121,20 @@ impl WlBuffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_framebuffer(&self) -> Result<(), WlBufferError> {
|
||||
match &self.storage {
|
||||
WlBufferStorage::Shm { .. } => {
|
||||
// nothing
|
||||
}
|
||||
WlBufferStorage::Dmabuf(img) => {
|
||||
if self.famebuffer.get().is_none() {
|
||||
self.famebuffer.set(Some(img.to_framebuffer()?));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlBufferError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
|
|
|
|||
|
|
@ -102,18 +102,12 @@ impl WlDrm {
|
|||
Err(WlDrmError::Unsupported)
|
||||
}
|
||||
|
||||
fn create_planar_buffer(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDrmError> {
|
||||
fn create_planar_buffer(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), WlDrmError> {
|
||||
let _req: CreatePlanarBuffer = self.client.parse(&**self, parser)?;
|
||||
Err(WlDrmError::Unsupported)
|
||||
}
|
||||
|
||||
fn create_prime_buffer(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDrmError> {
|
||||
fn create_prime_buffer(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), WlDrmError> {
|
||||
let req: CreatePrimeBuffer = self.client.parse(&**self, parser)?;
|
||||
let ctx = match self.client.state.render_ctx.get() {
|
||||
Some(ctx) => ctx,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use {
|
|||
backend,
|
||||
client::{Client, ClientError, ClientId},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::zxdg_output_v1::ZxdgOutputV1,
|
||||
ifs::{zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1, zxdg_output_v1::ZxdgOutputV1},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
|
|
@ -13,6 +13,7 @@ use {
|
|||
buffd::{MsgParser, MsgParserError},
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
linkedlist::LinkedList,
|
||||
},
|
||||
wire::{wl_output::*, WlOutputId, ZxdgOutputV1Id},
|
||||
},
|
||||
|
|
@ -68,6 +69,8 @@ pub struct WlOutputGlobal {
|
|||
pub width_mm: i32,
|
||||
pub height_mm: i32,
|
||||
pub bindings: RefCell<AHashMap<ClientId, AHashMap<WlOutputId, Rc<WlOutput>>>>,
|
||||
pub unused_captures: LinkedList<Rc<ZwlrScreencopyFrameV1>>,
|
||||
pub pending_captures: LinkedList<Rc<ZwlrScreencopyFrameV1>>,
|
||||
}
|
||||
|
||||
impl WlOutputGlobal {
|
||||
|
|
@ -92,6 +95,8 @@ impl WlOutputGlobal {
|
|||
width_mm,
|
||||
height_mm,
|
||||
bindings: Default::default(),
|
||||
unused_captures: Default::default(),
|
||||
pending_captures: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,16 @@ use {
|
|||
ifs::wl_seat::WlSeat,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
oserror::OsError,
|
||||
},
|
||||
wire::{wl_keyboard::*, WlKeyboardId, WlSurfaceId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
use crate::utils::oserror::OsError;
|
||||
|
||||
pub const REPEAT_INFO_SINCE: u32 = 4;
|
||||
|
||||
|
|
|
|||
|
|
@ -539,10 +539,7 @@ impl WlSurface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_buffer_transform(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlSurfaceError> {
|
||||
fn set_buffer_transform(&self, parser: MsgParser<'_, '_>) -> Result<(), WlSurfaceError> {
|
||||
let _req: SetBufferTransform = self.parse(parser)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,10 +283,7 @@ impl XdgToplevel {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_fullscreen(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgToplevelError> {
|
||||
fn set_fullscreen(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgToplevelError> {
|
||||
let client = &self.xdg.surface.client;
|
||||
let req: SetFullscreen = client.parse(self.deref(), parser)?;
|
||||
self.states.borrow_mut().insert(STATE_FULLSCREEN);
|
||||
|
|
|
|||
|
|
@ -221,11 +221,7 @@ impl XdgPositioner {
|
|||
let req: SetConstraintAdjustment = self.client.parse(self, parser)?;
|
||||
let ca = match CA::from_bits(req.constraint_adjustment) {
|
||||
Some(c) => c,
|
||||
_ => {
|
||||
return Err(XdgPositionerError::UnknownCa(
|
||||
req.constraint_adjustment,
|
||||
))
|
||||
}
|
||||
_ => return Err(XdgPositionerError::UnknownCa(req.constraint_adjustment)),
|
||||
};
|
||||
self.position.borrow_mut().ca = ca;
|
||||
Ok(())
|
||||
|
|
@ -261,10 +257,7 @@ impl XdgPositioner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_parent_configure(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgPositionerError> {
|
||||
fn set_parent_configure(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgPositionerError> {
|
||||
let req: SetParentConfigure = self.client.parse(self, parser)?;
|
||||
self.position.borrow_mut().parent_serial = req.serial;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -84,10 +84,7 @@ impl XdgWmBase {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn create_positioner(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgWmBaseError> {
|
||||
fn create_positioner(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgWmBaseError> {
|
||||
let req: CreatePositioner = self.client.parse(&**self, parser)?;
|
||||
let pos = Rc::new(XdgPositioner::new(self, req.id, &self.client));
|
||||
track!(self.client, pos);
|
||||
|
|
@ -95,10 +92,7 @@ impl XdgWmBase {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_xdg_surface(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), XdgWmBaseError> {
|
||||
fn get_xdg_surface(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgWmBaseError> {
|
||||
let req: GetXdgSurface = self.client.parse(&**self, parser)?;
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let xdg_surface = Rc::new(XdgSurface::new(self, req.id, &surface));
|
||||
|
|
|
|||
196
src/ifs/zwlr_screencopy_frame_v1.rs
Normal file
196
src/ifs/zwlr_screencopy_frame_v1.rs
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
format::XRGB8888,
|
||||
ifs::{
|
||||
wl_buffer::{WlBuffer, WlBufferError, WlBufferStorage},
|
||||
wl_output::WlOutputGlobal,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
utils::{
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
linkedlist::LinkedNode,
|
||||
},
|
||||
wire::{zwlr_screencopy_frame_v1::*, WlBufferId, ZwlrScreencopyFrameV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub const FLAGS_Y_INVERT: u32 = 1;
|
||||
|
||||
pub struct ZwlrScreencopyFrameV1 {
|
||||
pub id: ZwlrScreencopyFrameV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub output: Rc<WlOutputGlobal>,
|
||||
pub rect: Rect,
|
||||
pub overlay_cursor: bool,
|
||||
pub used: Cell<bool>,
|
||||
pub with_damage: Cell<bool>,
|
||||
pub output_link: Cell<Option<LinkedNode<Rc<Self>>>>,
|
||||
pub buffer: Cell<Option<Rc<WlBuffer>>>,
|
||||
pub version: u32,
|
||||
}
|
||||
|
||||
impl ZwlrScreencopyFrameV1 {
|
||||
pub fn send_ready(&self, tv_sec: u64, tv_nsec: u32) {
|
||||
self.client.event(Ready {
|
||||
self_id: self.id,
|
||||
tv_sec_hi: (tv_sec >> 32) as u32,
|
||||
tv_sec_lo: tv_sec as u32,
|
||||
tv_nsec,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn send_failed(&self) {
|
||||
self.client.event(Failed { self_id: self.id });
|
||||
}
|
||||
|
||||
pub fn send_damage(&self) {
|
||||
self.client.event(Damage {
|
||||
self_id: self.id,
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: self.rect.width() as _,
|
||||
height: self.rect.height() as _,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn send_buffer(&self) {
|
||||
self.client.event(Buffer {
|
||||
self_id: self.id,
|
||||
format: XRGB8888.wl_id.unwrap(),
|
||||
width: self.rect.width() as _,
|
||||
height: self.rect.height() as _,
|
||||
stride: self.rect.width() as u32 * 4, // TODO
|
||||
});
|
||||
}
|
||||
|
||||
pub fn send_linux_dmabuf(&self) {
|
||||
self.client.event(LinuxDmabuf {
|
||||
self_id: self.id,
|
||||
format: XRGB8888.drm,
|
||||
width: self.rect.width() as _,
|
||||
height: self.rect.height() as _,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn send_buffer_done(&self) {
|
||||
self.client.event(BufferDone { self_id: self.id })
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn send_flags(&self, flags: u32) {
|
||||
self.client.event(Flags {
|
||||
self_id: self.id,
|
||||
flags,
|
||||
})
|
||||
}
|
||||
|
||||
fn do_copy(
|
||||
&self,
|
||||
buffer_id: WlBufferId,
|
||||
with_damage: bool,
|
||||
) -> Result<(), ZwlrScreencopyFrameV1Error> {
|
||||
if self.used.replace(true) {
|
||||
return Err(ZwlrScreencopyFrameV1Error::AlreadyUsed);
|
||||
}
|
||||
let link = match self.output_link.take() {
|
||||
Some(l) => l,
|
||||
_ => {
|
||||
self.send_failed();
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
let buffer = self.client.lookup(buffer_id)?;
|
||||
if (buffer.rect.width(), buffer.rect.height()) != (self.rect.width(), self.rect.height()) {
|
||||
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferSize);
|
||||
}
|
||||
if buffer.format != XRGB8888 {
|
||||
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferFormat);
|
||||
}
|
||||
buffer.update_framebuffer()?;
|
||||
if let WlBufferStorage::Shm { stride, .. } = &buffer.storage {
|
||||
if *stride != self.rect.width() * 4 {
|
||||
return Err(ZwlrScreencopyFrameV1Error::InvalidBufferStride);
|
||||
}
|
||||
}
|
||||
self.buffer.set(Some(buffer));
|
||||
if !with_damage {
|
||||
self.output.connector.connector.damage();
|
||||
}
|
||||
self.with_damage.set(with_damage);
|
||||
self.output.pending_captures.add_last_existing(&link);
|
||||
self.output_link.set(Some(link));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn copy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrScreencopyFrameV1Error> {
|
||||
let req: Copy = self.client.parse(self, parser)?;
|
||||
self.do_copy(req.buffer, false)
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrScreencopyFrameV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
self.output_link.take();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn copy_with_damage(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwlrScreencopyFrameV1Error> {
|
||||
let req: CopyWithDamage = self.client.parse(self, parser)?;
|
||||
self.do_copy(req.buffer, true)
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
ZwlrScreencopyFrameV1;
|
||||
|
||||
COPY => copy,
|
||||
DESTROY => destroy,
|
||||
COPY_WITH_DAMAGE => copy_with_damage,
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwlrScreencopyFrameV1);
|
||||
|
||||
impl Object for ZwlrScreencopyFrameV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
if self.version >= 2 {
|
||||
COPY_WITH_DAMAGE + 1
|
||||
} else {
|
||||
DESTROY + 1
|
||||
}
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.output_link.take();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwlrScreencopyFrameV1Error {
|
||||
#[error("This frame has already been used")]
|
||||
AlreadyUsed,
|
||||
#[error("The buffer has an invalid size for the frame")]
|
||||
InvalidBufferSize,
|
||||
#[error("The buffer has an invalid stride for the frame")]
|
||||
InvalidBufferStride,
|
||||
#[error("The buffer has an invalid format")]
|
||||
InvalidBufferFormat,
|
||||
#[error(transparent)]
|
||||
WlBufferError(Box<WlBufferError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
MsgParserError(Box<MsgParserError>),
|
||||
}
|
||||
efrom!(ZwlrScreencopyFrameV1Error, WlBufferError);
|
||||
efrom!(ZwlrScreencopyFrameV1Error, ClientError);
|
||||
efrom!(ZwlrScreencopyFrameV1Error, MsgParserError);
|
||||
163
src/ifs/zwlr_screencopy_manager_v1.rs
Normal file
163
src/ifs/zwlr_screencopy_manager_v1.rs
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
rect::Rect,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{
|
||||
zwlr_screencopy_manager_v1::*, WlOutputId, ZwlrScreencopyFrameV1Id,
|
||||
ZwlrScreencopyManagerV1Id,
|
||||
},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct ZwlrScreencopyManagerV1Global {
|
||||
pub name: GlobalName,
|
||||
}
|
||||
|
||||
impl ZwlrScreencopyManagerV1Global {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: ZwlrScreencopyManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), ZwlrScreencopyManagerV1Error> {
|
||||
let mgr = Rc::new(ZwlrScreencopyManagerV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
});
|
||||
track!(client, mgr);
|
||||
client.add_client_obj(&mgr)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(
|
||||
ZwlrScreencopyManagerV1Global,
|
||||
ZwlrScreencopyManagerV1,
|
||||
ZwlrScreencopyManagerV1Error
|
||||
);
|
||||
|
||||
simple_add_global!(ZwlrScreencopyManagerV1Global);
|
||||
|
||||
impl Global for ZwlrScreencopyManagerV1Global {
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
3
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ZwlrScreencopyManagerV1 {
|
||||
pub id: ZwlrScreencopyManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: u32,
|
||||
}
|
||||
|
||||
impl ZwlrScreencopyManagerV1 {
|
||||
fn capture_output(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwlrScreencopyManagerV1Error> {
|
||||
let req: CaptureOutput = self.client.parse(self, parser)?;
|
||||
self.do_capture_output(req.output, req.overlay_cursor != 0, req.frame, None)
|
||||
}
|
||||
|
||||
fn capture_output_region(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwlrScreencopyManagerV1Error> {
|
||||
let req: CaptureOutputRegion = self.client.parse(self, parser)?;
|
||||
let region = match Rect::new_sized(req.x, req.y, req.width, req.height) {
|
||||
Some(r) => r,
|
||||
_ => return Err(ZwlrScreencopyManagerV1Error::InvalidRegion),
|
||||
};
|
||||
self.do_capture_output(req.output, req.overlay_cursor != 0, req.frame, Some(region))
|
||||
}
|
||||
|
||||
fn do_capture_output(
|
||||
&self,
|
||||
output: WlOutputId,
|
||||
overlay_cursor: bool,
|
||||
frame: ZwlrScreencopyFrameV1Id,
|
||||
region: Option<Rect>,
|
||||
) -> Result<(), ZwlrScreencopyManagerV1Error> {
|
||||
let output = self.client.lookup(output)?;
|
||||
let mut rect = output.global.position().at_point(0, 0);
|
||||
if let Some(region) = region {
|
||||
rect = rect.intersect(region);
|
||||
}
|
||||
let frame = Rc::new(ZwlrScreencopyFrameV1 {
|
||||
id: frame,
|
||||
client: self.client.clone(),
|
||||
tracker: Default::default(),
|
||||
output: output.global.clone(),
|
||||
rect,
|
||||
overlay_cursor,
|
||||
used: Cell::new(false),
|
||||
with_damage: Cell::new(false),
|
||||
output_link: Cell::new(None),
|
||||
buffer: Cell::new(None),
|
||||
version: self.version,
|
||||
});
|
||||
track!(self.client, frame);
|
||||
self.client.add_client_obj(&frame)?;
|
||||
frame.send_buffer();
|
||||
if self.version >= 3 {
|
||||
frame.send_linux_dmabuf();
|
||||
frame.send_buffer_done();
|
||||
}
|
||||
frame
|
||||
.output_link
|
||||
.set(Some(output.global.unused_captures.add_last(frame.clone())));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrScreencopyManagerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
ZwlrScreencopyManagerV1;
|
||||
|
||||
CAPTURE_OUTPUT => capture_output,
|
||||
CAPTURE_OUTPUT_REGION => capture_output_region,
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for ZwlrScreencopyManagerV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwlrScreencopyManagerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwlrScreencopyManagerV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error("The passed region is invalid")]
|
||||
InvalidRegion,
|
||||
}
|
||||
efrom!(ZwlrScreencopyManagerV1Error, ClientError);
|
||||
efrom!(ZwlrScreencopyManagerV1Error, MsgParserError);
|
||||
|
|
@ -61,7 +61,10 @@ impl ZwpLinuxBufferParamsV1 {
|
|||
self.parent.client.event(Failed { self_id: self.id })
|
||||
}
|
||||
|
||||
fn destroy(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), ZwpLinuxBufferParamsV1Error> {
|
||||
fn destroy(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpLinuxBufferParamsV1Error> {
|
||||
let _req: Destroy = self.parent.client.parse(&**self, parser)?;
|
||||
self.parent.client.remove_obj(&**self)?;
|
||||
Ok(())
|
||||
|
|
@ -71,7 +74,9 @@ impl ZwpLinuxBufferParamsV1 {
|
|||
let req: Add = self.parent.client.parse(&**self, parser)?;
|
||||
let modifier = ((req.modifier_hi as u64) << 32) | req.modifier_lo as u64;
|
||||
match self.modifier.get() {
|
||||
Some(m) if m != modifier => return Err(ZwpLinuxBufferParamsV1Error::MixedModifiers(modifier, m)),
|
||||
Some(m) if m != modifier => {
|
||||
return Err(ZwpLinuxBufferParamsV1Error::MixedModifiers(modifier, m))
|
||||
}
|
||||
_ => self.modifier.set(Some(modifier)),
|
||||
}
|
||||
let plane = req.plane_idx;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,10 @@ impl ZwpLinuxDmabufV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn create_params(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), ZwpLinuxDmabufV1Error> {
|
||||
fn create_params(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpLinuxDmabufV1Error> {
|
||||
let req: CreateParams = self.client.parse(&**self, parser)?;
|
||||
let params = Rc::new(ZwpLinuxBufferParamsV1::new(req.params_id, self));
|
||||
track!(self.client, params);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ impl ZxdgOutputManagerV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_xdg_output(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), ZxdgOutputManagerV1Error> {
|
||||
fn get_xdg_output(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZxdgOutputManagerV1Error> {
|
||||
let req: GetXdgOutput = self.client.parse(&**self, parser)?;
|
||||
let output = self.client.lookup(req.output)?;
|
||||
let xdg_output = Rc::new(ZxdgOutputV1 {
|
||||
|
|
|
|||
|
|
@ -67,8 +67,10 @@ impl ZxdgOutputV1 {
|
|||
if self.version >= NAME_SINCE {
|
||||
self.send_name(&self.output.global.connector.name);
|
||||
}
|
||||
if self.version >= NO_DONE_SINCE && self.output.version >= SEND_DONE_SINCE {
|
||||
self.output.send_done();
|
||||
if self.version >= NO_DONE_SINCE {
|
||||
if self.output.version >= SEND_DONE_SINCE {
|
||||
self.output.send_done();
|
||||
}
|
||||
} else {
|
||||
self.send_done();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,13 +57,19 @@ impl ZxdgToplevelDecorationV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_mode(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), ZxdgToplevelDecorationV1Error> {
|
||||
fn set_mode(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZxdgToplevelDecorationV1Error> {
|
||||
let _req: SetMode = self.client.parse(&**self, parser)?;
|
||||
self.do_send_configure();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unset_mode(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), ZxdgToplevelDecorationV1Error> {
|
||||
fn unset_mode(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZxdgToplevelDecorationV1Error> {
|
||||
let _req: UnsetMode = self.client.parse(&**self, parser)?;
|
||||
self.do_send_configure();
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -74,6 +74,17 @@ extern "C" {
|
|||
#[allow(dead_code)]
|
||||
pub fn glFlush();
|
||||
|
||||
pub fn glReadnPixels(
|
||||
x: GLint,
|
||||
y: GLint,
|
||||
width: GLsizei,
|
||||
height: GLsizei,
|
||||
format: GLenum,
|
||||
ty: GLenum,
|
||||
buf_size: GLsizei,
|
||||
data: *mut c::c_void,
|
||||
);
|
||||
|
||||
pub fn glGenTextures(n: GLsizei, textures: *mut GLuint);
|
||||
pub fn glDeleteTextures(n: GLsizei, textures: *const GLuint);
|
||||
pub fn glBindTexture(target: GLenum, texture: GLuint);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
format::{Format, XRGB8888},
|
||||
rect::Rect,
|
||||
render::{
|
||||
gl::{
|
||||
|
|
@ -10,13 +11,14 @@ use {
|
|||
},
|
||||
},
|
||||
renderer::{context::RenderContext, renderer::Renderer},
|
||||
sys::{glBlendFunc, glFlush, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
|
||||
RenderResult,
|
||||
sys::{glBlendFunc, glFlush, glReadnPixels, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
|
||||
RenderResult, Texture,
|
||||
},
|
||||
state::State,
|
||||
tree::Node,
|
||||
},
|
||||
std::{
|
||||
cell::Cell,
|
||||
fmt::{Debug, Formatter},
|
||||
rc::Rc,
|
||||
},
|
||||
|
|
@ -46,6 +48,57 @@ impl Framebuffer {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn copy_texture(&self, state: &State, texture: &Texture, x: i32, y: i32) {
|
||||
let _ = self.ctx.ctx.with_current(|| {
|
||||
unsafe {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, self.gl.fbo);
|
||||
glViewport(0, 0, self.gl.width, self.gl.height);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
let mut renderer = Renderer {
|
||||
ctx: &self.ctx,
|
||||
fb: &self.gl,
|
||||
state,
|
||||
on_output: false,
|
||||
result: &mut RenderResult::default(),
|
||||
};
|
||||
renderer.render_texture(texture, x, y, XRGB8888);
|
||||
unsafe {
|
||||
glFlush();
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
pub fn copy_to_shm(
|
||||
&self,
|
||||
x: i32,
|
||||
y: i32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
format: &Format,
|
||||
shm: &[Cell<u8>],
|
||||
) {
|
||||
let y = self.gl.height - y - height;
|
||||
let _ = self.ctx.ctx.with_current(|| {
|
||||
unsafe {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, self.gl.fbo);
|
||||
glViewport(0, 0, self.gl.width, self.gl.height);
|
||||
glReadnPixels(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
format.gl_format as _,
|
||||
format.gl_type as _,
|
||||
shm.len() as _,
|
||||
shm.as_ptr() as _,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
pub fn render(
|
||||
&self,
|
||||
node: &dyn Node,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use {
|
||||
crate::render::{
|
||||
egl::image::EglImage, gl::texture::GlTexture, RenderContext, RenderError, Texture,
|
||||
egl::image::EglImage,
|
||||
gl::{render_buffer::GlRenderBuffer, texture::GlTexture},
|
||||
Framebuffer, RenderContext, RenderError, Texture,
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
|
@ -25,4 +27,15 @@ impl Image {
|
|||
gl: GlTexture::import_img(&self.ctx.ctx, &self.gl)?,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn to_framebuffer(&self) -> Result<Rc<Framebuffer>, RenderError> {
|
||||
self.ctx.ctx.with_current(|| unsafe {
|
||||
let rb = GlRenderBuffer::from_image(&self.gl, &self.ctx.ctx)?;
|
||||
let fb = rb.create_framebuffer()?;
|
||||
Ok(Rc::new(Framebuffer {
|
||||
ctx: self.ctx.clone(),
|
||||
gl: fb,
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
use {
|
||||
crate::render::{gl::texture::GlTexture, renderer::context::RenderContext},
|
||||
std::rc::Rc,
|
||||
std::{
|
||||
fmt::{Debug, Formatter},
|
||||
rc::Rc,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct Texture {
|
||||
|
|
@ -8,6 +11,12 @@ pub struct Texture {
|
|||
pub(super) gl: GlTexture,
|
||||
}
|
||||
|
||||
impl Debug for Texture {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Texture").finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl Texture {
|
||||
pub fn width(&self) -> i32 {
|
||||
self.gl.width
|
||||
|
|
|
|||
|
|
@ -79,6 +79,15 @@ impl<T> LinkedList<T> {
|
|||
self.root.append(t)
|
||||
}
|
||||
|
||||
pub fn add_last_existing(&self, t: &NodeRef<T>) {
|
||||
self.root.prepend_existing(t)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn add_first_existing(&self, t: &NodeRef<T>) {
|
||||
self.root.append_existing(t)
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> LinkedListIter<T> {
|
||||
unsafe {
|
||||
let root = self.root.data.as_ref();
|
||||
|
|
|
|||
51
wire/zwlr_screencopy_frame_v1.txt
Normal file
51
wire/zwlr_screencopy_frame_v1.txt
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# requests
|
||||
|
||||
msg copy = 0 {
|
||||
buffer: id(wl_buffer),
|
||||
}
|
||||
|
||||
msg destroy = 1 {
|
||||
}
|
||||
|
||||
msg copy_with_damage = 2 {
|
||||
buffer: id(wl_buffer),
|
||||
}
|
||||
|
||||
# events
|
||||
|
||||
msg buffer = 0 {
|
||||
format: u32,
|
||||
width: u32,
|
||||
height: u32,
|
||||
stride: u32,
|
||||
}
|
||||
|
||||
msg flags = 1 {
|
||||
flags: u32,
|
||||
}
|
||||
|
||||
msg ready = 2 {
|
||||
tv_sec_hi: u32,
|
||||
tv_sec_lo: u32,
|
||||
tv_nsec: u32,
|
||||
}
|
||||
|
||||
msg failed = 3 {
|
||||
|
||||
}
|
||||
|
||||
msg damage = 4 {
|
||||
x: u32,
|
||||
y: u32,
|
||||
width: u32,
|
||||
height: u32,
|
||||
}
|
||||
|
||||
msg linux_dmabuf = 5 {
|
||||
format: u32,
|
||||
width: u32,
|
||||
height: u32,
|
||||
}
|
||||
|
||||
msg buffer_done = 6 {
|
||||
}
|
||||
20
wire/zwlr_screencopy_manager_v1.txt
Normal file
20
wire/zwlr_screencopy_manager_v1.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# requests
|
||||
|
||||
msg capture_output = 0 {
|
||||
frame: id(zwlr_screencopy_frame_v1),
|
||||
overlay_cursor: i32,
|
||||
output: id(wl_output),
|
||||
}
|
||||
|
||||
msg capture_output_region = 1 {
|
||||
frame: id(zwlr_screencopy_frame_v1),
|
||||
overlay_cursor: i32,
|
||||
output: id(wl_output),
|
||||
x: i32,
|
||||
y: i32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
}
|
||||
|
||||
msg destroy = 2 {
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue