tiling: Animate tree changes

This commit is contained in:
Victoria Brekenfeld 2023-05-12 20:01:37 +02:00
parent ea1b976076
commit 331b884f1e
23 changed files with 1641 additions and 395 deletions

View file

@ -2,17 +2,22 @@
use crate::{
shell::CosmicSurface,
state::{BackendData, Data},
state::{BackendData, ClientState, Data},
utils::prelude::*,
wayland::protocols::screencopy::SessionType,
};
use calloop::Interest;
use smithay::{
backend::renderer::utils::{on_commit_buffer_handler, with_renderer_surface_state},
delegate_compositor,
desktop::{layer_map_for_output, LayerSurface, PopupKind, WindowSurfaceType},
reexports::wayland_server::protocol::wl_surface::WlSurface,
reexports::wayland_server::{protocol::wl_surface::WlSurface, Client, Resource},
wayland::{
compositor::{with_states, CompositorHandler, CompositorState},
compositor::{
add_blocker, add_pre_commit_hook, with_states, BufferAssignment, CompositorClientState,
CompositorHandler, CompositorState, SurfaceAttributes,
},
dmabuf::get_dmabuf,
seat::WaylandFocus,
shell::{
wlr_layer::LayerSurfaceAttributes,
@ -21,7 +26,7 @@ use smithay::{
},
},
},
xwayland::X11Wm,
xwayland::{X11Wm, XWaylandClientData},
};
use std::sync::Mutex;
@ -105,15 +110,63 @@ impl State {
}
}
pub fn client_compositor_state<'a>(client: &'a Client) -> &'a CompositorClientState {
if let Some(state) = client.get_data::<XWaylandClientData>() {
return &state.compositor_state;
}
if let Some(state) = client.get_data::<ClientState>() {
return &state.compositor_client_state;
}
panic!("Unknown client data type")
}
impl CompositorHandler for State {
fn compositor_state(&mut self) -> &mut CompositorState {
&mut self.common.compositor_state
}
fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState {
client_compositor_state(client)
}
fn new_surface(&mut self, surface: &WlSurface) {
add_pre_commit_hook::<Self, _>(surface, move |state, _dh, surface| {
let maybe_dmabuf = with_states(surface, |surface_data| {
surface_data
.cached_state
.pending::<SurfaceAttributes>()
.buffer
.as_ref()
.and_then(|assignment| match assignment {
BufferAssignment::NewBuffer(buffer) => get_dmabuf(buffer).ok(),
_ => None,
})
});
if let Some(dmabuf) = maybe_dmabuf {
if let Ok((blocker, source)) = dmabuf.generate_blocker(Interest::READ) {
let client = surface.client().unwrap();
let res =
state
.common
.event_loop_handle
.insert_source(source, move |_, _, data| {
data.state
.client_compositor_state(&client)
.blocker_cleared(&mut data.state, &data.display.handle());
Ok(())
});
if res.is_ok() {
add_blocker(surface, blocker);
}
}
}
})
}
fn commit(&mut self, surface: &WlSurface) {
X11Wm::commit_hook::<Data>(surface);
// first load the buffer for various smithay helper functions
on_commit_buffer_handler(surface);
on_commit_buffer_handler::<Self>(surface);
// then handle initial configure events and map windows if necessary
if let Some((window, seat)) = self

View file

@ -947,6 +947,7 @@ pub fn render_window_to_buffer(
renderer,
(-geometry.loc.x, -geometry.loc.y).into(),
Scale::from(1.0),
1.0,
);
for seat in common.seats() {