Add support for wl_compositor@v6

This commit is contained in:
Kirill Chibisov
2023-10-26 00:15:46 +04:00
committed by Ivan Molodetskikh
parent 49a8f156f3
commit 0a2052945e
9 changed files with 121 additions and 37 deletions
+21 -1
View File
@@ -52,7 +52,7 @@ use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::render_elements;
use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
use smithay::wayland::compositor::with_states;
use smithay::wayland::compositor::{send_surface_state, with_states, SurfaceData};
use smithay::wayland::shell::xdg::SurfaceCachedState;
use crate::animation::Animation;
@@ -77,6 +77,7 @@ pub trait LayoutElement: SpaceElement + PartialEq + Clone {
fn max_size(&self) -> Size<i32, Logical>;
fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool;
fn has_ssd(&self) -> bool;
fn with_surfaces<F: FnMut(&WlSurface, &SurfaceData)>(&self, processor: F);
}
#[derive(Debug)]
@@ -333,6 +334,10 @@ impl LayoutElement for Window {
self.toplevel().wl_surface() == wl_surface
}
fn with_surfaces<F: FnMut(&WlSurface, &SurfaceData)>(&self, processor: F) {
self.with_surfaces(processor);
}
fn has_ssd(&self) -> bool {
self.toplevel().current_state().decoration_mode
== Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
@@ -1903,6 +1908,7 @@ impl<W: LayoutElement> Workspace<W> {
fn enter_output_for_window(&self, window: &W) {
if let Some(output) = &self.output {
// FIXME: proper overlap.
self.send_surface_state_for_window_tree(window, output);
window.output_enter(
output,
Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX)),
@@ -1937,12 +1943,24 @@ impl<W: LayoutElement> Workspace<W> {
let bounds = self.toplevel_bounds();
if let Some(output) = self.output.as_ref() {
self.send_surface_state_for_window_tree(window, output);
}
window.toplevel().with_pending_state(|state| {
state.size = Some(size);
state.bounds = Some(bounds);
});
}
fn send_surface_state_for_window_tree(&self, window: &impl LayoutElement, output: &Output) {
let scale = output.current_scale().integer_scale();
let transform = output.current_transform();
window.with_surfaces(|surface, data| {
send_surface_state(surface, data, scale, transform);
});
}
fn compute_new_view_offset_for_column(&self, current_x: i32, idx: usize) -> i32 {
if self.columns[idx].is_fullscreen {
return 0;
@@ -2890,6 +2908,8 @@ mod tests {
false
}
fn with_surfaces<F: FnMut(&WlSurface, &SurfaceData)>(&self, _processor: F) {}
fn has_ssd(&self) -> bool {
false
}