1
0
Fork 0
forked from wry/wry

autocommit 2022-04-21 18:25:34 CEST

This commit is contained in:
Julian Orth 2022-04-21 18:25:34 +02:00
parent 0d414a5336
commit 32fe8b64ca
8 changed files with 133 additions and 28 deletions

View file

@ -121,7 +121,7 @@ impl WlDrm {
};
let formats = ctx.formats();
let format = match formats.get(&req.format) {
Some(f) => *f,
Some(f) => f.format,
None => return Err(CreatePrimeBufferError::InvalidFormat(req.format)),
};
let mut dmabuf = DmaBuf {

View file

@ -11,8 +11,9 @@ use {
render::Renderer,
state::State,
tree::{
FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, SizedNode, SizedToplevelNode,
ToplevelData, ToplevelNode, WorkspaceNode,
FindTreeResult, FoundNode, FullscreenData, Node, NodeId, NodeVisitor,
SizedFullscreenNode, SizedNode, SizedToplevelNode, ToplevelData, ToplevelNode,
WorkspaceNode,
},
utils::{
clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode,
@ -31,7 +32,6 @@ use {
},
thiserror::Error,
};
use crate::tree::{FullscreenData, SizedFullscreenNode};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum XInputModel {
@ -508,10 +508,15 @@ impl SizedToplevelNode for Xwindow {
fn set_fullscreen(self: &Rc<Self>, fullscreen: bool) {
if fullscreen {
if let Some(ws) = self.workspace.get() {
self.fullscreen_data.set_fullscreen(&self.data.state, self.clone(), &ws.output.get());
self.fullscreen_data.set_fullscreen(
&self.data.state,
self.clone(),
&ws.output.get(),
);
}
} else {
self.fullscreen_data.unset_fullscreen(&self.data.state, self.clone());
self.fullscreen_data
.unset_fullscreen(&self.data.state, self.clone());
}
}
@ -538,7 +543,12 @@ impl SizedFullscreenNode for Xwindow {
}
fn title(&self) -> String {
self.data.info.title.borrow_mut().clone().unwrap_or_default()
self.data
.info
.title
.borrow_mut()
.clone()
.unwrap_or_default()
}
}

View file

@ -11,7 +11,6 @@ use {
},
video::{
dmabuf::{DmaBuf, DmaBufPlane},
INVALID_MODIFIER,
},
wire::{zwp_linux_buffer_params_v1::*, WlBufferId, ZwpLinuxBufferParamsV1Id},
},
@ -37,6 +36,7 @@ pub struct ZwpLinuxBufferParamsV1 {
pub parent: Rc<ZwpLinuxDmabufV1>,
planes: RefCell<AHashMap<u32, Add>>,
used: Cell<bool>,
modifier: Cell<Option<u64>>,
pub tracker: Tracker<Self>,
}
@ -47,6 +47,7 @@ impl ZwpLinuxBufferParamsV1 {
parent: parent.clone(),
planes: RefCell::new(Default::default()),
used: Cell::new(false),
modifier: Cell::new(None),
tracker: Default::default(),
}
}
@ -71,8 +72,9 @@ impl ZwpLinuxBufferParamsV1 {
fn add(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), AddError> {
let req: Add = self.parent.client.parse(&**self, parser)?;
let modifier = ((req.modifier_hi as u64) << 32) | req.modifier_lo as u64;
if modifier != INVALID_MODIFIER {
return Err(AddError::InvalidModifier(modifier));
match self.modifier.get() {
Some(m) if m != modifier => return Err(AddError::MixedModifiers(modifier, m)),
_ => self.modifier.set(Some(modifier)),
}
let plane = req.plane_idx;
if plane > MAX_PLANE {
@ -98,14 +100,21 @@ impl ZwpLinuxBufferParamsV1 {
};
let formats = ctx.formats();
let format = match formats.get(&format) {
Some(f) => *f,
Some(f) => f,
None => return Err(DoCreateError::InvalidFormat(format)),
};
let modifier = match self.modifier.get() {
Some(m) => m,
_ => return Err(DoCreateError::NoPlanes),
};
if !format.modifiers.contains_key(&modifier) {
return Err(DoCreateError::InvalidModifier(modifier));
}
let mut dmabuf = DmaBuf {
width,
height,
format,
modifier: INVALID_MODIFIER,
format: format.format,
modifier,
planes: vec![],
};
let mut planes: Vec<_> = self.planes.borrow_mut().drain().map(|v| v.1).collect();
@ -128,7 +137,7 @@ impl ZwpLinuxBufferParamsV1 {
let buffer = Rc::new(WlBuffer::new_dmabuf(
buffer_id,
&self.parent.client,
format,
format.format,
&img,
));
track!(self.parent.client, buffer);
@ -223,8 +232,8 @@ pub enum AddError {
MaxPlane,
#[error(transparent)]
ClientError(Box<ClientError>),
#[error("The modifier {0} is not supported")]
InvalidModifier(u64),
#[error("Tried to add a plane with modifier {0} that differs from a previous modifier {1}")]
MixedModifiers(u64, u64),
#[error("The plane {0} was already set")]
AlreadySet(u32),
}
@ -239,6 +248,10 @@ pub enum DoCreateError {
NoRenderContext,
#[error("The format {0} is not supported")]
InvalidFormat(u32),
#[error("No planes were added")]
NoPlanes,
#[error("The modifier {0} is not supported")]
InvalidModifier(u64),
#[error("Plane {0} was not set")]
MissingPlane(usize),
#[error("Could not import the buffer")]

View file

@ -6,7 +6,6 @@ use {
leaks::Tracker,
object::Object,
utils::buffd::{MsgParser, MsgParserError},
video::INVALID_MODIFIER,
wire::{zwp_linux_dmabuf_v1::*, ZwpLinuxDmabufV1Id},
},
std::rc::Rc,
@ -39,9 +38,11 @@ impl ZwpLinuxDmabufV1Global {
if let Some(ctx) = client.state.render_ctx.get() {
let formats = ctx.formats();
for format in formats.values() {
obj.send_format(format.drm);
obj.send_format(format.format.drm);
if version >= MODIFIERS_SINCE_VERSION {
obj.send_modifier(format.drm, INVALID_MODIFIER);
for modifier in format.modifiers.values() {
obj.send_modifier(format.format.drm, modifier.modifier);
}
}
}
}